Jump to content

include once is not working


sandeepm
 Share

Recommended Posts

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 by sandeepm
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...