Question on MySQL and PHP

Hi,

I am trying to write a page in PHP3 running on my Redhat 6.1. I have Apache 1.3.9, MySQL 3.22.27 and PHP 3.0.12 running ok. However, when I want to the following code running my Linux:


=======================================
<?php

$db = mysql_connect('localhost', 'root','');

mysql_select_db("mydb",$db);

$result = mysql_query("SELECT * FROM employees",$db);

printf("First Name: %s<br>\n", mysql_result($result,0,"first"));

printf("Last Name: %s<br>\n", mysql_result($result,0,"last"));

printf("Address: %s<br>\n", mysql_result($result,0,"address"));

printf("Position: %s<br>\n", mysql_result($result,0,"position"));

?>
=======================================

I have the following error:

=======================================
Fatal error: Call to unsupported or undefined function mysql_connect() in /home/httpd/html/php/showdb.php3 on line 11
=======================================

It seems that I need to do connections for the PHP an MySQL.  However, most of the document I found on the web just teaching me install and recompile the php3 and mysql from scratch. Do I really need to do it? Can I just change some config file and restart the services? If yes, which file I should change.

I would be appreciated if there is a step by step instruction for!

Thanks

Joe


fokchiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fokchiAuthor Commented:
Adjusted points to 150
0
feenixCommented:
Have you installed the PHP-mysql module and configured it in the php3.ini? PHP might not use the MySQL module by default, and if that is the case, it would give the error you described.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fokchiAuthor Commented:
hi feenix,

Can you tell me how to install the MySQL module? Where I can I find it and how to install it?

Thanks,
0
feenixCommented:
Seems like there is no MySQL module for PHP in the RedHat 6.1 CD, strange. But I did find the module from a few places, one is ftp://ftp.muni.cz/pub/linux/local/redhat-cz/6.1/local/RPMS/php-mysql-3.0.12-8cs.i386.rpm

Just install it (rpm -i package), and then open your /etc/httpd/conf/php3.ini. There should be a section names Dynamic Extensions. There should read:
extension=mysql.so

Then your MySQL module should work okay.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.