尝试更新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';
?>有什么帮助吗?谢谢
发布于 2011-04-04 18:47:29
die ('Error updating database');不是非常无用,而是以更具信息性的方式处理错误
mysql_query($query) or trigger_error(mysql_error().' in '.$query);看看上面写的是什么
发布于 2011-04-04 19:53:19
使用mysql_error(),就像Shrapnel上校展示的那样。
但让我苦恼的是。这就是该页面的所有代码吗?因为您有//database connection,但我没有看到任何数据库连接。是否确实要连接到数据库并将该连接包含在文件中?
编辑:
当你回显时,你的查询是什么样子的?也许id是空的..。这样,您就可以确切地看到要发送到db的内容。
echo $query;https://stackoverflow.com/questions/5537353
复制相似问题