Jump to content
Sign in to follow this  

include once is not working

Recommended Posts

i am saving db.php and header.php files in same folder i am including db.php file in header.php



<?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

Share this post

Link to post
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>"}?>

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...