Help With Php/mysql

liunx

Guest
I am in the process of moving my site from another host to here. A few of my pages use a mysql database. I created the database, populated it (with a dump from the old one), changed the config files to point to the correct database, but it's giving me an error:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'lunarmagic@localhost' (Using password: YES) in /home/lunardr/public_html/index.php on line 46<br />Couldn't connect to MySQL<!--c2--></div><!--ec2--><br /><br />I'm not really sure what to do about it, since it worked fine on my old site. Could someone please let me know if there's anything I should be doing differently? Here's my connection code...<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->include('statsconfig.html');<br /><br />$db = mysql_connect($server, $username, $password);<br />if (! $db)<br />die("Couldn't connect to MySQL");<br />mysql_select_db($database,$db) or die("Select DB Error: ".mysql_error());<!--c2--></div><!--ec2--><br /><br />$server is set to "localhost", username and password I set up in the database manually.<br /><br />Thanks.<!--content-->
did you assign a username to the database in cpanel? also when you configured it the dbase name should be cpanelusername_dbasename, same way with dbase username.<!--content-->
Dang, that's the problem... the name of the user. Blech... thanks for your help!!<!--content-->
You don't need to create a new user to access the database. Your Cpanel username and password should work just fine.<br /><br />Just a little advice, change the line<br /><br />die("Couldn't connect to MySQL");<br /><br />into<br /><br />die("Couldn't connect to MySQL: " . mysql_error());<br /><br />It will provide you with more information on the error.<!--content-->
 
Back
Top