Jump to content

Help with class project (emergency)


hdry

Recommended Posts

This is a bit of an emergency since I have a project that is due tomorrow, and I ran into several issues, which includes a friend that was supposed to do the databases somehow ruined his laptop, so I ended up having to do it as well.

 

For this project I am using xampp 1.67 for Windows XP.

 

One of the pages I made was a registration page where the user has to enter their name, age and email and these information will then be stored in the database.

 

When I tried it out, however, I got this error:

 

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'host' (11001) in C:\xampp\htdocs\formproc.php on line 21

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\xampp\htdocs\formproc.php on line 22

 

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\formproc.php on line 32

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\formproc.php on line 32

 

The code:

The form:

http://pastebin.ca/1209375

The form process file:

http://pastebin.ca/1209377

Link to comment
Share on other sites

The form:

<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<body>
	<title>Registration Form</title>
	</head>
	<h2>Registration Form</h2>

	<form action='formproc.php' method='post'>
	Name: <input type="text" name="name" />
	Age: <input type="text" name="age" />
	Email <input type="text" name="email" />
	<input type="submit" />
</form>
</body>
</html>

 

The form process file:

<?php
/*
CREATE TABLE `database`.`members` (
`memberid` INT( 7 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 200 ) NOT NULL ,
`age` VARCHAR( 40 ) NOT NULL ,
`email` VARCHAR( 200 ) NOT NULL
) ENGINE = MYISAM 
*/




$name = htmlentities($_POST['name']);
$age = htmlentities($_POST['age']);
$email = htmlentities($_POST['email']);

if (isset($_POST['name'])){
$connection = mysql_connect("localhost",
			"admin",
			"classproj");
mysql_select_db("database", $connection);

mysql_query("INSERT INTO members (
`memberid` ,
`name` ,
`age` ,
`email`
)
VALUES (
NULL , '$name', '$age', '$email'
);");
}
?>
<html>
<body>
<title>Form Validation</title>
<p><strong>Thank you for registering for our site. Your details is now stored on our site's server.</strong></p>
<p><strong>The following data has been saved on our database:</strong></p>
<table>
	<tr>
	<td class = "username"><?php echo $name;?></td>
	<td class = "age"><?php echo $age;?></td>
	<td class = "mail"><?php echo $mail;?></td>
	</tr>
	Thank you<?php echo $name; ?>.<br />
	<?php echo $email; ?>.<br />
</table>
<br /><br /><br />
</body>
</html>

Link to comment
Share on other sites

The first error that you posted indicates that you are/were using "host" for the host, but your posted code says "localhost." You should be either fixed or getting different errors now. What are those errors? If they are the same, something doesn't add up. The code you list here shouldn't say that it couldn't connect to host "host".

Link to comment
Share on other sites

As stated above, PHP is having problems connecting to your database with the arguments given. Verify this infomration is correct.

 

As a secondary note... no one gets priority. This is a volunteer board and we will help you at the pace we choose. Be thankful you're getting help, rather than telling us how urgently we need to help you.

Link to comment
Share on other sites

I still get the same error:

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'host' (11001) in C:\xampp\htdocs\formproc.php on line 21

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\xampp\htdocs\formproc.php on line 22

 

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\formproc.php on line 32

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\formproc.php on line 32

 

On a side note, I did remember writing it as localhost and saving it before I tested it out.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.