php - Updating table via PDO prepare query -


i've been having problems trying update value based off code received on page.

for example:

http://example.com/register.php?code=fa82f82712d1 (not actual code, it's 32-char code actually).

i start transaction, , update in following way:

$stmt = $stmt->prepare("update user set got_code = 1 code = :code"); 

then $stmt->execute(array(':code' => $code)); code gotten before.

but never updates anything, i'm running rowcount() (gives me '0') , closing transaction can't seem updated.

the column type char(32) should match length of code received.

is possible it's causing confusions because of data type?

maybe bind parameter before like:

$stmt2 = $stmt->prepare("update user set got_code = 1 code = :code"); $stmt2->bindparam(":code", $code, pdo::param_str); if ($stmt2->execute()){         $stmt->commit();     } else {         $stmt->rollback();     } 

edit: after comment of other people. basic not use

$stmt = $stmt->prepare("update user set got_code = 1 code = :code"); 

but give different var name like

$stmt2 = $stmt->prepare("update user set got_code = 1 code = :code"); 

because otherwise system overwrite $stmt , not work anymore


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -