mysqli_query UPDATE不起作用

时间:2015-08-27 00:46:54

标签: php mysql

我尝试使用带变量的值更新表。这是我的代码:

$event = mysqli_query($con,"SELECT * FROM Events WHERE Name='$eventName'");
$credits=0;
$creditTally=0;
$spotsTaken=0;

while($row = mysqli_fetch_array($event)) {
    $credits = $row['Credits_Worth'];
    $creditTally= $row['Credit_Tally'];
    $spotsTaken= $row['Spots_Taken'];

}
echo $creditTally; //1st print
    $creditTally+=1;
    echo $creditTally. "<br>";//2nd print
    mysqli_query($con, "UPDATE `events` SET `Credit_Tally` = `$creditTally` WHERE `Name`= `$eventName`");

Credit_Tally的表值最初从0开始,这由我的第一个echo确认。在我将其递增1之后,它会像它应该的那样打印出来。另一方面,我的查询不是更新表。我没有任何错误或任何错误,但表格中的数字不会改变。 $ eventName填充了GET和Credit_Tally中的值,Name是我的SQL表中的有效列。我的查询有什么问题?

0 个答案:

没有答案