使用HTTP POST方法通过php更新mysql数据库
它完全在应用程序上执行,我再次检查它。 它正确地发送所有参数,问题是在PHP脚本它不执行查询(更新,删除)它正确执行插入查询。 该PHP脚本完美的HTML形式,但我不知道问题在哪里。
这是我的PHP脚本:
$mysql_host = "localhost"; $mysql_database = "locator"; $mysql_user = "root"; $mysql_password = ""; mysql_connect($mysql_host,$mysql_user,$mysql_password) or die(mysql_error()); mysql_select_db($mysql_database); $uMail = $_POST['u_mail']; $uIMEI = $_POST['u_IMEI']; $uName = $_POST['u_name']; $uPass = $_POST['u_pass']; $tName = $_POST['t_names']; $tIMEI = $_POST['t_IMEIs']; $tDesc = $_POST['t_desc']; mysql_query("UPDATE user_master SET t_names='$tName',t_IMEIs='$tIMEI',t_desc= '$tDesc' WHERE u_mail = '$uMail' AND u_IMEI = '$uIMEI'"); mysql_close(); ?>
也许你应该用mysql_real_escape_string()
来逃避你的字符串
$uMail = mysql_real_escape_string($_POST['u_mail']);
$uIMEI = mysql_real_escape_string($_POST['u_IMEI']);
$uName = mysql_real_escape_string($_POST['u_name']);
$uPass = mysql_real_escape_string($_POST['u_pass']);
$tName = mysql_real_escape_string($_POST['t_names']);
$tIMEI = mysql_real_escape_string($_POST['t_IMEIs']);
$tDesc = mysql_real_escape_string($_POST['t_desc']);
mysql_query("UPDATE user_master SET t_names='$tName',t_IMEIs='$tIMEI',t_desc= '$tDesc' WHERE u_mail = '$uMail' AND u_IMEI = '$uIMEI'");
并确保$uMail
和$uIMEI
设置正确
上一篇: Updating mysql database through php with HTTP POST methods
下一篇: connect access denied error when trying to access remote database