Why do i keep getting this kind of error message?
INSERT 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 '(usrip, user, status) VALUES ('', '', '')' at line 1
Here is my php code
PHP Code:$ipaddr=$_SERVER['REMOTE_ADDR'];
$mycnct=mysql_connect("abc","xyz","pass");
if($mycnct){
if(mysql_select_db("mydb",$mycnct)){
$grpid=$_GET['gid'];
$thisuser=$_GET['usersid'];
$mylockr=$_GET['accessid'];
$grpmode=$_GET['gmode'];
$grplock=$_GET['islock'];
$isonline="online";
$groupFullName="GRP_".$grpid."_users";
if(mysql_query("INSERT INTO $groupFullName ('usrip', 'user', 'status') VALUES ('$ipaddr', '$thisuser', '$isonline')")){
echo "Success";
}else{
echo "INSERT ERROR:".mysql_error();
}
}
}
/*Link with variables:
mysite.com/testing.php?gid=bluebell&usersid=henry&gmode=join&islock=off&accessid=abc
*/
Before running the above code, this is how the table was created:
PHP Code:if(mysql_query("CREATE TABLE $groupFullName(SL int(11) NOT NULL AUTO_INCREMENT, usrip text NOT NULL, user varbinary(35) NOT NULL, status varchar(15) NOT NULL, getreq varchar(15) NOT NULL, PRIMARY KEY (SL))")){
echo "DONE";
}else{
echo "Fail";
}




Reply With Quote