[GLLUG] Retrieving a row from mysql

Marshal Newrock marshal at simons-rock.edu
Mon Feb 16 16:35:26 EST 2004

On Mon, 16 Feb 2004, Seth Bembeneck wrote:

> I have a query like this in php:
> $name = 'Seth';
> $accnum= 12;
> $tablename = 'players'
> query = mysql_query("SELECT * FROM $tablename WHERE name= '$name' AND
> accountnum= $accnum");
> When I run this, I get a message saying that I have an error in my
> syntext and to check the manuel for my version of MySql for the right
> syntext to use near " at line 1.

I recommend doing something like:
$query = "SELECT ...";
echo "query: $query<br>\n";
$result = mysql_query($query);

That will let you work directly with the query, rather than assuming
everything is correct.  And then you can copy the query directly into
mysql, adjust as needed.

If everything looks correct, do a php_info(); and see if magic_quotes_gpc
is set or not.  If not, you'll need to addslashes($query) for it to be

CAUTION: Product will be hot after heating

More information about the linux-user mailing list