Parse error "unexpected T_STRING "

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nfw24
Forum Newbie
Posts: 5
Joined: Mon Jul 02, 2007 4:20 pm

Parse error "unexpected T_STRING "

Post by nfw24 »

Hi everyone,

I am a newbie at programming so I would appreciate any help I can get! I'm sure its very simple but I don't have enough knowledge to fix it:

For some reason, I get an unexpected T_STRING error for the following code: (I am trying to extract information from a database)

$sql = “SELECT user_name FROM Valid_User
WHERE user_name = ‘$user_name’
AND password = md5(‘$user_password’)”;

Does anyone know what is wrong?
Thanks!
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

First, you must show us exactly what the full error message was and then the code on the exact line number that was in the error message.

What you showed us just the assignment of a string that should be an SQL statement. That's almost surely not the line that contains the error. Oh, unless it's actually broken up into several lines, as you have shown. That would give you an error, because you can't break a PHP string with line breaks. You would need to concatenate several strings or do it all on one line.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Did you write that in Microsoft word or something? Your quotes are not the correct type.

Secondly, you cannot execute a php function inside of a string.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

astions wrote:Did you write that in Microsoft word or something? Your quotes are not the correct type.

Secondly, you cannot execute a php function inside of a string.
md5 is also a mysql function :wink:
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Yeah I didn't think of that. I figured he was trying to use it in there as a PHP function.
Post Reply