jfs0479 Posted July 26, 2007 Share Posted July 26, 2007 Hi All, I am quite new to php but can understand most things..however this script has really stomped me. I am simply trying to insert this data into the database and all the names and everthing is correct. It has worked fine for me before but i am completly unsure why it is not working now. Heres The script. <? session_start(); session_checker(); function session_checker(){ if(!session_is_registered('memberid')){ include 'index.php'; exit(); } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <?php $departing = $_POST["departing"]; $departingicao = $_POST["departingicao"]; $arriving = $_POST["arriving"]; $arrivingicao = $_POST["arrivingicao"]; $pax = $_POST["pax"]; $aircraft = $_POST["aircraft"]; $reg = $_POST["reg"]; $fuelused = $_POST["fuelused"]; $id = $_POST["id"]; $route = $_POST["route"]; $eta = $_POST["eta"]; $date = date('d/m/y'); $memberid = $_SESSION['memberid']; include("db.php"); $result = mysql_query( "insert into arab_flights (departing, departingicao, arriving, arrivingicao, pax, aircraft, reg, fuelused, id, route, eta, date, memberid) values ('$departing', '$departingicao', '$arriving', '$arrivingicao', '$pax', '$aircraft', '$reg', '$fuelused', '$id', '$route', '$eta', '$date', '$memberid')" ); if ($result) { print <<<EOT EOT; } else { print "We are currently having connection problems."; } mysql_close(); ?> </body> </html> The error i get is the one i have set which is the We are Currently having connection problems however all of the database details are correct and connections through db.php on other pages is ok and displaying it ok. Thank for your help James Link to comment https://forums.phpfreaks.com/topic/61819-solved-insert-not-working/ Share on other sites More sharing options...
btherl Posted July 26, 2007 Share Posted July 26, 2007 Add this line under "We are currently having connection problems": print "The error is: " . mysql_error(); Link to comment https://forums.phpfreaks.com/topic/61819-solved-insert-not-working/#findComment-307840 Share on other sites More sharing options...
redarrow Posted July 26, 2007 Share Posted July 26, 2007 please i cracked up at the heredoc sorry write you need to add addslashes or mysql_reel_esape_string(); Link to comment https://forums.phpfreaks.com/topic/61819-solved-insert-not-working/#findComment-307844 Share on other sites More sharing options...
redarrow Posted July 26, 2007 Share Posted July 26, 2007 <?php session_start(); session_checker(); // This made my day lol not needed is it really but it will work. function session_checker(){ if(!$_SESSION['memberid']){ include 'index.php'; exit(); } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <?php $departing = addslashes($_POST["departing"]); $departingicao = addslashes($_POST["departingicao"]); $arriving = addslashes($_POST["arriving"]); $arrivingicao = addslashes($_POST["arrivingicao"]); $pax = addslashes($_POST["pax"]); $aircraft = addslashes($_POST["aircraft"]); $reg = addslashes($_POST["reg"]); $fuelused = addslashes($_POST["fuelused"]); $id = addslashes($_POST["id"]); $route = addslashes($_POST["route"]); $eta = addslashes($_POST["eta"]); $date = date("d/m/y"); $memberid = $_SESSION['memberid']; $memberid=addslashes($_POST['memberid']); include("db.php"); $query = "INSERT INTO `arab_flights`(departing, departingicao, arriving, arrivingicao, pax, aircraft, reg, fuelused, id, route, eta, date, memberid) values ('$departing', '$departingicao', '$arriving', '$arrivingicao', '$pax', '$aircraft', '$reg', '$fuelused', '$id', '$route', '$eta', '$date', '$memberid')"; $result=mysql_query($query)or die("mysql_error()"); if (mysql_affected_rows($result)){ echo " database was updated"; }else{ echo " please contact the admin i think my database has blown up"; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/61819-solved-insert-not-working/#findComment-307847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.