Click here to Skip to main content
14,838,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i made database in phpmyadmin but when i use mysqli_connect to connect in database it doesn't work
(Unknown database)

this is function

function connect()
// Check connection
if (mysqli_connect_errno())
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
      echo "Yes";
      return $con;

why ?

1 solution

hi Heba
try this out

$DSN ="localhost " // hostname
$User="root"    // the username
$Password="password" // your password come in the 
$ conx = mysqli_connect($DSN,$User,$Password); 

// check if connection works

if (mysqli_connect errno())
   echo "failed to connect to mysql".mysqli_connect_errno();
  echo "connected :)" ;


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900