Jump to content

[SOLVED] Insert Not Working


jfs0479

Recommended Posts

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
Share on other sites

<?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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.