Board index   FAQ   Search  
Register  Login
Board index PHP PHP Installation

The mysqli extention

Forum for you who has PHP installation issues

Moderators: macek, egami, gesf

The mysqli extention

Postby Dabear » Fri Aug 06, 2004 2:46 am

http://php.net wrote: A new MySQL extension named MySQLi for developers using MySQL 4.1 and later. This new extension includes an object-oriented interface in addition to a traditional interface; as well as support for many of MySQL's new features, such as prepared statements.


Ok, good. I've installed apache2, mysql and php5 on my machine now (win xp home). I've tried to connect to my database, but here's the output:
Code: Select all
Fatal error: Class 'mysqli' not found in C:\Programfiler\Apache Group\Apache2\htdocs\mysqli.php on line 3

So how do I enable mysqli on windows?
User avatar
Dabear
New php-forum User
New php-forum User
 
Posts: 24
Joined: Thu Jul 22, 2004 12:48 pm
Location: Norway

Postby swirlee » Fri Aug 06, 2004 6:06 am

Same way you enable any extension. Uncomment its line (or add it) in PHP.ini.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby Dabear » Fri Aug 06, 2004 7:04 am

If it had been that simple, I've wouldn't asked the question :)

my php.ini wrote:
;Windows Extensions
;Note that ODBC support is built in, so no dll is needed for it.
;
extention=php_mysql.dll
extention=php_mysqli.dll
;extension=libmysqli.dll
;extension=php_bz2.dll
;extension=php_cpdf.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_iconv.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
;extension=php_mysql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_w32api.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_yaz.dll
;extension=php_zip.dll


and the output of
Code: Select all
<?php

$mysqli = new mysqli;
?>

has always been:
Code: Select all
Fatal error: Class 'mysqli' not found in C:\Programfiler\Apache Group\Apache2\htdocs\mysqli.php on line 3
[
User avatar
Dabear
New php-forum User
New php-forum User
 
Posts: 24
Joined: Thu Jul 22, 2004 12:48 pm
Location: Norway

Postby swirlee » Fri Aug 06, 2004 11:21 am

Dabear wrote:
Code: Select all
<?php

$mysqli = new mysqli;
?>


Is this your actual code? The mysqli constructor requires you to pass arguments, like any other function. Try following the example in the documentation.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby Dabear » Fri Aug 06, 2004 12:12 pm

Code: Select all
[string host [, string username [, string passwd [, string dbname [, int port [, string socket]]]]]]


This means that you actually don't need to pass any value. But I've tried adding them too-all of them, it didn't work. It still gives me the same output. I'm forced to use php4(with the mysql-commands) now :(
User avatar
Dabear
New php-forum User
New php-forum User
 
Posts: 24
Joined: Thu Jul 22, 2004 12:48 pm
Location: Norway

Postby swirlee » Fri Aug 06, 2004 12:45 pm

Check to make sure PHP is actually finding the extension. Turn error_reporting to E_ALL while you're at it.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby Dabear » Fri Aug 06, 2004 1:16 pm

<?php
error_reporting(E_ALL);

print_r(get_declared_classes());

$mysqli = new mysqli('localhost', 'root', '***', 'dvd');
?>
I've checked and doublechecked the extension_dir in php.ini, but still I get this output(note: no mysql class in the array)
output:
Code: Select all
Array ( [0] => stdClass [1] => __PHP_Incomplete_Class [2] => Directory [3] => COM [4] => VARIANT )
Fatal error: Cannot instantiate non-existent class: mysqli in C:\Programfiler\Apache Group\Apache2\htdocs\mysqli.php on line 6

Seriously, I don't know what to do next
:sleep:
User avatar
Dabear
New php-forum User
New php-forum User
 
Posts: 24
Joined: Thu Jul 22, 2004 12:48 pm
Location: Norway

Postby Redcircle » Sun Aug 08, 2004 11:40 am

have you started the mysql service or installed the service

go into the mysql/bin dir and type: mysqld -install

then go into your services and start the service.

mysql is installed by default you shouldn't be having a problem.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby GSX1400 » Tue Feb 15, 2005 4:29 am

Redcircle wrote:have you started the mysql service or installed the service

go into the mysql/bin dir and type: mysqld -install

then go into your services and start the service.

mysql is installed by default you shouldn't be having a problem.


I also have this problem

Here's the extensions part of my version of php.ini

;Windows Extensions
;Note that ODBC support is built in, so no dll is needed for it.
;

;extension=php_bz2.dll
;extension=php_cpdf.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_java.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
extension=php_mysql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_w32api.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_yaz.dll
;extension=php_zip.dll

I have mysql version 4.1.7 which is running as a service, PHP 5.0.3, windows 2000 sp4

In response to the snippet included by Dabear

<?php

error_reporting(E_ALL);

print_r(get_declared_classes());

$mysqli = new mysqli('localhost', 'root', '***', 'directory');

?>

I get. .

Array ( [0] => stdClass [1] => Exception [2] => ReflectionException [3] => Reflection [4] => ReflectionFunction [5] => ReflectionParameter [6] => ReflectionMethod [7] => ReflectionClass [8] => ReflectionObject [9] => ReflectionProperty [10] => ReflectionExtension [11] => COMPersistHelper [12] => com_exception [13] => com_safearray_proxy [14] => variant [15] => com [16] => dotnet [17] => RecursiveIteratorIterator [18] => FilterIterator [19] => ParentIterator [20] => LimitIterator [21] => CachingIterator [22] => CachingRecursiveIterator [23] => ArrayObject [24] => ArrayIterator [25] => DirectoryIterator [26] => RecursiveDirectoryIterator [27] => SQLiteDatabase [28] => SQLiteResult [29] => SQLiteUnbuffered [30] => SQLiteException [31] => __PHP_Incomplete_Class [32] => php_user_filter [33] => Directory [34] => DOMException [35] => DOMStringList [36] => DOMNameList [37] => DOMImplementationList [38] => DOMImplementationSource [39] => DOMImplementation [40] => DOMNode [41] => DOMNameSpaceNode [42] => DOMDocumentFragment [43] => DOMDocument [44] => DOMNodeList [45] => DOMNamedNodeMap [46] => DOMCharacterData [47] => DOMAttr [48] => DOMElement [49] => DOMText [50] => DOMComment [51] => DOMTypeinfo [52] => DOMUserDataHandler [53] => DOMDomError [54] => DOMErrorHandler [55] => DOMLocator [56] => DOMConfiguration [57] => DOMCdataSection [58] => DOMDocumentType [59] => DOMNotation [60] => DOMEntity [61] => DOMEntityReference [62] => DOMProcessingInstruction [63] => DOMStringExtend [64] => DOMXPath [65] => SimpleXMLElement [66] => SimpleXMLIterator )
Fatal error: Class 'mysqli' not found in C:\websites\webpages\directory\connect.php on line 16

Any help would be gratefully received
GSX1400
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Feb 15, 2005 4:17 am

Postby GSX1400 » Tue Feb 15, 2005 4:43 am

OK Time for a Homer

D'OH

Please look carefully at your extensions section of PHP.INI

If you look, you will see a line extension=php_mysql.dll, which when uncommented will add the mysql extension into PHP

HOWEVER, PHP INI DOES NOT COME WITH MYSQLI as an extnsion in the list.

Add the following line below the extensions

extension=php_mysqli.dll

Make sure you have mysqli.dll in your extensions directory

stop and re-start your server and it should all go. . . it did for me.

create a file called phpinfo.php in your web server's document directory and put the following in it

<?php
phpinfo();
?>

Somehere in the resultant list you should see a mysqli entry simialr to the following. .

mysqli
MysqlI Support enabled
Client API version 4.1.7
MYSQLI_SOCKET /tmp/mysql.sock

Directive Local Value Master Value
mysqli.default_host no value no value
mysqli.default_port 3306 3306
mysqli.default_pw no value no value
mysqli.default_socket no value no value
mysqli.default_user no value no value
mysqli.max_links Unlimited Unlimited
mysqli.reconnect Off Off



yet again D'OH!

Question
Is it necessary to have both mysql and mysqli loaded?
GSX1400
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Feb 15, 2005 4:17 am


Return to PHP Installation

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron