Jump to content

[SOLVED] INSERT INTO, HELP!


brophi

Recommended Posts

Server version: 5.0.45-community-nt

 

The brocken code:

$to = mysql_real_escape_string($_POST['to']);
$text = mysql_real_escape_string($_POST['text']);
$from = mysql_real_escape_string($_SESSION["sessioname"]);
mysql_query("INSERT INTO mail (to, from, text, datetime) VALUES ('$to', '$from', '$text', NULL)")

 

The mysql_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 'to, from, text, datetime VALUES ('Brophi', 'Brophi', 'Test', NULL)' at line 1

 

The 'mail' table:

CREATE TABLE `mail` (\n  `to` text collate latin1_general_ci NOT NULL,\n  `from` text collate latin1_general_ci NOT NULL,\n  `text` text collate latin1_general_ci NOT NULL,\n  `datetime` timestamp NOT NULL default '0000-00-00 00:00:00' on update CURRENT_TIMESTAMP\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci

 

Can someone please help, I keep getting this error, although i havnt ttried much cause i dont know much about mysql syntax, im sorry if this post is hard to read, but please help

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.