hdry Posted September 23, 2008 Share Posted September 23, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/ Share on other sites More sharing options...
F1Fan Posted September 23, 2008 Share Posted September 23, 2008 Display your mysql connection. It looks like you're using the word "host" as your host, rather than a server address. Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648679 Share on other sites More sharing options...
aebstract Posted September 23, 2008 Share Posted September 23, 2008 Could you post the code? Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648680 Share on other sites More sharing options...
Maq Posted September 23, 2008 Share Posted September 23, 2008 $connection = mysql_connect("host", "admin", "classproj"); You're using "host" for host. That is incorrect, double check this. Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648682 Share on other sites More sharing options...
hdry Posted September 23, 2008 Author Share Posted September 23, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648684 Share on other sites More sharing options...
F1Fan Posted September 23, 2008 Share Posted September 23, 2008 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". Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648689 Share on other sites More sharing options...
discomatt Posted September 23, 2008 Share Posted September 23, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648693 Share on other sites More sharing options...
hdry Posted September 23, 2008 Author Share Posted September 23, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648698 Share on other sites More sharing options...
Maq Posted September 23, 2008 Share Posted September 23, 2008 Could you post the exact code that you got this error with? It's probably something with this line: $connection = mysql_connect("localhost", "admin", "classproj"); Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648700 Share on other sites More sharing options...
F1Fan Posted September 23, 2008 Share Posted September 23, 2008 As I said before, you have "host" as your host. If you saved it as "localhost," you didn't save it to the correct location or file, because the code that you are viewing has "host" as the host, NOT "localhost." Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648701 Share on other sites More sharing options...
JonnoTheDev Posted September 23, 2008 Share Posted September 23, 2008 You can tell you are in a rush! Read the errors carefully that are displayed to you on the screen: Unknown MySQL server host 'host' (11001) in C:\xampp\htdocs\formproc.php on line 21 It is even telling you the file and line number! Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648702 Share on other sites More sharing options...
hdry Posted September 23, 2008 Author Share Posted September 23, 2008 Yeah I rechecked it, and I had to re-edit it again, and it finally works. Thank you all for helping and sorry for the bother I've caused you guys. Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648703 Share on other sites More sharing options...
Maq Posted September 23, 2008 Share Posted September 23, 2008 Thank god... Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648711 Share on other sites More sharing options...
nadeemshafi9 Posted September 23, 2008 Share Posted September 23, 2008 you should hav attended all ur lessons and studdied hard now look at you when people asked me for help with there work i always gave them an idea but never showed them how Quote Link to comment https://forums.phpfreaks.com/topic/125472-help-with-class-project-emergency/#findComment-648734 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.