警告:mysqli :: prepare()只需要1个参数,给出2

时间:2013-07-31 02:03:01

标签: 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();
}

1 个答案:

答案 0 :(得分:5)

您正在混合API和样式。

mysql_connectmysql_select_db与MySQLi的库不同。

尝试:

$mysqli = new mysqli("host","user","password","database"); 

而不是:

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

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

然后将准备好的陈述改为:

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); 

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

从:

开始

Mysqli::Construct了解如何正确初始化MySQLi类,然后继续准备语句stmt::FunctionName