Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 字符串中的元素数不为';不匹配绑定变量的数量_Php_Mysql_Sql_Mysqli - Fatal编程技术网

Php 字符串中的元素数不为';不匹配绑定变量的数量

Php 字符串中的元素数不为';不匹配绑定变量的数量,php,mysql,sql,mysqli,Php,Mysql,Sql,Mysqli,嗨 尝试通过准备好的语句执行查询时,我收到以下错误: // prepare and bind 以下代码: Number of elements in string doesn't match number of bind variables 这里有两个明显的缺点: 不要在准备好的语句中的占位符周围加引号 bind_param()的第一个参数应该是一个字符串,用于标识后续参数的数据类型- 由9个s组成的字符串,因为您有9个参数,并且都是字符串(s)值不要在准备好的语句中的占位符

尝试通过准备好的语句执行查询时,我收到以下错误:

// prepare and bind
以下代码:

Number of elements in string doesn't match number of bind variables     

这里有两个明显的缺点:


  • 不要在准备好的语句中的占位符周围加引号

  • bind_param()
    的第一个参数应该是一个字符串,用于标识后续参数的数据类型-


由9个
s
组成的字符串,因为您有9个参数,并且都是字符串(
s
)值

不要在准备好的语句中的占位符周围加引号。
bind_param()
的第一个参数应该是标识后续参数的数据类型的字符串-
$track = $con->prepare("INSERT INTO resources_record (name,email,stage,format,topic,max_cost,mentor,total_cost,duration)
              VALUES ('?', '?', '?', '?', '?', '?', '?', '?', '?')");
    $track->bind_param($fullName, $email, $stage, $format, $topic, $cost, $mentor, $price, $duration);

    // Execute
    $track->execute();

    $track->close();
$track = $con->prepare("INSERT INTO resources_record (name,email,stage,format,topic,max_cost,mentor,total_cost,duration)
          VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
$track->bind_param('sssssssss', $fullName, $email, $stage, $format, $topic, $cost, $mentor, $price, $duration);