Why is this a parse error?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bobthebobert
Forum Commoner
Posts: 25
Joined: Sat Feb 15, 2003 5:56 pm

Why is this a parse error?

Post by bobthebobert »

Code: Select all

<?php

$result = mysql_query("SELECT kingname FROM info WHERE (rulername="bob")");


?>
Where is the parse error, I can't find it -.-
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You've got double quotes within a double quoted string and you haven't escaped them. This would work:

Code: Select all

$result = mysql_query("SELECT kingname FROM info WHERE (rulername="bob")");
but since this is an SQL statement you can and should use single quotes instead:

Code: Select all

$result = mysql_query("SELECT kingname FROM info WHERE (rulername='bob')");
Mac
bobthebobert
Forum Commoner
Posts: 25
Joined: Sat Feb 15, 2003 5:56 pm

Post by bobthebobert »

Grrr, thankyou, i figured it was something stupid like that =/

I will eventually figure it out though!
Post Reply