Author |
|
rlecessi
Joined: 18 May 2015 Posts: 4 Location: United States,Princeton
|
Posted: Mon 18 May '15 12:02 Post subject: mysqli works on command line but not in Apache |
|
|
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
|
Posted: Tue 19 May '15 17:43 Post subject: |
|
|
create a script with
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
|
Posted: Wed 20 May '15 12:19 Post subject: |
|
|
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
|
Posted: Wed 20 May '15 17:03 Post subject: |
|
|
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
|
Posted: Thu 21 May '15 3:51 Post subject: |
|
|
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
|
Posted: Thu 21 May '15 10:25 Post subject: |
|
|
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
|
Posted: Fri 22 May '15 3:02 Post subject: |
|
|
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! |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Fri 22 May '15 14:23 Post subject: |
|
|
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 |
|