Failing to us php to insert data to mysql database
Posted: Sat May 18, 2002 7:14 pm
Hello
Can someone help me, I'm trying to insert data in a table created but i encounter an error when i try to insert the data via form. Error message:
"Server error!
Error message:
handler "httpd/unix-directory" not found for: C:/mywww/
If you think this is a server error, please contact the webmaster "
This is the php code written for
<html>
<head>
<title>Inserting records into School DB</title>
<body>
<form name="author_admin" method="post" action="<?php echo $PHP_SELF;?>">
<p>Student ID: <input type="number" name="studentId"><br>
<p>First Name: <input type="text" name="firstName"><br>
<p>Last Name: <input type="text" name="lastname"><br>
e-mail: <input type="text" name="email">
<input type="submit" name = "submit" value="Insert"></p>
</form>
<?php
$Dbname="roll";
$dbHost=@mysql_connect("localhost", "", "");
mysql_select_db("$Dbname", $dbHost);
if ((isset($studentId)) AND (isset($firstName)) AND (isset($lastName)) AND (isset($email))) {
$sql="INSERT INTO roll VALUES('','$studentId','$firstName', '$lastName','$email')";
$result=mysql_query($sql,$dbHost);
echo "<h1>Success!</h1><p>";
echo "$firstName $lastName was inserted into the database. Here are the details:<p>";
echo "Name: $firstName $name<br>Student ID $studentId<br>email: $email<p>";
}
mysql_close();
?>
</body>
</html>
and my doc root is mywww.
Help pls cos i'm getting quite frustrated! (
Can someone help me, I'm trying to insert data in a table created but i encounter an error when i try to insert the data via form. Error message:
"Server error!
Error message:
handler "httpd/unix-directory" not found for: C:/mywww/
If you think this is a server error, please contact the webmaster "
This is the php code written for
<html>
<head>
<title>Inserting records into School DB</title>
<body>
<form name="author_admin" method="post" action="<?php echo $PHP_SELF;?>">
<p>Student ID: <input type="number" name="studentId"><br>
<p>First Name: <input type="text" name="firstName"><br>
<p>Last Name: <input type="text" name="lastname"><br>
e-mail: <input type="text" name="email">
<input type="submit" name = "submit" value="Insert"></p>
</form>
<?php
$Dbname="roll";
$dbHost=@mysql_connect("localhost", "", "");
mysql_select_db("$Dbname", $dbHost);
if ((isset($studentId)) AND (isset($firstName)) AND (isset($lastName)) AND (isset($email))) {
$sql="INSERT INTO roll VALUES('','$studentId','$firstName', '$lastName','$email')";
$result=mysql_query($sql,$dbHost);
echo "<h1>Success!</h1><p>";
echo "$firstName $lastName was inserted into the database. Here are the details:<p>";
echo "Name: $firstName $name<br>Student ID $studentId<br>email: $email<p>";
}
mysql_close();
?>
</body>
</html>
and my doc root is mywww.
Help pls cos i'm getting quite frustrated! (