0

EDIT! I see that many people are answering to my question, and thank you. But most of you are talking about some user name, which I do not get. I am actually using this example over here:

http : //people. cis.ksu .edu/~hankley/d764/tut06/GopisettyPHP.html

and am trying to make it using this reference. Over there is something completely different, cis-id, which I do not understand. Yes, I do not understand what the cis id is, which is in here:

$con = mysql_connect("sql107.freezoy.com","CIS-ID","REDACTED INFORMATION");

And also, many people are saying that I wrote name instead of Full Name and phone instead of Phone Number, but that is not referring to the table. The 'phone' and 'name' are the names I gave to the inputs in the HTML form.

Thanks, Kind Regards, Danish Humair

BACK TO THE OLD POST

Well, I am currently working on a website. Basically what happens is that you submit your name and phone number and it is inserted into the database. This may be a very 'newbie`ish' question, but I need your help.

Well, I made the table in the database and everything. Then I put this code into the HTML document:

<html>
  <head>
    <link rel="shortcut icon" href="main/shortcut_icon.ico" />
    <link rel="stylesheet" href="main/common.css" />
    <title>
      Danish Core
    </title>
  </head>
  <body>
    <p class="title">
      Welcome! Here is a simple form that uses PHP and MySQL!
    </p>
    <p>
      Note: Please do not submit any sensitive information, as all that you submit will be saved into our database. Also, please do not spam by submitting irrelevant (or related) text.
    </p>
    <br />
    <br />
    <form action="insert.php" method="post">
      Full Name:
      <input type="text" name="name" />
      <br />
      <br />
      Phone Number:
      <input type="text" name="phone" />
      <br />
      <br />
      <input type="submit" />
    </form>
  </body>
</html>

Well, and the 'insert.php' mentioned in the form's opening tag:

<html>
<body>


<?php
$con = mysql_connect("sql107.freezoy.com","frzoy_15640861_main","REDACTED INFORMATION");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("frzoy_15640861_main", $con);

$sql="INSERT INTO ClientInformation (name, phone)
VALUES
('$_POST[name]','$_POST[phone]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)
?>
</body>
</html>

And here is a screen shot of my MySQL table:

https://i.stack.imgur.com/VGITc.png

And also my host's information:

https://i.stack.imgur.com/GA3vK.png

And the error is this: Could not connect: Access denied for user 'frzoy_15640861_main'@'192.168.0.40' (using password: YES)

I believe that it is most likely that the information to connect to the database was incorrect in the insert.php file. I have included the database information with the password redacted, so - if you could please help me with the trouble I am having thanks!

Thank you for reading! Kind Regards, Danish Humair

  • 4
    I'd remove the real credentials and put in some dummy values if I were you. – martincarlin87 Dec 11 '14 at 10:34
  • avoid `mysql` functions as they are depricated. Switch to `mysqli` or `pdo`. If you have this code on your server, than you use the term `localhost` instead of `sql107.freezoy.com` since you try to connect from outside to the inside, while you are already inside. This indeed may cause an error. Try it with `localhost`. – Dorvalla Dec 11 '14 at 10:47
  • As per this [picture](http://i.stack.imgur.com/GA3vK.png) Your mysql username is frzoy_15640861 – Indra Kumar S Dec 11 '14 at 10:53

4 Answers4

0

Your Database fields are different.

Full Name and your inserting name

Phone Number and you are inserting phone

Rename you DB table fields to name and phone

Note:

Don't use mysql_ functions. They are deprecated.

Pupil
  • 23,834
  • 6
  • 44
  • 66
0

I believe that the user exists and its password is correct but is not permitted to connect from the IP that the connection is coming from. Check this old question in StackOverflow.

Community
  • 1
  • 1
jcbermu
  • 557
  • 6
  • 12
0

From what I can see from the screenshot you're trying to connect with the username frzoy_15640861_main which is the db name instead. The user should be frzoy_15640861. Maybe the issue is in the credentials you are providing. Am I wrong?

theLibertine
  • 175
  • 7
0

Guys, you were right, but there was another thing that had to be done.

You guys were right that I inserted the database name in place of the username, and that I had written name and phone rather than Full Name and Phone Number. There was yet another problem. I was still not able to insert the data as the Table columns Full Name and Phone Number had a space in them! (between full and name, and phone and number)

This is though pretty weird, but removing those spaces in the table did the trick!

Thank you all for helping. Kind Regards, Danish Humair.