I've tried all the suggestions mentioned here. Still no output. With the SELECT I see the statement being written to the screen, but with INSERT nothing comes up and the page keeps looping back to the input form. !!
This is the updated snippet:
<HTML>
<?php
if ($submit) {
include "open_persondb.inc";
$list = array( '_REQUEST', '_COOKIE', '_ENV', '_FILES', '_POST' );
foreach($list as $element) {
if( !empty($$element) && is_array($$element) ) {
extract($$element);
}
}
$sql_insert = "INSERT INTO personnel (firstname, lastname, nick, email, salary) VALUES
('$first','$last','$nickname','$email','$salary')";
print $sql_insert;
$result = mysql_query($sql_insert, $db) or die(mysql_error());
echo "Information Was Submitted.\n";
}
else{
if (mysql_errno() >= 0)
mysql_error();
?>
<form method="post" action="datain.php">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Nick Name:<input type="Text" name="nickname"><br>
E-mail:<input type="Text" name="email"><br>
Salary:<input type="Text" name="salary"><br>
<input type="Submit" name="submit" value="Enter information"></form>
<?
}
?>
</HTML>
and nothing strange in the open_persondb.inc
<?php
$db = mysql_connect("localhost", "root", "");
mysql_select_db("test", $db) or die(mysql_errno() . ": " . mysql_error() . "<br>");
?>
maybe I should just mind my Java business and stay out of PHP 🙂