logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: mysqli works on command line but not in Apache
Author
rlecessi



Joined: 18 May 2015
Posts: 4
Location: United States,Princeton

PostPosted: Mon 18 May '15 12:02    Post subject: mysqli works on command line but not in Apache Reply with quote

The following .php script works when I execute php from the
DOS prompt, but not from a Web browser:

<?php
$mysqli = new mysqli("my_ip_address", "root", "my_password",
"chapter7");
echo $mysqli->host_info . "\n";
$mysqli->real_query("SELECT name FROM hero");
$res = $mysqli->use_result();
while ($row = $res->fetch_assoc()) {
echo " name = " . $row['name'] . "\n";
}
?>

DOS>..\php connectMe.php
my_ip_address via TCP/IP
name = Green Lantern <- WORKS
name = Superman

But when I browse connectMe.php I get:

Fatal error: Class 'mysqli' not found in C:\Apache24\htdocs\CH8\connectMe.php on line 3

From PHP.ini:

extension_dir ="C:\PHP\ext"
extension=c:/php/ext/php_mysql.dll
extension=c:/php/ext/php_mysqli.dll
extension=c:/php/ext/php_pdo_mysql.dll

I copied libmysql.dll from MySQL to Apache\bin as per
Tue 13 Feb '07 Post (Apache mysqli installation problem),
but still not working.

Platform:
Apache 2.4.12 win32 VC11 update 4
PHP Version 5.6.7
MySQL Server 5.6
Windows 7 Ultimate Edition Service Pack 1) i586

Thanks in advance.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Tue 19 May '15 17:43    Post subject: Reply with quote

create a script with

Code:

<?php
phpinfo();


in your document folder open it via url in your browser and see which php.ini is loaded.
Back to top
rlecessi



Joined: 18 May 2015
Posts: 4
Location: United States,Princeton

PostPosted: Wed 20 May '15 12:19    Post subject: Reply with quote

Thank you James.

The loaded configure command was as expected
(C:\PHP\php.ini).

I've posted the results at
http://www.ralphlecessitutor.com/phpinfo.pdf .
Please let me know if anything looks incorrect.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Wed 20 May '15 17:03    Post subject: Reply with quote

Well

it seems mysql and mysqli are not enabled

change in your php.ini

Code:

;extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_pdo_mysql.dll


to

Code:

extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
Back to top
rlecessi



Joined: 18 May 2015
Posts: 4
Location: United States,Princeton

PostPosted: Thu 21 May '15 3:51    Post subject: Reply with quote

Thank you James.

I was unable to find evidence of this in the phpinfo.
Could you help me find it?

I posted the php.ini specified by "loaded configuration file"
at http://www.ralphlecessitutor.com/php_ini.pdf.

I found the following at lines 890-895

extension=c:/php/ext/php_mysql.dll
extension=c:/php/ext/php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
extension=c:/php/ext/php_openssl.dll
;extension=php_pdo_firebird.dll
extension=c:/php/ext/php_pdo_mysql.dll

What am I missing?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 21 May '15 10:25    Post subject: Reply with quote

Did you restart apache? Cause these modules / extensions are not loaded!

See my phpinfo https://www.apachehaus.de/media/php_info.pdf

You will find a section with mysql and another one with mysqli
Back to top
rlecessi



Joined: 18 May 2015
Posts: 4
Location: United States,Princeton

PostPosted: Fri 22 May '15 3:02    Post subject: Reply with quote

Looks like httpd -k restart doesn't update the extensions.
I stopped and started the Apache2.4 service in Windows Task
Manager (this gave Apache a new PID, which did not happen
during the restart). When I was done, the phpinfo looked like yours and the mysqli program worked in Apache.

Thank you so much for your help! Very Happy
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 22 May '15 14:23    Post subject: Reply with quote

Do not kill apache in the taskmanager. If you have installed it as a service

use

httpd -k stop
and
httpd -k start
Back to top


Reply to topic   Topic: mysqli works on command line but not in Apache View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules