警告:mysqli :: prepare()期望恰好有1个参数,其中2个给定

Gab*_*lza 0 php sql forms

我被困在这里给我这个错误=(有什么帮助吗?

$link = mysql_connect("localhost","odyssexxxxxx","xxxxxxxx")
or die ("Could not connect :" . mysql_error());

// db
mysql_select_db("odysseus_matchcode",$link);


// ejecucion del query

if ($insert_stmt = $mysqli->prepare("UPDATE members SET (nombre, apellido, username, email, password, salt, telefono) VALUES (?, ?, ?, ?, ?, ?, ?) WHERE `cedula` = '$cedula'",$link)) {    
   $insert_stmt->bind_param('sssssss', $nombre, $apellido, $username, $email, $password, $random_salt, $telefono); 
    // Execute the prepared query.
   $insert_stmt->execute();
}
Run Code Online (Sandbox Code Playgroud)

Dar*_*ill 5

您正在混合使用API​​和样式。

mysql_connect并且mysql_select_db与MySQLi属于不同的库。

尝试拥有:

$mysqli = new mysqli("host","user","password","database"); 
Run Code Online (Sandbox Code Playgroud)

代替:

$link = mysql_connect("localhost","odyssexxxxxx","xxxxxxxx")
or die ("Could not connect :" . mysql_error());

// db
mysql_select_db("odysseus_matchcode",$link);
Run Code Online (Sandbox Code Playgroud)

然后将准备好的语句更改为:

if ($insert_stmt = $mysqli->prepare("UPDATE members SET (nombre, apellido, username, email, password, salt, telefono) VALUES (?, ?, ?, ?, ?, ?, ?) WHERE `cedula` = ?")) { 

   $insert_stmt->bind_param('ssssssss', $nombre, $apellido, $username, $email, $password, $random_salt, $telefono,$cedula); 
Run Code Online (Sandbox Code Playgroud)

我也建议阅读手册:http : //uk1.php.net/manual/en/book.mysqli.php

开始于:

Mysqli :: Construct来查看如何正确初始化MySQLi类,然后继续执行准备好的语句stmt::FunctionName