Jump to content

mysqli_connect()


White_Lily

Recommended Posts

Hi, I have ahd a slight problem with the deprecation of mysql_*() functions, and so are swapping them for mysqli_*() functions, how I have come across an error which states that $connect is undefined.

 

<?php

$GLOBALS["host"] = "localhost";
$GLOBALS["user"] = "web113-social-1";
$GLOBALS["pass"] = "********";
$GLOBALS["database"] = "***************";

$connect = mysqli_connect($GLOBALS["host"], $GLOBALS["user"], $GLOBALS["pass"], $GLOBALS["database"]);
?>

 

I have compared this against php.net's examples, and this code looks almost exact. I dont know what the problem is. Any help would be appreciated.

 

- Lily

Link to comment
https://forums.phpfreaks.com/topic/273514-mysqli_connect/
Share on other sites

Okay, so I looked back at php.net to see what error checking they use...

 

<?php

$connect = mysqli_connect("localhost", "username", "password", "database");

if(!$connect){
die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
}

echo 'Success... ' . mysqli_get_host_info($connect) . "\n";
?>

 

Guess what... Still getting an Undefined $connect error... dispite manually typing in the connection settings.

Link to comment
https://forums.phpfreaks.com/topic/273514-mysqli_connect/#findComment-1407660
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.