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); } ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 24, 2011 Share Posted August 24, 2011 You forgot to execute the query. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
dflow Posted August 24, 2011 Author Share Posted August 24, 2011 You forgot to execute the query. //adding did not help mysql_query($query); Quote Link to comment 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()); Quote Link to comment Share on other sites More sharing options...
dflow Posted August 24, 2011 Author 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()); output: Error: No database selected strange but there isn't an error connecting on the Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.