Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

having problem with apache after installing wampserver

Status
Not open for further replies.

fnan

MIS
Apr 3, 2011
2
My laptop is installed xp professional service pack-2. I installed wampserver-2 to test my page in localhost before the actual release of it. I create a form and php code which will link it to my mysql table. Then to read the users comment from the form. Then When I tried it in localhost I receive this message: "Apache HTTP Server has encountered a problem and need to close"
This is the php code I write:(file name: demo.php)

Code:
<?php
define('DB_NAME', 'forms1');
define('DB_USER', 'root');
define('DB_PASSWORD', ');
define('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link){
	die('could not connect: ' . mysql_error());

}
$db_selected = mysql_select_db(DB_NAME,$link);
if(!$db_selected){
	die('can\'t use ' . DB_NAME . ': ' . mysql_error());
}
echo 'connected successfully';
$value = $_POST['fname'];
$value2 = $_POST['lname'];
$value3 = $_POST['comment'];
$sql = "INSERT INTO table-demo VALUES('$value','$value2','$value3')";
	if(mysql_query($sql)){
		echo "one record addedd scucessfully";
	}
mysql_close();
?>
</code>
And this is the form code I write (file name demo-from.php)
<code>
<html>
<head>
<title>This is the demo-form.php</title>
</head>
<body>
<h1>Fill the form</h1>
<form action="demo.php" method="post">
<p>First Name:<input type="text" name="fname" /></p>
<p>Last Name:<input type="text" name="lname" /></p>
<p>comment Box</p>
<textarea rows="8" cols="30" name="comment"></textarea>
<input type="submit" value="send" />
</form>
</body>
</html>
And of course I have a database named forms1 and a table named table-demo
 
Open Skype -> Tools -> Advanced -> Connections -> uncheck "Use port 80 and 443 as alternatives for incoming connections".




Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top