第二个查询不起作用

时间:2014-07-25 06:52:02

标签: php mysql

第一个查询工作正常但第二个查询不更新数据库。我找不到错误。

<?php
if (isset($_GET['id'])) {
    $editdes = $_GET['id'];
    $con     = mysqli_connect("localhost", "user", "password", "Destinos");
    $con1    = mysqli_connect("localhost", "user", "password", "var");
    // Check connection
    if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    mysqli_query($con, "UPDATE Destinos SET Precio=730 WHERE Destino='$editdes'");
    mysqli_query($con1, "UPDATE var SET variable='$editdes' WHERE variable= * ");


    mysqli_close($con);
}
?>

1 个答案:

答案 0 :(得分:3)

*是字符串,如果用作字段的值,则应引用

UPDATE var SET variable='$editdes' WHERE variable= '*'

非常重要:How can I prevent SQL injection in PHP?