doloreel Posted April 30, 2013 Share Posted April 30, 2013 First of all i'm new to this. the mysql_connect('localhost', 'root', '') always seems to run even when the values are wrong. I assume that something is wrong here? I am running MAMP. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted April 30, 2013 Share Posted April 30, 2013 the mysql_connect() statement will always run (assuming the function is defined.) if the connection fails, the function call will return a false value to the calling code. do you have any logic in your code to test if that function returns a false value? Quote Link to comment Share on other sites More sharing options...
doloreel Posted April 30, 2013 Author Share Posted April 30, 2013 Ah ok. No i dont have any logic to test if its false. Quote Link to comment Share on other sites More sharing options...
doloreel Posted April 30, 2013 Author Share Posted April 30, 2013 this is my code now, it just returns 'could not connect' although phpmyadmin is running and i have input everything correctly. any ideas? <?php if (!@mysql_connect('localhost', 'root', '') || !@mysql_select_db('a_database')) { die('could not connect'); } ?> Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted April 30, 2013 Share Posted April 30, 2013 echoing mysql_error() or using mysql_error() in the die() statement will tell you why the connect/select_db statement is failing. 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.