3列の単純なテーブルがあります:
testID は INT(11) 自動インクリメント プライマリ インデックスです。
name は VARCHAR テキストフィールドです
位置は INT(11) フィールドです
<?php
error_reporting(E_ALL);
require("mysqli.test.inc");
$name1="Rhonda Hotop"; $position1=456;
$name2="Perry Shafran"; $position2 = 789;
$sqlupdate = "UPDATE test SET name = ?, position =?";
$sqlinsert = "INSERT INTO test (name, position) VALUES (name = ?, position = ?)";
//create the connection to the database
$con = new mysqli($hostname,$username,$password,$database);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//test an UPDATE
$statement = $con->prepare($sqlupdate);
$statement->bind_param("si", $name1, $position1);
$statement->execute();
$statement->close();
//test an INSERT
$statement = $con->prepare($sqlinsert);
$statement->bind_param('si', $name2, $position2);
$statement->execute();
$statement->close();
exit();
接続は機能します。
更新は機能します。
ただし、INSERT はそうではありません。正しい testID フィールドを持つ新しいレコードが作成されますが、name2 フィールドと position2 フィールドは両方とも 0 に設定されています。
いくつかの助けをいただければ幸いです。