Updating mysql database through php with HTTP POST methods
It executes on application perfectly I double checked it. It sends all parameters properly and the problem is in php script it doesn't execute the query (update,delete) it execute the insert query properly. The php script works perfect with html form but I don't know where the problem is.
Here is my php script:
$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(); ?>
maybe you should escape your strings with 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'");
and make sure $uMail
and $uIMEI
are set correctly
上一篇: 一个MySQL数据库和多表