After Switching to mysqli...Failing to Connect to MySQL
Posted: Fri Jan 09, 2015 8:53 am
The $conn connection handler variable is showing nothing, so I know it is not connecting. Why? I don't know. When I was using mysql_pconnect($host, $user, $pass); this was working, until I did some update in Linux Ubuntu. Anyway, I want to proceed with moving over to mysqli extensions now and make this all work. Got any ideas on what is going wrong here? I used a few print statements to try to debug this.
Code: Select all
<?php
$lDebug = TRUE;
$host = "localhost";
$user = "web_user";
$pass = "bubbagumpfakepassword";
$db = "mysql";
$conn = "";
echo "{$user}";
echo "<br />";
$today = strtotime(date("Y-m-d"));
echo "Time is: $today";
// This part sets up the connection to the
// database (so you don't need to reopen the connection
// again on the same page).
// 01/08/2015 Cecil Champenois. Apache 2 PHP code has deprecated mysql_pconnect. Use mysqli_connect() instead.
//$ms = mysql_pconnect($host, $user, $pass);
$conn = mysqli_connect($host, $user, $pass, $db); // 01/08/2015 Cecil.
print("<br/>");
print("This is the connection handler: " . $conn);
// Check Connection.
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}