would this work??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

would this work??

Post by ericburnard »

just woundering if this would work to give you a link like this ---- http://eric.madashatters.com/readmail.p ... oop&mail=1


$username = mysql_real_escape_string($_GET['user']);
$mail = mysql_real_escape_string($_GET['mail']);
$query = "SELECT * FROM pm WHERE user='$username' AND WHERE id='$mail'";
$result = mysql_query($query) or die(mysql_error());

thanks
Eric
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You have a syntax error.. As you notice yourself when you visit the page:

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 'WHERE id='0'' at line 1
Should be WHERE id='0' , thus in a string becomes "WHERE id='0'"
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

Post by ericburnard »

i can see that it is ment to be WHERE id='0' but have played around with the code but it dosnt want to work :s

what am i doing wrong :S

Eric

ps. sorry for taking up your time tonight timvw i really apprechiate it (even thought i cant spell it :P)
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you have two instances of "where" in your query.

you only need one for your where clause:

Code: Select all

$query = "SELECT * FROM pm WHERE user='$username' AND  id='$mail'";
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

MySQL cannot handle multiple WHERE keywords, so once it sees the second WHERE it bails out. That's why it says the error is over there. Learn how to interpret error messages: it does the body good.
User avatar
ericburnard
Forum Contributor
Posts: 104
Joined: Wed Jun 15, 2005 5:11 pm
Location: Chesterfield, UK

Post by ericburnard »

Is that all it is :D lol
Thank you very much :D

Eric
Post Reply