Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php更新sql_Php_Mysql_Sql_Updating - Fatal编程技术网

使用php更新sql

使用php更新sql,php,mysql,sql,updating,Php,Mysql,Sql,Updating,我正在尝试使用php制作一个更新表单并更新sql数据库,但在这里似乎不起作用。我尝试更新表单,然后它应该说它已更新,但它不想工作。我需要帮助。谢谢 <?php include 'connections/connection.php'; $updateinfo = @$_POST['update']; $get_info = mysql_query("SELECT * FROM customer"); $id = @$_REQUEST['id']; $get_row = mysql_fe

我正在尝试使用php制作一个更新表单并更新sql数据库,但在这里似乎不起作用。我尝试更新表单,然后它应该说它已更新,但它不想工作。我需要帮助。谢谢

<?php
include 'connections/connection.php';

$updateinfo = @$_POST['update'];

$get_info = mysql_query("SELECT * FROM customer");
$id = @$_REQUEST['id'];
$get_row = mysql_fetch_assoc($get_info);
$db_cname = $get_row['customer_name'];
$db_cemail = $get_row['customer_email'];
$db_caddress = $get_row['customer_address'];
$db_cphone = $get_row['customer_phone'];

  if ($updateinfo) {
    $cname = strip_tags(@$_POST['cname']); 
    $cemail = strip_tags(@$_POST['cemail']);
    $caddress = strip_tags(@$_POST['caddress']);
    $cphone = strip_tags(@$_POST['cphone']); 

    //Submit the form to the database
    $info_submit_query = mysql_query("UPDATE customer SET customer_name='$cname', customer_email='$cemail', customer_address='$caddress', customer_phone='$cphone' WHERE id='$id'") or die("Error! " . mysql_error());
    echo "updated!";
   }
  else
 {
   echo "error " . mysql_error();
}
?>

将错误报告添加到文件顶部
错误报告(全部);ini设置(“显示错误”,1)在开发过程中。您还可以使用
@
符号抑制可能的错误。必须使用“mysql已被弃用。请开始使用mysqli或PDO”。“其中id=”$id“..我已经有一段时间没有使用PHP了,但是如果说id是5…其中id='5'..id被存储为int…那么如果这就是它被插值的方式…引号可能会把它扔掉。不要只是说它不工作。说出发生了什么。你是在敲你的
还是死
语句?如果是,提供了什么错误?
<head>
    <title>Customer Modification</title>
</head>
<body>

<table border="0" cellpadding="10" cellspacing="5" width="30%" style="margin-top:100px;" align="center" bgcolor="#FFB13C">
        <form action="edit.php" method="post">
            <tr>
                <td><b>Customer Name:*</b></td>
                <td><input type="text" size="50" name="cname" value="<?php echo $db_cname; ?>"></td>
            </tr>
            <tr>
                <td><b>Customer Email:*</b></td>
                <td><input type="text" size="50" name="cemail" value="<?php echo $db_cemail; ?>"></td>
            </tr>
            <tr>
                <td><b>Customer Address:*</b></td>
                <td><input type="text" size="50" name="caddress"  value="<?php echo $db_caddress; ?>"></td>
            </tr>
            <tr>
                <td><b>Customer Phone:*</b></td>
                <td><input type="text" size="50" name="cphone" value="<?php echo $db_cphone; ?>"></td>
            </tr>
            <tr>
                <td><input type="reset" name="reset" value="Reset"></td>
                <td><input type="submit" name="update" value="Edit"></td>
            </tr>
        </form>

    </table>
</body>