Page 1 of 1

Parse error "unexpected T_STRING "

Posted: Mon Jul 02, 2007 4:29 pm
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!

Posted: Mon Jul 02, 2007 5:31 pm
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.

Posted: Mon Jul 02, 2007 6:49 pm
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.

Posted: Mon Jul 02, 2007 6:52 pm
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:

Posted: Mon Jul 02, 2007 6:54 pm
by Benjamin
Yeah I didn't think of that. I figured he was trying to use it in there as a PHP function.