divz2 Posted May 8, 2009 Report Share Posted May 8, 2009 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' Quote Link to comment Share on other sites More sharing options...
LSW Posted May 8, 2009 Report Share Posted May 8, 2009 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. Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted May 8, 2009 Report Share Posted May 8, 2009 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. Quote Link to comment Share on other sites More sharing options...
LSW Posted May 8, 2009 Report Share Posted May 8, 2009 See! About the same answer... but shorter. I guess I should be a Politician! 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!!!! Quote Link to comment Share on other sites More sharing options...
newseed Posted May 8, 2009 Report Share Posted May 8, 2009 See! About the same answer... but shorter. I guess I should be a Politician! 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. Quote Link to comment Share on other sites More sharing options...
LSW Posted May 8, 2009 Report Share Posted May 8, 2009 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). Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted May 9, 2009 Report Share Posted May 9, 2009 That would be "Chronologically Challenged", same as me. Coming on 56 this October. I'll bet you are younger than that, LSW. Quote Link to comment Share on other sites More sharing options...
divz2 Posted May 11, 2009 Author Report Share Posted May 11, 2009 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. 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.
Note: Your post will require moderator approval before it will be visible.