PC Nerd Posted May 12, 2007 Share Posted May 12, 2007 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."); } ?> Quote Link to comment Share on other sites More sharing options...
Trium918 Posted May 12, 2007 Share Posted May 12, 2007 The error is in here somewhere. Double check for spelling and whitespacing. <?php $host="localhost"; $account="USER"; $password="PASSWORD"; $dbname="DATABASE NAME"; $DB_Server = mysqli_connect($host, $account, $password); ?> Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 12, 2007 Author Share Posted May 12, 2007 ok, well ive had a look, however i still cant find a way to fix the error, any more suggestions? Quote Link to comment Share on other sites More sharing options...
Trium918 Posted May 12, 2007 Share Posted May 12, 2007 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";} ?> Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 12, 2007 Author Share Posted May 12, 2007 ok, ill try it in a sec, however im sunniny 5.0.6 i think for mysql, and 4.4.1 for php so mysqli should beworking anyway. ill have a look, and let you know if i come up with anything thankyou Quote Link to comment Share on other sites More sharing options...
neel_basu Posted May 12, 2007 Share Posted May 12, 2007 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..................................... Quote Link to comment Share on other sites More sharing options...
Trium918 Posted May 12, 2007 Share Posted May 12, 2007 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. Quote Link to comment Share on other sites More sharing options...
neel_basu Posted May 12, 2007 Share Posted May 12, 2007 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 Quote Link to comment Share on other sites More sharing options...
neel_basu Posted May 12, 2007 Share Posted May 12, 2007 May be its my personal nostalgia to use mysql_* instead of mysqli_* But I swear I've never faced any problem with mysql_* extension. Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted May 12, 2007 Share Posted May 12, 2007 I am agree with neel_basu. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 12, 2007 Author Share Posted May 12, 2007 ok..... i checked the release of mysqli and it was version 4.1.3, and im running 4.4.6 or higher i think..... ok, ill contact my host about the ini file, thanks for all your help Quote Link to comment Share on other sites More sharing options...
trq Posted May 12, 2007 Share Posted May 12, 2007 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. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 12, 2007 Author Share Posted May 12, 2007 yeah, as i said ill check with my host. Quote Link to comment Share on other sites More sharing options...
neel_basu Posted May 12, 2007 Share Posted May 12, 2007 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"; } ?> Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 12, 2007 Author Share Posted May 12, 2007 ok, got it. the server was configured to run mysqli only on v5 and i have v4.4.6, so i sinply had to edit my .htaccess file, so it used php v5 thanks for your help Quote Link to comment Share on other sites More sharing options...
neel_basu Posted May 12, 2007 Share Posted May 12, 2007 So what you changed in your .htaccess file to do that ?? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 13, 2007 Author Share Posted May 13, 2007 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 Quote Link to comment Share on other sites More sharing options...
neel_basu Posted May 13, 2007 Share Posted May 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted May 13, 2007 Author Share Posted May 13, 2007 um a) wouldnt know, b) huh? godaddy? lol, thanks guys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.