derekbelcher Posted January 28, 2009 Share Posted January 28, 2009 I am trying to do a simple data entry form, and am getting errors. This is my first database attempt. See below: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'p2r71184_admin'@'cp01.myhostcenter.com' (using password: YES) in /home/p2r71184/public_html/addentry.php on line 8 Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/p2r71184/public_html/addentry.php on line 9 Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/p2r71184/public_html/addentry.php on line 9 Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/p2r71184/public_html/addentry.php on line 14 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/p2r71184/public_html/addentry.php on line 14 ERROR: unable to post. How do I correct this stuff? Quote Link to comment Share on other sites More sharing options...
Zhadus Posted January 28, 2009 Share Posted January 28, 2009 Check your password, if that's fine, please post your code so we can take a look. Quote Link to comment Share on other sites More sharing options...
derekbelcher Posted January 28, 2009 Author Share Posted January 28, 2009 Here is the code: <HTML> <HEAD> <TITLE>Add a Weblog Entry</TITLE> </HEAD> <BODY> <?php if ($HTTP_POST_VARS['submit']) { mysql_connect("mercercountyfa.org","p2r71184_admin","692134"); mysql_select_db("p2r71184_training"); $entrytitle=$HTTP_POST_VARS['entrytitle']; $entrytext=$HTTP_POST_VARS['entrytext']; $query ="INSERT INTO weblog (entrytitle,entrytext)"; $query.=" VALUES ('$entrytitle','$entrytext')"; $result=mysql_query($query); if ($result) echo "<b>Successfully Posted!</b>"; else echo "<b>ERROR: unable to post.</b>"; } ?> <H1>Add an Entry</H1> <form method="POST" action="addentry.php"> <b>Title:</b><br> <input type="text" name="entrytitle"><br> <b>Weblog Entry:</b><br> <textarea cols="60" rows="6" name="entrytext"> </textarea><br> <input type="submit" name="submit" value="Submit"> </form> </BODY> </HTML> Quote Link to comment Share on other sites More sharing options...
gevans Posted January 28, 2009 Share Posted January 28, 2009 You'r problem is with the details on this line; mysql_connect("mercercountyfa.org","p2r71184_admin","692134"); Check your database name, username and password. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted January 28, 2009 Share Posted January 28, 2009 that looks like a student id ?? Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted January 28, 2009 Share Posted January 28, 2009 might aswell put a barcode on ur arm, yeh ur passwords wrong Quote Link to comment Share on other sites More sharing options...
derekbelcher Posted January 28, 2009 Author Share Posted January 28, 2009 o.k. here is the stupid question now. My domain name is www.mercerccountyfa.org and when I put my server name as mercercountyfa.org it turns it into cp01.myhostcenter.com. I am not sure what my server name should look like. I am very new to this, and thought I could figure it out, but I am lost. I am using cpanel to create the sql database. Quote Link to comment Share on other sites More sharing options...
gevans Posted January 28, 2009 Share Posted January 28, 2009 I believe cPanel uses localhost, try this line instead of yours; mysql_connect("localhost","p2r71184_admin","692134") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 28, 2009 Share Posted January 28, 2009 Your database page (where you created the database, database user and password) in your control panel usually displays the correct host name/IP address of the database server to use in the connection. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted January 28, 2009 Share Posted January 28, 2009 it says access denied, that means its got the host it just cant log in, thats my opinion, either the username or password is wrong Quote Link to comment Share on other sites More sharing options...
derekbelcher Posted January 28, 2009 Author Share Posted January 28, 2009 I am still not sure. I tried it with localhost and with the domain name and it still says it's invalid. I don't know. Thanks for your help though. I'll keep messing with it and see what I can do Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 28, 2009 Share Posted January 28, 2009 Most shared web hosting has multiple database servers. Unless he gets the correct hostname where his database/database user/password was created, he will not be able to connect, even though he is using a hostname that does correspond to a database server. Quote Link to comment Share on other sites More sharing options...
derekbelcher Posted January 28, 2009 Author Share Posted January 28, 2009 I have an ip address where my site is hosted, would that help? I am using simplehost.com, if anyone has ever used that hosting service. thanks Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 28, 2009 Share Posted January 28, 2009 No, the IP address of the web site is not necessarily going to be the IP address of you database server. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted January 28, 2009 Share Posted January 28, 2009 log into c panel and make a user i bet you havent made a user for that database ? when u make a databse you have to make a user for it too, this is done where u created teh database its simple in c panel u create the user not in phpmyadmin but in c panel and then you add the user to teh database in c panel Quote Link to comment Share on other sites More sharing options...
derekbelcher Posted January 28, 2009 Author Share Posted January 28, 2009 o.k. I just figured it out: I was using the wrong username. I thought when I created the database, I had to create a username, but the database assigned a different name and I found it. It works. This was the first time I have been able to utilize databases...woo hoo. Thanks for your help Quote Link to comment 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.