Sql/php Question

liunx

Guest
Hello!<br /><br />I'm new to ***** Hosting (just got everything set up a couple of days ago, in fact) and I was wondering if anyone here might be able to help me out.<br /><br />I've some experience with Web design, but all of my database work has been with ASP. I'm learning a bit of how PHP works, but I keep having trouble accessing my database. I am told that, while I can connect to the server, it cannot find the database itself.<br /><br />Here's what I've been using:<br /><br />$dbh=@mysql_connect ("localhost", "db_user", "password") or die ('I cannot connect to the database because: ' . mysql_error());<br /><br /><br />if (!$dbh) {<br />echo( "<p>Unable to connect to the " .<br />"database server at this time.</p>" );<br />exit();<br />}<br /><br />mysql_select_db("db_",$dbh);<br /><br />if (!@mysql_select_db("db_") ) {<br />echo( "<p>Unable to locate the db " .<br />"database at this time.</p>" );<br />exit();<br />}<br /><br />Sorry if this goes beyond the scope of support, but I just thought I'd see if anyone could see what I was doing wrong.<br /><br />Many thanks!<!--content-->
This might help<br /><br />Name of host - localhost<br />Database Name - cpanelusername_dbname<br />Datbase User Name - cpanelusername_dbusername<!--content-->
If you go to your mysql manager in your cpanel it will display the PHP code necessary to connect to your database. It's very handy!<br /><br />-chicken<!--content-->
Head Guru: Thanks very much! That was the information I needed!<br /><br />And I agree: the information provided that tells you how to connect to the database is very helpful. <br /><br />Although I will be happy to post something in the Reviews forum, I must say that I have been very impressed with the tools and service provided by Simple Net Hosting. I've been maintaining a colleague's Web site for some time now--I only wish I had had the tools and capabilities I have here! (Hm...maybe I should talk to him about moving over... you think?)<br /><br />Again, many thanks for the help!<!--content-->
 
Back
Top