pedromas Posted March 31, 2009 Share Posted March 31, 2009 Hi everyone, I am currently having a problem with phpDesigner. Whenever I use the mysqli_stmt->bind_result() it gives me the following error: Number of bind variables doesn't match number of fields in prepared statement. Underneath I have a simple php code where this happens. Do you know why this might be happening? Any help is highly appreciated. <?php //Start connection $mysqli = new mysqli( 'localhost', 'user', 'pass', 'db'); if(!$mysqli) { die('A connection to the database was not possible!'); } if($mysqli_stmt = $mysqli->stmt_init()) { //Prepared instructions $sql = 'SELECT*FROM destinations WHERE id = ? '; $sql .='AND city != ?'; $string = 'Berlin'; $integer = 3; $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('si', $string,$integer); $mysqli_stmt->execute(); //Error if($mysqli_stmt->errno) { echo 'Fehler ('.$mysqli_stmt->errno.'): '.$mysqli_stmt->error; } if($mysqli_stmt->result_metadata()) { $mysqli_stmt->store_result(); echo 'Datasaetzen: '.$mysqli_stmt->num_rows.'<br />'; //recall result $attr1=''; $attr2=''; $mysqli_stmt->bind_result($attr1,$attr2); while($mysqli_stmt->fetch()) { echo $attr1.' | '.$attr2.'<br />'; } } else { echo 'Datensaetze: '.$mysqli_stmt->affected_rows.'<br />'; } $mysqli_stmt->close(); } else { die('It was not possible to generate the object!'); } $mysqli->close(); ?> Link to comment https://forums.phpfreaks.com/topic/151971-mysqli_stmt-bind_resultattr1-attr2-not-working/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.