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
[email protected]
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('[email protected]','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
https://forums.phpfreaks.com/topic/273810-cant-figure-out-simple-php-error/
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.