Jump to content

[SOLVED] mysqli_connect, call to undefined etc....


PC Nerd

Recommended Posts

hi guys,

 

ive come across this error before, bt have been able to fix it.

 

 

im changing servers, and ive uploaded the file, and ive ensured that all my users and paasswords and database stuff is correct, but im still getting this error:

Fatal error: Call to undefined function: mysqli_connect() in FILE NAME on line 13

is this saying that the function isnt there, or that the arguments are incorrect?

 

 

 

 


<?php


$host="localhost";
$account="USER";
$password="PASSWORD";
$dbname="DATABASE NAME";





$DB_Server = mysqli_connect($host, $account, $password);

if(!$DB_Server){
die("There was an error in connecting to the database.  Please try again later");
}


$DB = mysqli_select_db($DB_Server, $dbname);

if(empty($DB)){
die("There was an error in selecting the database.  Please try again later.");
}
?>

ok, well ive had a look, however i still cant find a way to fix the error, any more suggestions?

 

 

I am using PHP4 but it will work for you also. Try this and then

add $account and $password

 

Note: Create a new file for testing.

<?php
$host="localhost";
//$account="USER";
//$password="PASSWORD";
$dbname="Datbase";

$DB_Server = mysql_connect($host) or die(mysql_error());

if(!$DB_Server){
die("There was an error in connecting to the database.  Please try again later");
}

$DB = mysql_select_db($dbname);

if(empty($DB)){
die("There was an error in selecting the database.  Please try again later.");
}
else {echo "Connected";}


?>

Requirements

 

In order to have these functions available, you must compile PHP with support for the mysqli extension.

Installation

 

To install the mysqli extension for PHP, use the --with-mysqli=mysql_config_path/mysql_config configuration .......................

Installation on Windows Systems

 

MySQLi is not enabled by default, so the php_mysqli.dll DLL must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library.....................................

Requirements

 

In order to have these functions available, you must compile PHP with support for the mysqli extension.

Installation

 

To install the mysqli extension for PHP, use the --with-mysqli=mysql_config_path/mysql_config configuration .......................

Installation on Windows Systems

 

MySQLi is not enabled by default, so the php_mysqli.dll DLL must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library.....................................

 

You hit it on the head. That is causing the error. I am still using mysql_connect

instead of mysqli_connect which is PHP5.

 

Note: The code above still works.

I think mysqli is only aviliable on PHP 5

If your server is PHP 4 your script would not work.

--------------------------------------------------------

I dont understand why some guys use mysqli_*

mysql_* is not at all bad

and whatever we need to do with MySQL can easily be done with mysql_*

So why ou are so fond of mysqli_* Extension

May be its my personal nostalgia to use mysql_* instead of mysqli_*

But I swear I've never faced any problem with mysql_* extension.

 

mysqli has allot of new features not available in the old mysql extension, but, yeah, PC NERD, it appears your new server does not support mysqli.

Run this Code to test weather your Server Supports mysqli_* or not

-------------------------------------------------------------------

<?php
header('Content-Type: text/plain');
$report = get_loaded_extensions();
print_r($report);
if(in_array('mysqli', $report))
 {
   echo "MySQLi is Supported \n";
 }
else
 {
   echo "MySQLi Is NOT Supported\n";
 }
?>

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.