note 74065 rejected from function.mysqli-stmt-prepare by bobby

From: Date: Thu, 22 Mar 2007 14:26:17 +0000
Subject: note 74065 rejected from function.mysqli-stmt-prepare by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-124711@lists.php.net to get a copy of this message
Note Submitter: kyle dot m dot hall at gmail dot com ---- I feel like I'm losing my mind. When I run the following code, my SELECT works just fine, but my UPDATE affects 0 rows. I would like to see the actual SQL statement being executed, but as far as I can tell, there is no way to do so. $query = 'SELECT cardnumber FROM borrowers WHERE password IS NULL'; $patronData = array(); if ( $result = $mysqli->query( $query ) ) { /* fetch associative array */ while ( $row = $result->fetch_assoc() ) { $cardnumber = $row['cardnumber']; $userid = $cardnumber; $password = md5_base64( $cardnumber ); $query = $mysqli->prepare("UPDATE borrowers SET password = ?, userid = ? WHERE cardnumber = ?"); $query->bind_param( 'sss', $password, $userid, $cardnumber ); $query->execute(); if ( $mysqli->error ) { try { throw new Exception("MySQL error $mysqli->error <br> Query:<br> $query", $msqli->errno); } catch( Exception $e ) { echo "Error No: ".$e->getCode(). " - ". $e->getMessage() . "<br >"; echo nl2br($e->getTraceAsString()); } } else { echo "Created password hash $password and userid $userid for cardnumber $cardnumber\n"; echo $mysqli->info . "\n"; } } /* free result set */ $result->close(); } else { printf("Connect failed: %s\n", $mysqli->error ); }

« previous php.notes (#124711) next »