Jump to content

Recommended Posts

hi can anyone help with this i have fiddled with it for hours , its the INSERT statement its having issues with, i believe, i have tried a variety of quotes around my variables but to no avail; i have tried google, but i cant seem to grasp a general feeling of what the error msg is trying to tell me, so its no help..

 

mysql> describe calcs;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| week  | smallint(6) | YES  |     | NULL    |       | 
| day   | tinyint(2)  | YES  |     | NULL    |       | 
| low   | datetime    | YES  |     | NULL    |       | 
| high  | datetime    | YES  |     | NULL    |       | 
| diff  | smallint(3) | YES  |     | NULL    |       | 
+-------+-------------+------+-----+---------+-------+

// this is a summarised segment of my code in which i believe the error is contained..

list($time,$quote,$week,$day) = split(",",$_REQUEST["n"]); # n=2008-03-17%2005:30:00,15000,1,1 ; 

$con = mysql_connect("localhost","fxr","");
if (!$con){
die('Could not connect: ' . mysql_error());
} 

mysql_select_db("pam_test", $con); 
$sql="INSERT INTO calcs (week, day, low, high, diff) VALUES('$week', '$day', '$time', '$time', '0') ";
if (!mysql_query($sql,$con)){
die("Error: " . mysql_error());
						}


// error --> PHP Parse error:  syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/htdocs/pam/savequote2.php on line ### [which is the select statement]

 

can anyone bail a noob out please?

i don't see a select statment!

if you mean the selectDB

you could try this

mysql_select_db("pam_test", $con) or die("database doesn't exist"); 

 

but it looks ok to me

 

check you are not missing a } anywhere also quote cause this problem

 

if you put the whole page up i could probably spot it,

 

Okay last thing to check/try

//Add this
$week = addslashes($week);
$day= addslashes($day);
$time= addslashes($time);
$sql="INSERT INTO calcs (week, day, low, high, diff) VALUES('$week', '$day', '$time', '$time', '0') ";

 

infact you should

list($time,$quote,$week,$day) = split(",",urldecode($_REQUEST["n"])); # n=2008-03-17%2005:30:00,15000,1,1 ;

to remove the  %20

no good fella, ll add a link to the entire code for completeness, i didnt add it as m still at the early stages of bug checking and m a little shy off exposing my noobishness ;p

 

as you can probs see from the code, m not completely sure about when to close db connections.. do i need to open the database for each query, or insert/update?

 

entire code here --> http://rafb.net/p/E3rfGu52.html

 

Now... just pasting it means I HAVE FOUND MY ISSUE . i had an errant quote a few lines above, sorry to waste everyones time ;s  its been a long morning ;p 

 

so i can mark THIS ISSUE AS RESOLVED. unless someone cares to point out the myriad of other issues probably in there ;p

 

ll get back to my bug checking anyway..

 

thanks MadTechie..  i couldve been looking for answer in the wrong place for a lot longer, if it hadnt been for your kind intervention.

 

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.