Hi,
Please excuse my complete PHP stupidity, I am very new to PHP and mySQL, but I am trying to use the following code to submit a news item to my database.
<?php
$connection = mysql_connect (localhost, <USER>, <PASSWORD>) or die ("Unable to connect!");
mysql_select_db (<DBASENAME>);
$newdate = trim($date);
$newsubject = addslashes($subject);
$newtext = addslashes($text);
$result = mysql_query ("INSERT INTO vp_news (news_time, news_subject, news_text)
VALUES ('$newdate', '$newsubject '$newtext')
");
if(!result)
{
echo "<b>INSERT unsuccessful:</b> ", mysql_error();
exit;
}
else
{
print ("Thanks for submitting details.");
}
?>
This is called by a simple HTML form, I've made sure that the variable names match up.
I have removed the database name and the password and username from above.
The mySQL database table 'vp_news' is setup as follows;
news_id - int(10) - auto_increment
news_time - varchar(20)
news_subject - varchar(100)
news_text - text
I have another script which gets these news items out of the database and displays them, this works fine if I manually enter the data into the database (using phpMyAdmin) but if I try to use the above script, I get the thank you message (i.e. no errors reported anyway) but when I look at the database nothing has been added.
The database and all of the webpages etc, are on my ISPs server. This works fine as I am currently running phpBB in the same database with no complaints.
Does anyone know where I'm going wrong? It's bound to be something bvious but I just can't figure it.
Any help would be most appreciated
Richard