fxr Posted March 31, 2008 Share Posted March 31, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/98793-unexpected-t_constant_encapsed_string-error/ Share on other sites More sharing options...
MadTechie Posted March 31, 2008 Share Posted March 31, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/98793-unexpected-t_constant_encapsed_string-error/#findComment-505531 Share on other sites More sharing options...
fxr Posted March 31, 2008 Author Share Posted March 31, 2008 sorry fella, i meant the INSERT statement *editted now* thanks for lookin tho.. think i just need a little break from it.. hopefully a lightbulb ll go off when i come back to it. Quote Link to comment https://forums.phpfreaks.com/topic/98793-unexpected-t_constant_encapsed_string-error/#findComment-505538 Share on other sites More sharing options...
MadTechie Posted March 31, 2008 Share Posted March 31, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/98793-unexpected-t_constant_encapsed_string-error/#findComment-505544 Share on other sites More sharing options...
fxr Posted March 31, 2008 Author Share Posted March 31, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/98793-unexpected-t_constant_encapsed_string-error/#findComment-505552 Share on other sites More sharing options...
MadTechie Posted March 31, 2008 Share Posted March 31, 2008 change $diff = $row['diff'] + $diff'; to $diff = $row['diff'] + $diff; note the ' at the end lol i, just read the whole post well done solved i believe Quote Link to comment https://forums.phpfreaks.com/topic/98793-unexpected-t_constant_encapsed_string-error/#findComment-505573 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.