Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
mjseaden
Forum Contributor
Posts: 458 Joined: Wed Mar 17, 2004 5:49 am
Post
by mjseaden » Wed May 26, 2004 5:04 am
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
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed May 26, 2004 6:12 am
echo the query before you execute it to make sure it contains all the information you think it does
Mark
mjseaden
Forum Contributor
Posts: 458 Joined: Wed Mar 17, 2004 5:49 am
Post
by mjseaden » Wed May 26, 2004 6:34 am
Hi Bech
The output I've pasted onto my original message is copied from echoed output
Many thanks
Mark
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed May 26, 2004 6:44 am
Brackets are perfectly correct syntax.
Can you show a bit of the code.
Mark
mjseaden
Forum Contributor
Posts: 458 Joined: Wed Mar 17, 2004 5:49 am
Post
by mjseaden » Wed May 26, 2004 6:46 am
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.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed May 26, 2004 6:49 am
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
Last edited by
JayBird on Wed May 26, 2004 6:50 am, edited 1 time in total.
mjseaden
Forum Contributor
Posts: 458 Joined: Wed Mar 17, 2004 5:49 am
Post
by mjseaden » Wed May 26, 2004 6:49 am
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
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed May 26, 2004 6:54 am
so what happened when you took the brackets out, what error then?
magicrobotmonkey
Forum Regular
Posts: 888 Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA
Post
by magicrobotmonkey » Wed May 26, 2004 7:03 am
Are you sure you have all caps right in your column names?
mjseaden
Forum Contributor
Posts: 458 Joined: Wed Mar 17, 2004 5:49 am
Post
by mjseaden » Wed May 26, 2004 7:05 am
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.