Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-13-2006, 11:06 PM   #1
Registered: Oct 2005
Location: Bangladesh
Posts: 497

Rep: Reputation: 30
Lightbulb Php and Mysql

Dear Friends ,

I have completed my PHP configuration in my "Redhat Linux Enterprise Edition 4" using the following built in RPM's :

1)http/apache server
2)PHP v 3
3)PHP-Mysql v 3
Now i make a "test.php" file in "/var/www/html" directory .And i am running that page without no problem . In this moment i have a question :

If i want to make a project using PHP and Mysql Then

Is mysql automatically connects with my PHP ? or I need to make change One of a file to connect with PHP & Mysql ?

PLz inform .....
Old 02-13-2006, 11:47 PM   #2
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
If you have the php-mysql RPM installed then you can go ahead an use all the mysql_ functions in PHP.
Old 02-14-2006, 02:56 AM   #3
Registered: Jan 2005
Location: Finland
Distribution: Suse 10, Suse-factory , RHEL4, SLES9, SLED10
Posts: 380

Rep: Reputation: 30
If you have that php-mysql package installed, MySql is available, but you will still need to connect to the database.
I would use atleast php version4 and Mysql version 4 or higher versions because all those needed functions are not surely present at earlier versions.

Here is example code to connect and use Mysql
We tell php what database to use and give information about database user.
Then we select information from table named "users".

PHP Code:

function makeConnection() {

$connect mysql_connect($dbhost$dbusername$dbpassword);
mysql_select_db($dbname$connect) or die ("Could not select database");


$connect makeConnection();

$query "SELECT username, alias, real_name, text, mail FROM users";

$result mysql_query($query$connect);

$row mysql_fetch_assoc($result)) {
$details[] = $row;

$userlist getSomething();

List of MySQL-functions onb PHP :

Last edited by onjoo; 02-14-2006 at 02:59 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
php-mysql dependancy problem after nitemare mysql upgrade. RHEL4 andrewc Red Hat 1 01-03-2006 04:16 PM
mysql-server4.1 and mod php-mysql conflig kernelvn *BSD 0 06-18-2005 11:52 AM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
php4 mysql, installation, php-pages with mysql info stay empty dnla Linux - Software 2 03-14-2004 02:54 PM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 08:59 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration