从客户端无法更新mysql的脚本

时间:2013-05-29 16:29:11

标签: php mysql

1 - 更新我的mysql客户端的脚本 2 - 当我离开(其中id = id&#34 ;;)时,我将其他id加倍,只是让它们改变相同。当我编辑客户端的配置文件时。我知道这个问题,但不知道该放什么,我尝试了这么多的选择,但仍然不起作用, 3 - 这是我的剧本:

<?php
include('../conect.php');
if(isset($_POST['update']))
   // Get values from form
$id=$_POST['id'];
$username=$_POST['username'];
$utilizator=$_POST['utilizator'];
$password=$_POST['password'];
$nivel=$_POST['nivel'];
$departament=$_POST['departament'];
$location=$_POST['location'];
$country=$_POST['country'];
$email=$_POST['email'];
$ip=$_POST['ip'];


$query = "UPDATE utilizatori SET username = '$username', utilizator = '$utilizator', password = '$password', nivel = '$nivel', departament = '$departament', location = '$location', country = '$country', email = '$email', ip = '$ip' where id= id";
$res = mysql_query($query);
mysql_query($update);
    echo $update;


mysql_query($query);
echo "Record Updated";

header('location:../user.php');
// close connection
mysql_close(); 
?> 

2 个答案:

答案 0 :(得分:0)

您没有引用$id变量,而是一个打破查询语句的字符串文本id。添加一个美元符号来引用变量,如果它不是整数,则用单引号括起来。

$query = "UPDATE utilizatori SET username = '$username', {...}, ip = '$ip' where id= '$id' ";

答案 1 :(得分:0)

试试这个:

    <?php
include('../conect.php');
if(isset($_POST['update'])){
// Get values from form
$id=$_POST['id'];
$username=$_POST['username'];
$utilizator=$_POST['utilizator'];
$password=$_POST['password'];
$nivel=$_POST['nivel'];
$departament=$_POST['departament'];
$location=$_POST['location'];
$country=$_POST['country'];
$email=$_POST['email'];
$ip=$_POST['ip'];
    $query = "UPDATE utilizatori SET username = '$username', utilizator = '$utilizator',
    password = '$password', nivel = '$nivel', departament = '$departament', 
    location = '$location', country = '$country', email = '$email', ip = '$ip' 
    where id= $id";
    $res = mysql_query($query);
    if ($res) {
    echo "Record Updated";
    } else {
    echo "Record not updated.";
    }
    header('location:../user.php');
    } // end of first if statement
    // close connection
    mysql_close(); 
    ?>