Jump to content

[SOLVED] connecting to a database using mysqli...


woodsonoversoul

Recommended Posts

are you required to include a password if your db dosen't require it? My connection was working fine using:

 

// set server access variables

    $host = "localhost";

    $user = "root";

    $db = "testdb";

// open connection

    $connection = mysql_connect($host, $user) or die ("Unable to connect!");

// select database

    mysql_select_db($db) or die ("Unable to select database!");

 

But when I try to do this using mysqli:

 

// set server access variables

$host = "localhost";

$user = "root";

$db = "testdb";

 

// create mysqli object

// open connection

$mysqli = new mysqli($host, $user, $db);

 

// check for connection errors

if (mysqli_connect_errno()) {

    die("Unable to connect!");

 

I get an error message. What gives?

   

 

 

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.