2016-01-09 78 views
-3
  1. $abc = mysql_fetch_array($result); 
        if (!$result) 
        die("Error: Data not found..");   
    
    $name=$abc['name'] ; 
    $email= $abc['email'] ;     
    
    
    $sql = "UPDATE example SET name ='$name', email ='$email' WHERE id = '$id'"; 
        if(mysql_query($con, $sql)) //Error 
         Echo "Record Update successfully"; 
        else 
         Echo "ERROR: could not able to execute $sql".mysql_error($con); 
    
    mysql_close($con); 
    
+0

mysql_query()期望參數1是字符串,給定的資源//這是錯誤 –

+0

'mysql_query($ sql,$ con)' – smoqadam

+0

1錯誤解決thnks,&另一個錯誤=無法執行更新示例SET name ='',email =''WHERE id ='19'Table'test.example'does not exist –

回答

2

更新你的代碼是這樣的:

$sql = "UPDATE example SET name = $name,email = $email WHERE id = $id"; 
mysql_query($sql,$con); 
0

你必須以$ CON

if(mysql_query($sql, $con)) 
     { 
     Echo "Record Update successfully"; 
     } 
     else 
     { 
     Echo "ERROR: could not able to execute $sql".mysql_error($con); 
     } 
0
0

您可以使用mysqli的替代,這是MySQL的新版本有更多的安全功能,但你必須要單位所有的代碼使用MySQL或mysqli的

mysqli_query($connection,$query); 

OR

mysql_query($query,$connection); 

每當你使用mysqli,你應該設置參數1爲連接資源

相關問題