Hi All,
I am stumped on this one. I have a page that takes 6 items and inserts them into my table. When I submit the data via the page I get duplicate records. But if I take the same MySQL code and run it manually, I get one record.
I setup unique indexes, which give me errors from the php page.
Here is my code:
session_start();
// connect to MySQL
include( 'MySQLconn.php' );
// Select the DB
$db_selected = mysql_select_db( "db" );
if ( !$db_selected ) {
die( mysql_error() );
}
//set EST
date_default_timezone_set('America/New_York');
$Datetime = date('Y\-m\-d H:i:s');
$sql = "INSERT INTO vcevents";
$sql .= " (Title, URL, Source, Thumb, EmbedCode, Enabled, DateAdded)";
$sql .= " VALUES ('" . addslashes( $_POST['Title'] ) . "', '" . addslashes( $_POST['URL'] )
. "', '" . addslashes( $_POST['Source'] ) . "', '" . addslashes( $_POST['Thumb'] )
. "', '" . addslashes( $_POST['EmbedCode'] ) . "', " . $_POST['Enabled'] . ", '" . $Datetime . "')";
echo '$sql = ' . $sql . '<br>';
$result = mysql_query( $sql );
if ( !mysql_query( $sql ) ) {
echo 'There was a problem inserting the record.<br><br>' . mysql_errno() . '<br>'
. mysql_error() . '<br><br>';
die();
}
//close the conn
mysql_close($conn);
I have it echo the $sql to the screen and I get on echo and here it is.
$sql = INSERT INTO vcevents(Title, URL, Source, Thumb, EmbedCode, Enabled, DateAdded)VALUES ('test', 'test', 'test', 'test', 'test', 1, '2009-08-07 14:38:23')
Thanks in advance,
Don