这是数据库
这是前端页面
后台(ajaxinsert.php)
$pdo=new PDO("mysql:host=localhost;dbname=t1","root","");
$id=$_GET["id"];
$stmt=$pdo->prepare("insert into ajax(txt)values(:txt)");
$stmt->execute(array($id));
?>
回复讨论(解决方案)
$stmt=$pdo->prepare("insert into ajax (txt) values (:txt)");
$stmt->execute(array(‘:txt' =>$id));
或
$stmt=$pdo->prepare("insert into ajax (txt) values (?)");
$stmt->execute(array($id));
改成这样
prepare("insert into ajax(txt) values(?)");$stmt->execute(array($id));?>