Forum Moderators: coopster

Message Too Old, No Replies

mysql query problems

         

Sarah Atkinson

5:29 pm on Jun 27, 2005 (gmt 0)

10+ Year Member




Does anyone see anything wrong with this. it keeps saying there is an error but i'm not seeing it.(unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING )

$sqluser = "INSERT INTO sg_registration SET
fname='$_SESSION['fname']',
lname='$_SESSION['lname']',
email= '$_SESSION['email']',
birth='$_SESSION['month']',
sex= '$_SESSION['gender']',
phone='$_SESSION['phone']',
street='$_SESSION['street']',
city= '$_SESSION['city']',
state= '$_SESSION['state']',
zip= '$_SESSION['zip']',
ename= '$_SESSION['ename']',
ephone='$_SESSION['ephone']',
pname='$_SESSION['pname']',
pphone= '$_SESSION['pphone']',
iname= '$_SESSION['iname']',
iphone= '$_SESSION['iphone']',
medications= '$_SESSION['med']',
allergies='$_SESSION['allergies']',
shirtsize='$_SESSION['shirtsize']',";

jatar_k

5:36 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you probably need to surround your vars with braces

$_SESSION['fname']

should be

{$_SESSION['fname']}

for all vars

Sarah Atkinson

5:49 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



now i get this error
Error adding menu: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' lname=, email= , birth=, sex= , phone=, street=, city= ,

jatar_k

5:57 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't do them that way when I use array values I always cat them together, such as

$sqluser = "INSERT INTO sg_registration SET fname='" . $_SESSION['fname'] . "', lname='" . $_SESSION['lname'] . "'";

etc....

then I don't have to use braces, I alsi then use single quotes instead of double as nothing in the strings needs to be parsed.

That error looks like the session values aren'y ending up in you query string

echo your full query string to the screen to see if it is being built properly before you use mysql_query

moltar

6:04 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You have an extra comma after shirtsize. MySQL does not like extra, trailing commas.

Sarah Atkinson

6:05 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



thanks that worked