What does the PHP Manual mean about using mysql and mysqli?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ssmela
Forum Newbie
Posts: 5
Joined: Mon Aug 20, 2007 8:44 pm

What does the PHP Manual mean about using mysql and mysqli?

Post by ssmela »

According to the PHP Manual,

"If you would like to install the mysql extension along with the mysqli extension you have to use the same client library to avoid any conflicts."

I find this confusing because I have two dll libraries installed on my Windows XAMP system:

(1) php_mysql.dll
(2) php_mysqli.dll

I seem to be able to use functions from both of these libraries, so I am confused as to what the PHP manual is saying.

Also, I was looking at a piece of code that has the following statement:

Code: Select all

$cnt=$db->get_var("select count(*) from categories_description");
Where can I find information on the get_var method. Is this a part of mysqli?

Thank you.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Code: Select all

$cnt=$db->get_var("select count(*) from categories_description");
$db is an Instance of a Class, and get_var is a function in that class.

Not quite sure where you got that snippet from.
ssmela
Forum Newbie
Posts: 5
Joined: Mon Aug 20, 2007 8:44 pm

Post by ssmela »

OK sorry I should have given more information on the question about "get_var ".

Here is the more complete example.

Code: Select all

$connection = mysql_connect("localhost",$Login,$Password) or die("Couldn't make a connection.");
$db = mysql_select_db($theDB, $connection) or die("Couldn't select database.");
$cnt=$db->get_var("select count(*) from categories_description");
Where can I find information on the get_var method. Is this a part of mysqli?

Thank you
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

mysql_select_db returns a boolean (i.e. TRUE or FALSE).
Therefore $db->get_var in your script must fail since $db is not an object.
Did you actually copy that code snippet? If you did: From where?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: What does the PHP Manual mean about using mysql and mysq

Post by timvw »

ssmela wrote: "If you would like to install the mysql extension along with the mysqli extension you have to use the same client library to avoid any conflicts."
I seem to be able to use functions from both of these libraries, so I am confused as to what the PHP manual is saying.
AFAIK the manual is talking about libmysql (a library that both the mysql and mysqli extension use)... So, unless you start building your own binaries it's not something you should think about (and even if you build your own, it's rather uncommon that you would want to use two different versions.)
Post Reply