Jump to content
Killersites Forums

Connecting Online form to sql


divz2
 Share

Recommended Posts

Hi,

I am struggling with this problem.

I created an online form and was hoping to collect the form info using phpmyadmin/sql. It is working when I test it locally but it is giving an error when I upload it onto my website. Can someone please help me. Thank you very much.

 

PHP code for connecting to the database:

<?php

//Setting up Information

$dbhost='localhost';

$dbusername='root';

$dbuserpass='my password';

$dbname='whitePaper1';

 

//Connect to the mysql database server

$link_id = mysql_connect ($dbhost, $dbusername, $dbuserpass);

 

//Create database and select the name we want to access

$dbname=$dbusername."_".$dbname;

if (!mysql_select_db($dbname)) die(mysql_error());

?>

 

Error when I run the form and click submit:

 

Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES) in /home/exquip/www/olympicsupport.com/db_connect.inc on line 9

Unknown database 'root_whitePaper1'

Link to comment
Share on other sites

You need to have a Database on the web server, I am guessing that

$dbusername='root';

is the issue as the DB user name would be the database user name on the web server you created. Root seems false for a web server.

 

My web site databases all use a default prefix based on the web site followed by the DB name I choose, this is automatic from my host. So maybe

$dbname='whitePaper1';

should have a prefix? This is the exact name as you find in your database section of your web sites back end?

 

It is rare that my PC SQL Server is set the same way as the customer web server SQL. My guess is that you need to doubvle check and change

        $dbhost='localhost';
       $dbusername='root';
       $dbuserpass='my password';
       $dbname='whitePaper1';

Accordingly.

Link to comment
Share on other sites

The most common cause of this error is bad connection information.

Wrong User or password or host information.

Contact the Hosting Company to determine the connection information. Some Shared web Hosts require "account_username" and "account_password". And not all of then use "localhost"

 

It is also a bad idea to connect from the web using the 'root' account. The root user typically has privileges beyond what the script needs, ie: granting privileges.

Link to comment
Share on other sites

See! About the same answer... but shorter. I guess I should be a Politician! :D One was once described as using 256 words to say "No"... I think I have the required skill for long answers. Elect President LSW. If Elected I promise the formation of a new Party, a third party, A Standards compliant and Accessible Party!!!!

Link to comment
Share on other sites

See! About the same answer... but shorter. I guess I should be a Politician! :D One was once described as using 256 words to say "No"... I think I have the required skill for long answers. Elect President LSW. If Elected I promise the formation of a new Party, a third party, A Standards compliant and Accessible Party!!!!

More like a lecturer because a politician requires to be political correct so that it doesn't upset everyone. :D

Link to comment
Share on other sites

Well I am "Chronically Challenged" (Old), "Horizontally challenged" (Over weight), "Optically Impaired" (not the greatest looking) but more than "Optically Challenged" (Ugly) and after this week... feeling "Living Impaired" (like a Zombie)... so can I run for local Government at least?

 

Oh, that is of course as long as I am not involved with a "Water Fairing" (Float Plane) Controlled Flight Into Terrain. (FAA term for Airplane crashes).

Link to comment
Share on other sites

Hi guys,

I am sorry but I am still not able to connect the online form to collect data using mysql and phpmyadmin.

This code (mentioned above) is working on local system (http://localhost) when I test it.

So I was wondering if $dbhost='localhost'; should be changed to the correct ip address so that the data entered on the website online form will be collected into phpmyadmin.

How will I know what is the host ip address for the phpmyadmin??

Thanks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...