繁体   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