Jump to content

Can't Figure Out Simple PHP Error


Clinton

Recommended Posts

I seriously can't figure this out.

 

Code:

<?php
session_start();
if(!isset($_SESSION['me']))
{  header("location:index.php");  }
$action=$_POST["action"];
$from=$_POST["name"];
$message=$_POST["message"];
$when=$_POST["when"];
echo $action . "<p>";
echo $from . "<p>";
echo $message . "<p>";
echo $when . "<p>";
if ($action == "add") { 
mysql_connect("localhost", "name", "name") or die(mysql_error());
mysql_select_db("name") or die(mysql_error());
mysql_query("INSERT INTO tweet(from,when,message)VALUES('$from','$when','$message')") or die(mysql_error());
header("location:home.php");
}  ?>

 

Produces:

add
blah@gmail.com
Mary had a little lamb its fleece was white as snow.
2013-01-29 19:13:31
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,when,message)VALUES('blah@gmail.com','2013-01-29 19:13:31','Mary ha' at line 1

 

I'm beating my head. I can't fricken figure it out. Where's the error? Everything it's echoing is exactly what I'm putting into the system so the error isn't there. But where might it be?

 

Any help appreciated. Thank you.

 

CJA

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.