Jump to content

Weird MySQL Error.


GB_001

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.