Another Newbie Syntax Error Question :p
Posted: Wed Feb 19, 2003 7:12 pm
Something I can NEVER seem to get to work:
I just don't know what I'm doing wrong. It's not a problem connecting to the database or anything. The database and table exist. I know I didn't make any mistakes in the form. I'm guessing it's a problem in the query variable, but I've tried a very broad range of syntax and it still never works. Anyone have a clue? Thanks.
Code: Select all
<?php
/* $_POSTs attached to web form */
$date = $_POST['Date'];
$field = $_POST['Text'];
MySQL_connect("localhost", "[user]", "[password]") or die("Unable to connect to MySQL. " . mysql_error);
MySQL_select_db("[database]") or die("Unable to connect to database.");
$data = "INSERT INTO news1 (Date, Field)
VALUES ('$date', '$field')";
$send = mysql_query($data);
if($send){
echo("Data submitted successfully.");
}else{
echo("An error occurred while submitting data.");
}
?>