php - 使用 php 更新现有的 mysql 记录

标签 php mysql forms

尝试更新 phpMyAdmin 中的现有记录,但以下代码似乎不起作用。

<?php 
$id = stripslashes($_POST['id']);

$title = stripslashes($_POST['title']);
$first = stripslashes($_POST['first']);
$surname = stripslashes($_POST['surname']);
$email = stripslashes($_POST['email']);
$promotion = stripslashes($_POST['promotion']);

$maths11 = stripslashes($_POST['maths11']);
$english11 = stripslashes($_POST['english11']);
$english13 = stripslashes($_POST['english13']);
$science13 = stripslashes($_POST['science13']);
$maths133 = stripslashes($_POST['maths133']);
$maths132 = stripslashes($_POST['maths132']);

$address = stripslashes($_POST['address']);
$address2 = stripslashes($_POST['address2']);
$town = stripslashes($_POST['town']);
$county = stripslashes($_POST['county']);
$code = stripslashes($_POST['code']);
$tel = stripslashes($_POST['tel']);

//database connection

$query="UPDATE Promotions SET address='$address', address2='$address2', town='$town', county='$county', postcode='$code', tel='$tel' WHERE id = '$id'";
mysql_query($query) or die(mysql_error());


include 'confirm.php';
include 'registerEmail.php';
?>

有什么帮助吗?谢谢

最佳答案

而不是无用的 die ('Error updating database'); 以更多信息的方式处理你的错误

mysql_query($query) or trigger_error(mysql_error().' in '.$query);

阅读上面的内容

关于php - 使用 php 更新现有的 mysql 记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5537353/

相关文章:

使用exec函数的php后台进程

php - 反转和反转数组的数组

php - 如何通过限制每 4 个结果来分隔 php mysqli 结果

mysql - 如何按升序对这些数据进行排序?

html - &lt;input&gt; 有神秘的底部填充

php - 证书、php > 5.6 和 SMTP 问题

mysql - 从 MySQL Workbench 更新 BLOB

javascript - 向网页提交多个表单

forms - html 表格 : checkboxes group for pretty url query

php - 禁用对包含文件的访问