I've got a VERY simply script with which I wish to add some data to a DB. As far as I can see, it should work - any ideas why it's not?!
<?php
$connection = mysql_connect ("myhost", "ed", "mypassword");
$date = date("F j, Y");
$confirmednewtoadd = $_POST['confirmednewtoadd'];
$table = "xanews";
$addToDB = "Insert into $table(date, newsitem) values('$date', '$confirmnewtoadd')";
mysql_query($addToDB, $connection);
?>
Thanks,
Ed Ludlow
Adding to SQL DB
Moderator: General Moderators
Add some debugging/error checking ...
Code: Select all
<?php
error_reporting(E_ALL);
$connection = mysql_connect ('myhost', 'ed', 'mypassword') or die(mysql_error());
$date = date('F j, Y');
$confirmednewtoadd = $_POST['confirmednewtoadd'];
$table = "xanews";
$addToDB = "Insert into $table(date, newsitem) values('$date', '$confirmnewtoadd')";
echo $addToDB; //to check it's what you expect it to be
mysql_query($addToDB, $connection) or die(mysql_error());
?>