sandeepm Posted April 20, 2015 Share Posted April 20, 2015 (edited) i am saving db.php and header.php files in same folder i am including db.php file in header.php like <?php include_once("db.php");?> not including the file and givind error message like no database is selected i checked db in phpmyadmin it is perfect, in db.php i wrote connection like $con = mysql_connect("localhost","root",""); mysql_select_db("fun",$con); not connecting, but this same code past in index file it working... what is the mistake.? can any one help me please.... Edited April 23, 2015 by sandeepm Link to comment Share on other sites More sharing options...
davej Posted April 20, 2015 Share Posted April 20, 2015 Perhaps something like... <?phpecho "<p>Php is running</p>";error_reporting(E_ALL);ini_set('display_errors','On');$dbcon = mysqli_connect("localhost","root","mypassword");if(!$dbcon){ echo "<p>Unable to connect to MySQL</p>";}else if(!mysqli_select_db($dbcon,"mydatabasename")){ echo "<p>Unable to open database</p>";}else{ echo "<p>database connected</p>"}?> 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