I get this error: INSERT INTO example VALUES ('Craig', '33')Your information COULD NOT be entered into the database.
I am thinking that it is a problem in the mysql_query portion of the WELCOME.PHP script.. Can soeone take a peek, and see where I went wrong?
Thanks!
Scripts:
INCLUDE.PHP
<?
//<!-- MySQL Config -->
$hostname="localhost";
$username="root";
$password="******";
//<!-- DataBase Config -->
$database_name="diw_db";
$table1="example";
?>
HI.PHP
<html>
<body>
<form action="welcome.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
WELCOME.PHP
<?
include ("config.php");
$name=$HTTP_POST_VARS['name'];
$age=$HTTP_POST_VARS['age'];
$connection=mysql_connect($hostname, $username, $password)
or die("Could not establish connection");
mysql_select_db($database_name, $connection)
or die ("Could not select database");
$query="INSERT INTO `example` VALUES ('".$name."', '".$age."')";
echo $query;
$result=mysql_query($query);
mysql_close($connection);
if (!$result)
{die("<font color=\"red\"><b>Your information COULD NOT be entered into the database\.</font><br>");}
echo "
<TABLE BORDER>
<TR>
<TD COLSPAN='2'>Our records indicate that you are</TD>
</TR>
<TR>
<TD>Name</TD><TD>".$name. "</TD>
</TR>
<TR>
<TD>Age</TD><TD>" .$age. "</TD>
</TR>
</TABLE>";
?>
<html>
<body>
</body>
</html>