簡體   English   中英

SQL更新說成功,但不更新數據庫中的表

[英]SQL update saying successful but doesn't update table in database

我在使用SQL更新查詢時遇到問題,它說成功,但實際上並沒有更新數據庫記錄。

<?php

    require_once('auth.php');

    $host="localhost"; // Host name 
    $username="root"; // Mysql username
    $password="sysadmin"; // Mysql password 
    $db_name="Elite"; // Database name 
    $tbl_name="Triage"; // Table name 

    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="UPDATE Triage SET directly='$directly', psychologically='$psychologically' WHERE Reference='$Reference'";
    $result=mysql_query($sql);
$sql="UPDATE Triage SET directly='$directly', psychologically='$psychologically' WHERE Reference='$Reference'";

上面的代碼中沒有定義該查詢中使用的變量。 $directly,$psychologically,$Reference :沒有值。 定義這些值就可以了。

$Reference是必須的,即使其他人不是必須的。

$refrence="1";
$sql="UPDATE Triage SET directly='$directly' AND psychologically='$psychologically' WHERE Reference='$Reference'";

用您的MySQL ref替換$ refrence

使用此語法

 $sql=  UPDATE Triage SET directly=?, psychologically=? WHERE Reference=?";
 $param->execute(array($directly,$psychologically,$Reference));
 $result=mysql_query($param);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM