Failing to us php to insert data to mysql database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
igbidephilip
Forum Newbie
Posts: 1
Joined: Sat May 18, 2002 7:14 pm

Failing to us php to insert data to mysql database

Post by igbidephilip »

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! (
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

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
Well, it looks like a server error to me.

Also, remove the @ in front of the mysql_connect() function.
User avatar
Gavski
Forum Newbie
Posts: 19
Joined: Thu May 16, 2002 2:30 pm
Location: UK

sql root directory

Post by Gavski »

If you are running mysql from a path other than C:\mysql you have to alter my.ini to reflect this, I see you are using C:\mywww, make sure that mysql knows this. Look in my.ini or on mysqladmin if you have it.

I don't know if this is your problem but it may be worth checking if you haven't already.
Post Reply