Jump to content

[SOLVED] Need Help...I'm new and confused


derekbelcher

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/142850-solved-need-helpim-new-and-confused/
Share on other sites

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>

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.

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.

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

o.k.  I just figured it out:  ;D 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.