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.");
}
?>

Link to comment
Share on other sites

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";}


?>

Link to comment
Share on other sites

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.....................................

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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";
 }
?>

Link to comment
Share on other sites

AddHandler application/x-httpd-php5 .php

 

i added that into the ".htaccess" file

 

i think its like a custom extension of the php.ini file, so that you can specify different things to do with the serer and stuf.

 

thanks

Link to comment
Share on other sites

Cool

I knew application/x-httpd-php before

But I didn't knew the application/x-httpd-php5 .

Different Mime Type for PHP 5 ??

Is it Natural ??

or Godaddy has edited their mime.types file in Apache

As they have both PHP4 and PHP5.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.