MySQL Forums
Forum List  »  Perl

Re: T_STRING
Posted by: Randy Clamons
Date: November 13, 2008 02:07PM

This is more of a PHP problem than a MySql problem. The T_STRING message means you have an unquoted literal value somewhere in your code. I don't really see it this snippet of code, but there is one suspect statement (which appears to be line 19):

$query = "select * from users where username=’$username’ & password=’$password’";

First, I don't think you're going to get the results you want from the statement. The & operate perform a bitwise AND. What you probably meant to do is:

$query = “select * from users where username=’$username’ AND password=’$password’”;

Ok, now I'm guessing you're using a Mac to create your scripts--that's usually how I end up with this error. At the top of your script, where you assign $dbhost, $dbname, etc., you have the correct quotes. But the on the line above uses different kinds of quote characters (which I can't really reproduce with my Windows keyboard) that are the equivalent of open and close quote. Notice they don't look like the ones you used for $dbhost. That's where this error message comes from.

Once you fix that, you're going to have more errors popup--for pretty much the same reason. Your script also has the wrong kind of single quotes--they look more like apostrophes. While they are roughly the same for humans to read, they are completely different for computers. So, where you have ’ use ' instead. Now this line will look like this:

$query = “select * from users where username='$username' AND password='$password"’”;

Even if you get the program to compile without making these changes and successfully pass this to mySql, it will fail 'cause mySql doesn't understand those characters either. It's gonna think ’$username’ is a column name.

Ok, Dan. That's your PHP lesson for the day.

Options: ReplyQuote


Subject
Written By
Posted
November 13, 2008 11:58AM
Re: T_STRING
November 13, 2008 02:07PM
November 14, 2008 05:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.