MySql Connection Error

http://pro-connect.infinityfreeapp.com/

Error Message

$conn -> connect_error not giving any error message but connection to db isn’t succeeding

Code (dbconfig.php)

<?php
    $db_name = "epiz_28363796_pro_connect";
    $db_user = "epiz_28363796";
    $db_pass = "xxxxxxxxxxx";
    $db_host = "sql306.epizy.com";

    $conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);

    if(!$conn -> connect_errno){
        echo "Connection Error " . $conn -> connect_error;
        exit();
    }
    else{
        echo("Connection Succesfull");
    }   
?>

Output

Link shown below gives an error Connection Error
http://pro-connect.infinityfreeapp.com/dbconfig.php

Note

I am using hosting account password only…

So Sorry I got it, if condition should be

if(!$con)
1 Like

You’re using a mixture of procedural and object-orientated MySQL, I’m surprised this isn’t throwing errors. Half your issue this that you need to use one or the other.

As your connection is made using procedural MySQL, you need to use the procedural function to check for errors:

if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  exit();
}
3 Likes

yes, I know… But while posting i frustrated a little bit in trying some different methods… anyway Thank you…

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.