Jump to content

how to configure msqli


gongpex

Recommended Posts

Hello everyone,

 

today after configuration php.ini

 

I tried to connect mysql through PHP using this code :

<?php$host = "localhost";$user = "root";$pass = "abcdefgh";$database = "test";$connect = mysql_connect($host,$user,$pass);$db = mysql_select_db($database,$connect);if($db) { echo success; } else { echo failure;}?>

the result in browser didn't shown anything.

 

but after I configure php.ini I give comment on extension=php_mysqli.dll,

 

then I uncomment on extension=php_mysql.dll

 

then it can be connect, and show "success".

 

Q : if I configure php.ini using mysqli, Is there some code on above should be changed?

 

please help

 

thanks

Edited by gong
Link to comment
Share on other sites

When you changed your php.ini to point to the mysqli.dll, did you change your code to use

mysqli_*

functions instead?

Link to comment
Share on other sites

As thescientist already pointed out you have to replace

 

mysql_connect with mysqli_connect

 

and

 

mysql_select_db with mysqli_select_db

 

and so on and so forth throughout your code

 

mysql_ has been deprecated in PHP 5.5.

 

What PHP version are you using by the way?

Link to comment
Share on other sites

When you changed your php.ini to point to the mysqli.dll, did you change your code to use

 

yes, I had change it like this :

<?php$host = "localhost";$user = "root";$pass = "abcdefgh";$database = "test";$connect = mysqli_connect($host,$user,$pass);$db = mysqli_select_db($database,$connect);if($db) { echo success; } else { echo failure;}?>

but code on above didn't shown anything (display blank page on browser) like I mention before.

 

What PHP version are you using by the way?

 

my PHP version is 5.3.0

 

Q : Btw, Is some php version not support mysqli?

 

please help

 

thanks

Edited by gong
Link to comment
Share on other sites

are you checking for errors? it doesn't seem like you have them set to display. I would turn error reporting and displaying on and see what happens.

 

also just try with a basic test page. try one when pointed to the mysql.dll, then try again with the mysqli.dll

 

<?php phpinfo(); ?>

 

Also, you restarted apache after making changes to php.ini, yes?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...