2013-07-31 75 views
0

給出2我卡在這裏它給我這個錯誤=(任何幫助警告:mysqli的準備::()期望的是1個參數,在

$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(); 
} 
+5

您已經使用了'mysql'和'mysqli'函數的混合。 – DevZer0

+0

代碼中的$ mysqli是什麼? – Achrome

回答

4

你混合兩者的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

+0

''$ cedula''> SQL注入。 – BlitZ

+1

@CORRUPT謝謝你指出。如果開啓了嚴格的報告,則OP應該在準備好的語句中出現錯誤。但是,謝謝 –

相關問題