To : Stu
Your SQL statement is nothing wrong but your code is weird enough...
I will explain to you why i said it weird.
first, the all code is located in a file (I named it a.php) which means, who ever who access the a.php, db_connect() will be called and mysql_select_db() will be called also. The problem is why call them where you actually just want to present them a HTML form for them to add news? we suppose to call the db_connect() and mysql_select_db() only when we need database connection.
second, i don't think that your a.php file will get parsed because look at the function add_news_form() which starts with a { but never end with the } !. You should put a
} ?>
after the </form> tag.
third, your sql statement is correct, but it depend on how you set up your database columns. Let say, if we got a table named contry.
country table
cCode - char(2)
cName - char(100)
cCurrency - char(10)
with your SQL statement, you can insert record into this table with
$sqlstm = "INSERT INTO country VALUES ( 'MY', 'Malaysia', 'Ringgit' )";
the insert values must same order with your database layout.
if you want to change the order, then you will use
$sqlstm = "INSERT INTO country (cName,cCode,cCurrency) VALUES ( 'Singapore', 'SG', 'Dollar')";
do you see the difference!
fourth, what function to call when somebody reach a.php?
you put your form and process into function based but what gets called when I go to a.php
i help you a bit here.
if( isset( $_POST ) ) {
add_news();
} else {
add_news_form();
}