Hello there,
I am new to PHP/MYSQL.
Up to the this point, all my codes have worked fine. I created a new database, added a new table on the fly based on the user's input -table name and numbers of field. I created a form to collect data for a new record and call for addrecord.php. however, the php page is displayed as text in the web browser. Could someone take a look at what is wrong in the code below? Thanks a lot.
<?
if ((!$POST[id]) || (!$POST[format]) || (!$_POST[title])) {
header("Location: /addrecord.html");
exit;
}
$db_name="sampledb";
$table_name="my_video";
//connect to MySQL and select database to use
$connection = @mysql_connect ("localhost", "freeman", "greenpass")
or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql="INSERT INTO $table_name (id, format, title, artist_fn, artist_ln,my_notes)
VALUES ('$POST[id]','$POST[format]','$POST[title]','$POST[artist_fn]','$POST[artist_ln]','$POST[my_notes]')";
$result = mysql_query($sql,$connection) or die(mysql_error());
?>
<html>
html part works fine.
</html>
thanks a lot.
jque 😕