Hello,
Can anyone please help me with this error: [10-Feb-2009 13:26:08] PHP Parse error: syntax error, unexpected T_VARIABLE.
My code is below:
############
$sql = "INSERT INTO `database_test`.`Users` (`f_name`,`l_name`,`address`,`address_two`,`city`,`state`,`zip`,`phone`,`email`,`user_name`,`password`) VALUES ('$_POST[fName]','$_POST[lName]','$_POST[addressOne]','$_POST[addressTwo]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[phone]','$_POST[email]','$_POST[userName]','$_POST[password]';";
Thanks!
PHP Parse error: unexpected T_VARIABLE
Moderator: General Moderators
-
OU_Student
- Forum Newbie
- Posts: 7
- Joined: Tue Feb 10, 2009 5:30 pm
Re: PHP Parse error: unexpected T_VARIABLE
No errors there, except the missing ) at the end of the query.
Did you forget a semicolon on the line above?
Did you forget a semicolon on the line above?
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: PHP Parse error: unexpected T_VARIABLE
Can't put array indices inside double quotes without enclosing them in curly braces. Must enclose string array indices with quotes. Missing closing bracket in query. Unnecessary semi-colon in query.
-
OU_Student
- Forum Newbie
- Posts: 7
- Joined: Tue Feb 10, 2009 5:30 pm
Re: PHP Parse error: unexpected T_VARIABLE
Thank you, works now =)
Re: PHP Parse error: unexpected T_VARIABLE
Umm, no.jayshields wrote:Can't put array indices inside double quotes without enclosing them in curly braces. Must enclose string array indices with quotes.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: PHP Parse error: unexpected T_VARIABLE
Huh?
That was two seperate statements I made, sorry.
To elaborate; I meant:
Can't put array indices inside double quotes without enclosing them in curly braces.
Must enclose string array indices with quotes.
That was two seperate statements I made, sorry.
To elaborate; I meant:
Can't put array indices inside double quotes without enclosing them in curly braces.
Code: Select all
$sql = "blah blah '$_POST['addressOne']'"; //wrong
$sql = "blah blah '{$_POST['addressOne']}'"; //rightCode: Select all
$sql = "blah blah '{$_POST[addressOne]}'"; //wrong
$sql = "blah blah '{$_POST['addressOne']}'"; //right