Jump to content

[SOLVED] this code drives me crazy "inserting values to the mysql" need help !


samoi

Recommended Posts

I try to let this script work, but it doesn't what's its problem?

 


<?php
error_reporting(E_ALL & E_NOTICE);

require_once('config.php');




if(!$_POST)
{
header('Location: insert.php');
}

else
{

$event = clean($_POST['event']);
$date = clean($_POST['date']);
$insert = "INSERT INTO table (event, date) VALUES ('$event', '$date')";
$insertSQL = mysql_query($insert);

echo 'The new event has been submitted <br>
 hit <a href="index.php"> this link </a> to view them';
}
function clean($str)
{
return mysql_escape_string($str);
}


?>

You don't do any error checking on your query results.  Check your query by changing the line to read:

 

$insertSQL = mysql_query($insert) or die(mysql_error());

 

You should run error checks on every query.

You don't do any error checking on your query results.  Check your query by changing the line to read:

 

$insertSQL = mysql_query($insert) or die(mysql_error());

 

You should run error checks on every query.

 

I've got


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 'table (event, date) VALUES ('ENG 102 delever', '12/05/2008')' at line 1

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.