dflow Posted August 24, 2011 Share Posted August 24, 2011 i have the following processing action for a form query DUMP output is: string(202) "INSERT INTO contactPO (Status, DateReceived, CustomerEmail, LastName, FirstName, PropertyID, fromdate, todate, nop) VALUES ('1', '24-08-2011', 'r', 'r', 'rrrrr', '12121', '27-10-2011', '30-10-2011','4')" but nothing is inserted <?php $con = mysql_connect("localhost","international",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'utf8'"); mysql_select_db("international", $con); // check which button was clicked // perform calculation if ($_POST['send']) { $query = sprintf("INSERT INTO contactPO (Status, DateReceived, CustomerEmail, LastName, FirstName, PropertyID, fromdate, todate, nop) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s')", mysql_real_escape_string($_POST['Status']), mysql_real_escape_string($_POST['DateReceived']), mysql_real_escape_string($_POST['CustomerEmail']), mysql_real_escape_string($_POST['LastName']), mysql_real_escape_string($_POST['FirstName']), mysql_real_escape_string($_POST['PropertyID']), mysql_real_escape_string($_POST['fromdate']), mysql_real_escape_string($_POST['todate']), mysql_real_escape_string($_POST['nop'])); var_dump($query ); //$url_success = "search-index.php?RID=".$_POST['RequestID'].""; $url_success = "search-index.php"; echo("<meta http-equiv = refresh content=6;url=".$url_success.">"); exit; mysql_close($con); } ?> Link to comment https://forums.phpfreaks.com/topic/245598-nothing-inserted-no-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 24, 2011 Share Posted August 24, 2011 You forgot to execute the query. Link to comment https://forums.phpfreaks.com/topic/245598-nothing-inserted-no-error/#findComment-1261417 Share on other sites More sharing options...
Psycho Posted August 24, 2011 Share Posted August 24, 2011 Also, why are you running mysql_real_escape_string() on values that you should be validating as numeric or date values? mysql_real_escape_string() is for "string" values as its name implies. Link to comment https://forums.phpfreaks.com/topic/245598-nothing-inserted-no-error/#findComment-1261433 Share on other sites More sharing options...
dflow Posted August 24, 2011 Author Share Posted August 24, 2011 Quote You forgot to execute the query. //adding did not help mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/245598-nothing-inserted-no-error/#findComment-1261526 Share on other sites More sharing options...
Psycho Posted August 24, 2011 Share Posted August 24, 2011 Well add it so it will show any errors if it fails! mysql_query($query) or die("$query<br>Error: " . mysql_error()); Link to comment https://forums.phpfreaks.com/topic/245598-nothing-inserted-no-error/#findComment-1261535 Share on other sites More sharing options...
dflow Posted August 24, 2011 Author Share Posted August 24, 2011 Quote Well add it so it will show any errors if it fails! mysql_query($query) or die("$query<br>Error: " . mysql_error()); output: Error: No database selected strange but there isn't an error connecting on the Link to comment https://forums.phpfreaks.com/topic/245598-nothing-inserted-no-error/#findComment-1261541 Share on other sites More sharing options...
dflow Posted August 24, 2011 Author Share Posted August 24, 2011 k thanks solved problem on localhost but strange that i didnt get the connection error before Link to comment https://forums.phpfreaks.com/topic/245598-nothing-inserted-no-error/#findComment-1261543 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.