Jump to content

Sql Problem...


xyn

Recommended Posts

Hey guys,
I've used the $_GET to delete an individual message, and Obviously in a members are if the user was to change the ?id=[color=red]1[/color] to [color=red]2,3 or 4[/color] it would also delete them, so i've decided to prevent this by making sure the id is in the members Inbox.

My problem is I've decided to automatically send a CFA to my zone moderators + to tell them a member has deliberatly eddited the URL and needs to be warned. but I'm getting the following errors:

[sup]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 'from, msg, date, time, ip) VALUES ('Zroxx','xyn. is tr' at line 1[/sup]

My code is:
[code=php:0]include "db.php";
$ip = getenv('REMOTE_ADDR');
$bad_user = $_SESSION['user']['user'];
$db = mysql_connect("localhost", $login, $pwd) or die(mysql_error());
mysql_select_db("zroxxco_members") or die(mysql_error());
$bansql = "INSERT INTO cfa (from, msg, date, time, ip) VALUES ('<font color=orange>Zroxx</font>','$bad_user. is trying to delete other peoples posts.','$date','$time','No Information')";
mysql_query($bansql, $db) or die(mysql_error());[/code]
Link to comment
Share on other sites

FROM is a reserved word in MySQL.  You should not use reserved words as fieldnames.  Right solution is to change the from to something else (fromx for example); sloppy solution is to enclose reserved words in backticks .... `from`
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.