$db = new mysqli('localhost','root','nere','deneme');
if ($db->error)
exit();
$stmt = $db->prepare("INSERT INTO deneme VALUES (?,?,?)");
$stmt->bind_param('ssi',$adi,$soyadi,$no);
$adi='recep';
$soyadi='saban';
$no=5;
$stmt->execute();
i got error.
Fatal error: Call to a member function bind_param() on a non-object in C:\wamp\www\rock\index.php on line 10
what I am doing wrong?
it should be something like below. Also you should assign the values to the variables before passing it to bind_param()
if ($db->error)
exit();
if ($stmt = $db->prepare("INSERT INTO deneme VALUES (?,?,?)")) {
$adi='recep';
$soyadi='saban';
$no=5;
$stmt->bind_param('ssi',$adi,$soyadi,$no);
$stmt->execute();
}
It's also a good idea to tell which columns should be populated in your database:
INSERT INTO deneme (column1, column2, column3) VALUES (?,?,?)
Looks like your prepare statement is failing, and $stmt is false (you should add some checking there). Does table deneme actually exists?