Saturday, 17 August 2013

PHP prepared statement error: Warning: mysqli_stmt::bind_param():

PHP prepared statement error: Warning: mysqli_stmt::bind_param():

I'm learning to use prepared statements to select all my data from the
table in my database however i am getting this error
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match
number of parameters in prepared statement in
/Applications/XAMPP/xamppfiles/htdocs/contenteditable/classes/class.Insert.inc
on
line 13
Perhaps I'm not using the prepared statements in the right way I'm not
sure, I have used prepared statements before so hopefully somebody could
tell me where Im going wrong or if anyone has a working example that would
be helpful.
This is my code:
index.php
<div id="maincontent" contenteditable="true">
<?php
//get data from database.
require("classes/class.Insert.inc");
$insert = new Insert();
$insert->read();
?>
<button id="save">Save</button>
<input type="button" id="clear" value="Clear changes" />
</div>
classes/class.Insert.php
<?php
include("connect/class.Database.inc");
class Insert extends Database {
public $firstname;
public $content;
public function read(){
$stmt = $this->mysqli->prepare('SELECT * FROM datadump');
$stmt->bind_param('s', $content);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo $content; }
}
}
?>

No comments:

Post a Comment