Page 1 of 1

What's wrong with this?

Posted: Wed May 26, 2004 5:04 am
by mjseaden

Code: Select all

SELECT PropertyID FROM Bookmarks WHERE (PropertyID=4 && Username='XXXX')
For some reason this reports the error

Code: Select all

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3
I cannot spot the error in this query - what is wrong?

Many thanks

Mark

Posted: Wed May 26, 2004 6:12 am
by JayBird
echo the query before you execute it to make sure it contains all the information you think it does

Mark

Posted: Wed May 26, 2004 6:34 am
by mjseaden
Hi Bech

The output I've pasted onto my original message is copied from echoed output

Many thanks

Mark

Posted: Wed May 26, 2004 6:38 am
by magicrobotmonkey
lose the "( )" ?

Posted: Wed May 26, 2004 6:44 am
by JayBird
Brackets are perfectly correct syntax.

Can you show a bit of the code.

Mark

Posted: Wed May 26, 2004 6:46 am
by mjseaden
Well, you're right, in fact I copied the echoed statement and replaced the username with 'XXXXX' instead. Otherwise, you have my personal guarantee that it is indeed the echoed statement.

Posted: Wed May 26, 2004 6:49 am
by JayBird
hehehe, i edited my post before you replied.

Syntaxly (is that a word? It is now!), your statement is correct, so there must be some other problem. Post your code and ill take a look

Mark

Posted: Wed May 26, 2004 6:49 am
by mjseaden

Code: Select all

$query2 = 'SELECT PropertyID FROM Bookmarks WHERE PropertyID='.$myarray[4].' && Username='''.$_SESSION['reg_user'].'''';
echo $query2;
$result2 = mysql_query( $query2 );

if(!$result2)
{
   do_html_header( 'Database Error', FALSE, 0 );
   do_html_message('Error - Could not perform MySQL query - '.mysql_error());
   do_html_footer();
   exit();
}
Many thanks
Mark

Posted: Wed May 26, 2004 6:54 am
by JayBird
so what happened when you took the brackets out, what error then?

Posted: Wed May 26, 2004 7:03 am
by magicrobotmonkey
Are you sure you have all caps right in your column names?

Posted: Wed May 26, 2004 7:05 am
by mjseaden
Hi

I'm looking at the wrong error - I'm getting a problem with another query. Sorry for being a dufus, but often it's the simpler problems that can leave you scratching your head the most.

Thanks for the help - Mark.