簡體   English   中英

PHP MYSQL:插入不適用於准備好的語句

[英]PHP MYSQL : insert dont work with prepared statement

我將代碼插入表中的行:

$req = $bdd->prepare('INSERT INTO cours (id_region, id_type, nom, difficulte, duree1, duree2, remarque, nb_personne, note, publicateur)
VALUES(:region, :type, :nom, :level, :duree1, :duree2, :remarque, :nbPerso, :note, :publicateur)');

$rq = 'not yet';
$note = 5;
$prod = 'admin';

$req->bindParam(':region', $region);
$req->bindParam(':type', $type);
$req->bindParam(':nom', $name);
$req->bindParam(':level', $level);
$req->bindParam(':duree1', $temps1);
$req->bindParam(':duree2', $temps2);
$req->bindParam(':remarque', $rq);
$req->bindParam(':nbPerso', $nbPers);
$req->bindParam(':note', $note);
$req->bindParam(':publicateur', $prod);

$req->execute() or die('Problem insert '.mysql_error());  

當我調用php頁面時,我Problem insert ,但看不到錯誤的詳細信息

在調用准備好的語句之前,我已添加以下代碼來跟蹤錯誤:

ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', 'C:wamp/www/Cours/php/log_error_php.txt');
error_reporting(E_ERROR);

在php.ini中,我所有用於顯示錯誤的變量都等於“ on”

准備好的語句中的錯誤在哪里?

您正在使用mysql_error(),但沒有使用mysql。

嘗試使用errorInfo() (對於您的情況為PDO),或者如果您想使用mysqli,則可以使用mysqli_error()

看來您正在將PDO與mysqli混合使用,而兩者卻無法相互配合。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM