GB_001 Posted January 17, 2008 Share Posted January 17, 2008 Error: 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 User1='[email protected]' And User2='[email protected]'' at line 1 <?php session_start(); @mysql_connect("mysql.x10hosting.com", "gb_GB", "**********************") or die(mysql_error()); @mysql_select_db("gb_USERInfo") or die(mysql_error()); $Friend=$_GET['F']; $User=$_SESSION['email']; $result = "UPDATE Messages SET Requester='$User' AND Requestee='$Friend' WHERE User1='$User' AND User2='$Friend' OR WHERE User1='$Friend' AND User2='$User'"; $result2 = mysql_query("SELECT * FROM Messages WHERE User1='$User' AND User2='$Friend'"); $result3 = mysql_query("SELECT * FROM Messages WHERE User2='$Friend' AND User1='$User'"); $Num=mysql_num_rows($result2); $Num1=mysql_num_rows($result3); if($Num==0||$Num1==0){ $query = "INSERT INTO Messages (User1, User2) VALUES('$User', '$Friend')"; mysql_query($query) or die(mysql_error()); mysql_query($result) or die(mysql_error()); }else{ mysql_query($result) or die(mysql_error()); } include("CHAJAX.php?F=$Friend&U=$User"); ?> Link to comment https://forums.phpfreaks.com/topic/86415-weird-mysql-error/ Share on other sites More sharing options...
vbnullchar Posted January 17, 2008 Share Posted January 17, 2008 This line $result = "UPDATE Messages SET Requester='$User' AND Requestee='$Friend' WHERE User1='$User' AND User2='$Friend' OR WHERE User1='$Friend' AND User2='$User'"; should be... $result = "UPDATE Messages SET Requester='$User', Requestee='$Friend' WHERE (User1='$User' AND User2='$Friend') OR (User1='$Friend' AND User2='$User') "; Link to comment https://forums.phpfreaks.com/topic/86415-weird-mysql-error/#findComment-441593 Share on other sites More sharing options...
GB_001 Posted January 17, 2008 Author Share Posted January 17, 2008 Thankyou. =) Link to comment https://forums.phpfreaks.com/topic/86415-weird-mysql-error/#findComment-441594 Share on other sites More sharing options...
GB_001 Posted January 17, 2008 Author Share Posted January 17, 2008 Is it possibly you can help me with one more error though? I keep getting this error in the include() part of my code: Warning: include([email protected]&[email protected]) [function.include]: failed to open stream: No such file or directory in /home/gb/public_html/waiting.php on line 28 Link to comment https://forums.phpfreaks.com/topic/86415-weird-mysql-error/#findComment-441597 Share on other sites More sharing options...
Nhoj Posted January 17, 2008 Share Posted January 17, 2008 Remove the ?F=$Friend&U=$User from include("CHAJAX.php?F=$Friend&U=$User"); And try it... You can't include a file like a url that way... You can only include it via it's file name, meaning no extra parameters. Link to comment https://forums.phpfreaks.com/topic/86415-weird-mysql-error/#findComment-441726 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.