插入带有两个变量的php
下面的代码插入了一个变量。但是你怎么做到两个呢插入带有两个变量的php,php,pdo,Php,Pdo,下面的代码插入了一个变量。但是你怎么做到两个呢 $query = $pdo->prepare("INSERT INTO `{$test}` (user_id) VALUES (?)"); $query->bindValue(1, $idv); 我试过了 $query = $pdo->prepare("INSERT INTO `{$test}` (user_id,another_id) VALUES (?,?)"); $query->bindValue(1, $idv
$query = $pdo->prepare("INSERT INTO `{$test}` (user_id) VALUES (?)");
$query->bindValue(1, $idv);
我试过了
$query = $pdo->prepare("INSERT INTO `{$test}` (user_id,another_id) VALUES (?,?)");
$query->bindValue(1, $idv);
$query->bindValue(1, $idvsecond);
但这似乎不起作用。替换
$query->bindValue(1, $idvsecond);
与
对于要绑定的每个参数,为其指定相应的编号:
$query = $pdo->prepare("INSERT INTO `{$test}` (user_id,another_id) VALUES (?,?)");
$query->bindValue(1, $idv);
$query->bindValue(2, $idvsecond);
啊,这是有道理的,不是吗?我只是想说:试试
$query->bindValue(2,$idvs秒)但是夜班的工作人员刚进来。
$query = $pdo->prepare("INSERT INTO `{$test}` (user_id,another_id) VALUES (?,?)");
$query->bindValue(1, $idv);
$query->bindValue(2, $idvsecond);