Trying to setup PHP on apache keep getting errors....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

user51564
Forum Newbie
Posts: 16
Joined: Sun Apr 30, 2006 3:39 pm
Location: Ok
Contact:

Trying to setup PHP on apache keep getting errors....

Post by user51564 »

Server Version: Apache/2.0.55 (Win32) DAV/2 mod_gzip/2.1.0 mod_ssl/2.0.47 OpenSSL/0.9.7b PHP/5.1.2

most scripts won't run ... get errors like this ... :
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache

Group\Apache2\htdocs\dk\lib.php on line 55

Notice: Undefined index: style in C:\Program Files\Apache Group\Apache2\htdocs\dice\dice.php

on line 3

Notice: Undefined index: dice in C:\Program Files\Apache Group\Apache2\htdocs\dice\dice.php

on line 4

Warning: getimagesize(styles/style/1.png) [function.getimagesize]: failed to open stream: No

such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\dice\dice.php on line

8

Fatal error: Call to undefined function ImageCreate() in C:\Program Files\Apache

Group\Apache2\htdocs\dice\dice.php on line 14


don't have ssl setup yet can't get apache to find a good server.crt...please help!!!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

PHP 5 doesn't have MySQL built-in. You'll need to uncomment the line for it in the extensions list, same goes for GD.
user51564
Forum Newbie
Posts: 16
Joined: Sun Apr 30, 2006 3:39 pm
Location: Ok
Contact:

I don't understand what i need to do....

Post by user51564 »

I'm a newbee at php...i've got perl down but i am just learning mysql and php... please explain in detail for me what to do...i can't figure it out any further...thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

in your php.ini, you'll notice there is a list of extensions that will be loaded.

Some of them have a # before their name, which means they are commented and will not be loaded.
You will find both the mysql and gd extensions are commented out.

Once you have done this, save, and restart apache.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

In my php.ini file the extensions are commented using semicolons ( ; ). You can usually uncomment the line of the extension that you want to use by removing the semicolon in front of it...

Code: Select all

;remove the semicolon from behind the following line
;extension=php_mysql.dll

; Or, for linux machines it might be a .so
;extension=mysql.so
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

(assuming your OS is Win)
After doing what the guys here suggested you, make a phpinfo file and view it with your broswer and check for "Configuration File (php.ini) Path". If it set to something like 'C:\WINDOWS\' then that's not good and you'll need to put the php.ini file in your windows directory and then restart Apache. After that, go to the phpinfo file again and you should see 'C:\WINDOWS\php.ini'. Now all you've got to do is to put the file 'libmysql.dll' in your system directory - that would be 'system32' if you run Win xp or 'system' if you run Win 98.
user51564
Forum Newbie
Posts: 16
Joined: Sun Apr 30, 2006 3:39 pm
Location: Ok
Contact:

still have one error left....

Post by user51564 »

i did all you guys said to do and i still have one more error with mysql....:
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\chess\createtables.php on line 7
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Post your php.ini file. Specifically the section on the extensions. What OS are you on?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Everah wrote:Post your php.ini file. Specifically the section on the extensions. What OS are you on?
The posted error would say Windows. :)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

:lol: Hah! Oh baby, I am amused at my inability to read a freakin' post sometimes. Sorry about that. C:... I try not to see colons, it just sounds nasty....

Anyway, to OP, do have the php_mysql.dll file in your c:\PHP\ext\ folder? Make sure that is there, make sure the line that loads the module is uncommented (and make sure you are uncommenting the mysql line, not the mysqli line), restart apache then run your test script.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Another thing you should do, too, is check which extensions are loaded in your PHP install. This might shed a little more light on the situation. Try running a print_r(get_loaded_extensions)) and see what tells you.
user51564
Forum Newbie
Posts: 16
Joined: Sun Apr 30, 2006 3:39 pm
Location: Ok
Contact:

This is what i got...

Post by user51564 »

Array ( [0] => bcmath [1] => calendar [2] => com_dotnet [3] => ctype [4] => date [5] => ftp [6] => iconv [7] => odbc [8] => pcre [9] => Reflection [10] => session [11] => libxml [12] => standard [13] => tokenizer [14] => zlib [15] => SimpleXML [16] => dom [17] => SPL [18] => wddx [19] => xml [20] => xmlreader [21] => xmlwriter [22] => apache2handler )
looks like its not loading mysql...why?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I found this function for loading extensions at runtime in the PHP manual.

Code: Select all

<?php
// Example loading an extension based on OS
if (!extension_loaded('sqlite')) {
   if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
       dl('php_sqlite.dll');
   } else {
       dl('sqlite.so');
   }
}

// Or, the PHP_SHLIB_SUFFIX constant is available as of PHP 4.3.0
if (!extension_loaded('sqlite')) {
   $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
   dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX);
}
?>
Maybe try this for the 'mysql' extension. Also, did you make sure that you have the php_mysql.dll in your C:\php\ext folder?
user51564
Forum Newbie
Posts: 16
Joined: Sun Apr 30, 2006 3:39 pm
Location: Ok
Contact:

ok...something is wrong with php.ini

Post by user51564 »

it's not loading any of the ext i select...i think it is useing another php.ini than the one i'm editing...maybe something in the apache conf...idon't know...please help...
User avatar
php3ch0
Forum Contributor
Posts: 212
Joined: Sun Nov 13, 2005 7:35 am
Location: Folkestone, Kent, UK

Post by php3ch0 »

after installing on my machine php.ini is in C:/windows
Post Reply