ssrvant Posted January 15, 2015 Share Posted January 15, 2015 I am attempting to try and connect to my mysql database. I am using apache webserver. When I run a php script through localhost through my browser the script works well. When I run my mysql_connect.php then all I get is a blank page. nothing happens. I placed an echo statement at the end to verify that it connected. The echo statement doesn't appear when I refresh the page. Here is my code: <?php # Script 7.2 - mysql_connect.php // This file contains the database access information. // This file also establishes a connection to MySQL and selects the database. // Set the database access information as constants. DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', 'xxxxxxxxx'); DEFINE ('DB_HOST', 'localhost:3306'); DEFINE ('DB_NAME', 'reg'); // Make the connnection. $dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() ); // Select the database. @mysqli_select_db(DB_NAME) OR die ('Could not select the database: ' . mysql_error() ); echo 'hello'; ?> Link to comment Share on other sites More sharing options...
HartleySan Posted January 15, 2015 Share Posted January 15, 2015 Hello, and welcome to the forums. If only "hello" is output, then your DB connection is probably okay. Try running a query and see if the results come back. Link to comment Share on other sites More sharing options...
Larry Posted January 18, 2015 Share Posted January 18, 2015 Agreed with hartleysan. And keep in mind that except for the echo statement you added, the results of the page should be blank. Link to comment Share on other sites More sharing options...
Recommended Posts