chibineku Posted June 20, 2009 Report Share Posted June 20, 2009 I have been trying to configure MySQL, PHP and Apache, and I thought I had it figured out, but on running the following trial script, I get no output at all: <?php$mysqli = new mysqli("localhost","********","********","test");if (mysqli_connect_errno()) {printf("Connect failed: %s\n", mysqli_connect_error());exit();} else {printf("Host information: %s\n", mysqli_get_host_info($mysqli));}?> Obviously I am replacing the asterisks with a valid username and password. It ought to at least display an error, but I get nothing. Other PHP scripts work fine and my MySQL instance runs from the command line without any problems.And ideas? I feel like such a noob these days with all the basic installation threads I'm starting. Link to comment Share on other sites More sharing options...
MrFish Posted June 23, 2009 Report Share Posted June 23, 2009 (edited) This is how I do it and it works fine and is easy to fix if any problems arise. <?php$con = mysql_connect("server", "name", "password");if(!$con){ echo 'Could not connect to the database: ', die(mysql_error());}?> But maybe you're trying to do more then just connecting the database? Because I've never seen mysqli_get_host_info.Are you sure mysql should have an 'i' at the end of it?Edit: Oh, and when I'm debugging, I like to set up alerts everywhere in my code to see exactly where it stops working- <?php$con = mysql_connect("server", "name", "password");echo '<script type="text/javascript">'echo 'alert("1");'; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////echo '</script>'if(!$con){echo '<script type="text/javascript">'echo 'alert("2");'; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////echo '</script>' echo 'Could not connect to the database: ', die(mysql_error());echo '<script type="text/javascript">'echo 'alert("3");'; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////echo '</script>'}echo '<script type="text/javascript">'echo 'alert("4");'; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////echo '</script>'?> See? Now when you see alerts 1-2 then you know there's a problem with your error message and it's congesting the whole thing. Edited June 23, 2009 by MrFish Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now