PHP, Apache and MySQL

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

PHP, Apache and MySQL

Post by clarance »

Moved by moderator to Installation and Configuration

Please Help,

I have dug into the Sams Teach Yourself PHP, MySQL and Apache. I have installed everything on my Windows XP machine and I finally have come to the part where I interact between PHP and MySQL. in this book it uses MySQLi and for some reason I keep getting this error message:

Fatal error: Class 'mysqli' not found in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connection\test.php on line 2

here is my code:

<?php
$myconnect = new mysqli("localhost", "[user]", "[password]", "[database]");

if(mysqli_connect_errno()){
printf("Connection failed: %s\n", mysqli_connect_errno());
exit();
} else {
printf("Host information: %s\n", mysqli_get_host_info(myconnect));
}
?>


I have activated MySQLi in the PHP.ini:

extension=php_mysqli.dll

please if you have some suggestions let me know?

Sincerely,

Bilal Clarance
mmj
Forum Contributor
Posts: 118
Joined: Fri Oct 31, 2008 4:00 pm

Re: PHP, Apache and MySQL

Post by mmj »

If you just activated it you may need to restart Apache.
clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

Re: PHP, Apache and MySQL

Post by clarance »

thanks for your reply, but I also forgot to mention that I restarted my server. sorry!

Bilal
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP, Apache and MySQL

Post by VladSun »

Create a PHP file:

Code: Select all

phpinfo();
search for php.ini string and see whether you are editing the right php.ini - i.e. the one used by Apache.
There are 10 types of people in this world, those who understand binary and those who don't
clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

Re: PHP, Apache and MySQL

Post by clarance »

thank you, you were right I have been editing the file in the htdoc folder, but it says

Configuration File (php.ini) Path C:\WINDOWS

But just one thing when I go into the C:\WINDOWS folder I can't find the PHP.ini file.

any ideas?

Bilal
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP, Apache and MySQL

Post by VladSun »

Search for PHPIniDir string in Apache httpd.conf
Change it to an apropriate file.

On Win server I have:

Code: Select all

PHPIniDir "C:/php"
because the php.ini I want to use is C:/php/php.ini
There are 10 types of people in this world, those who understand binary and those who don't
clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

Re: PHP, Apache and MySQL

Post by clarance »

thanks again for your reply,

but sadly that is the same setting I have in my config file. I am entirely out of reason as to why it should look for the PHP.ini in C:/Windows...? :S

HELP SOMEONE, PLEASE!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP, Apache and MySQL

Post by VladSun »

Did you restart Apache service?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP, Apache and MySQL

Post by VladSun »

clarance wrote:thanks again for your reply,

but sadly that is the same setting I have in my config file. I am entirely out of reason as to why it should look for the PHP.ini in C:/Windows...? :S

HELP SOMEONE, PLEASE!
???

Did you change it to the PATH you want it to be?
There are 10 types of people in this world, those who understand binary and those who don't
clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

Re: PHP, Apache and MySQL

Post by clarance »

I Have the specified path in my apache config file. If you mean the PATH variables, then yes that has been added also.

Worth mentioning though is that when I load my <?php phpinfo() ?> file from the root server and I look in the 'Loaded Configuration file" it says (none) and I believe that it is supposed to say C:/php/php.ini. I have tried all that I can think off and really need this to work so that i can get back to work at home.

Desperate please help??

Sincerely

A developer in need
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP, Apache and MySQL

Post by VladSun »

Could you please post the exact text line you said you have in apache config file:

Code: Select all

PHPIniDir "C:/php"
There are 10 types of people in this world, those who understand binary and those who don't
clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

Re: PHP, Apache and MySQL

Post by clarance »

PHPIniDir "C:/php/"
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP, Apache and MySQL

Post by VladSun »

Do you have a php.ini file in C:\PHP\ ? ;)
There are 10 types of people in this world, those who understand binary and those who don't
clarance
Forum Newbie
Posts: 14
Joined: Sun Nov 23, 2008 10:25 am

Re: PHP, Apache and MySQL

Post by clarance »

yes I do have a php.ini file in C:/php

any other ideas? :)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP, Apache and MySQL

Post by VladSun »

Maybe you have a second PHPIniDir line somewhere else in httpd.conf ...
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply