LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-03-2003, 12:22 PM   #1
modestmouse
LQ Newbie
 
Registered: Apr 2003
Location: Denver, CO
Distribution: RH 8
Posts: 3

Rep: Reputation: 0
Unhappy getting php and mysql to talk!


PLEASE EXCUSE THE HUGE POST. I AM TRYING TO BE AS SPECIFIC AS POSSIBLE...ALTHOUGH I'M PROBABLY STILL LEAVING SOMETHING OUT! HAHAHA

Hello all. I'm very new to the Linux world and loving it...although the transition from the windows world has been frustrating at times. I'm also even newer to PHP and MySQL. Here is the situation I need help with, which I've been researching in this site and many others for a looooooong time now.

I am trying to get a product called PHProjekt out of Germany (which uses a LAMP configuration) up and running so my company can share contacts, schedules, tasks, and other info with the ability to modify tables to our specific needs. I have looked at probably 70-80 contact managers, including LDAP and this one seems like a great product and the best for our business. Anyway, I have RH 8.0 up and running with MySQL 4.0, PHP 4.2, and apache 2.0.

PLEASE NOTE: I tried the following with the old version of MySQL that comes with RH 8 and installed the php-mysql rpm and still couldn't get it to work.
I have the PHP and Apache running correctly I think as I'm able to see the server from my work station's browser including the phpinfo file. I tried writing a sample script that tests a connection to a MySQL database, which I copied out of Wrox Publishing's "Beginning PHP4" book. After I create the script file, save it in my /var/www/html directory, and try to get it to work in my browser, I get the following error:

Fatal error: Call to undefined function: mysql_connect() in /var/www/html/connect.php on line 4

Line 4 in my script is:
$link_id = mysql_connect("homer", "phpuser", "phpass");

In my phpinfo file, which I can bring up in my browser, the configuration section for mysql has '--with-mysql=shared,/usr'

The path to the mysql database looks wrong to me and/or I need to recompile php to use mysql. I have downloaded the new php 4.3.1 and did:

./configure --with-mysql=/usr/include/mysql/mysql.h

and everything seemed to go in fine. (note: I tried the above by just pointing to the directory [mysql]and it gave me an error saying missing header files or something similar, so I pointed it to the actual header file and it worked) Then I tried to do a make and a make install and PHP did not want to install...no error messages but a bunch of repeated paragraphs of text jumble went up on the screen and never ended...until I cancelled it.

So, if any one can point me in the right direction with a scenerio of what I just described (RH 8.0, mysql 4.0, php 4.2.2...although I have downloaded the new php 4.3.1, and apache 2.0), that would make a very frustrated newbie incredibly happy!

A couple of other notes: When I installed the mysql 4.0, I installed the rpm from my /usr/local directory...not sure if that makes a bit of difference or not?? I have looked on the web and found some stuff for a LAMP configuration...but nothing specific to RH 8.0, so if anyone knows of one, please post a link.

Whew! If you've read this entire post, thanks! And if anyone can help out, you ROCK!
 
Old 04-03-2003, 12:41 PM   #2
Unseen
Member
 
Registered: Feb 2003
Distribution: debian
Posts: 56

Rep: Reputation: 15
Can you change the line:

$link_id = mysql_connect("homer", "phpuser", "phpass");

to

$link_id = mysql_connect("homer", "phpuser", "phpass") or die("MySQL Error No.".mysql_errno().": ".mysql_error());

This will give a verbose explanation of the error.

Also, be sure you are selecting a database to use. You should have a line in there someplace that says:

$default_dbname = "super database of destruction";
mysql_select_db($default_dbname, $link_id);

Let us know what the full description of the error is.

Also, there should be a simple example script in the book to make sure the connection to your database works. You may want to run that to make sure you can connect properly. If it doesn't have an example, I can post one for you.
 
Old 04-03-2003, 02:31 PM   #3
modestmouse
LQ Newbie
 
Registered: Apr 2003
Location: Denver, CO
Distribution: RH 8
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for the reply Unseen.

The sample script in the book that I am trying out is as follows (with your added line to output the error included):

<?php
//list_db.php

$link_id = mysql_connect ("homer", "phpuser", "phpass") or die("MySQL Error No.".mysql_errno().": ".mysql_error());
$result = mysql_list_dbs($link_id);
$num_rows = mysql_num_rows($result);

while($db_data = mysql_fetch_row($result)) {
echo $db_data[0]. "<BR>";
$result2 = mysql_list_tables($db_data[0]);
$num_rows2 = mysql_num_rows(result2);
while($table_data = mysql_fetch_row($result2)) echo "--" .
$table_data[0]. "<BR>";
echo "==> $num_rows2 table(s) in " . $db_data[0] . "<P>";
}
?>

The above script lists all databases available and tables in each of them. Even with the error output line added I still get this error:

Fatal error: Call to undefined function: mysql_connect() in /var/www/html/connect.php on line 4

If you know of another simple example script, I would love to try it.

Thanks!

Last edited by modestmouse; 04-03-2003 at 02:41 PM.
 
Old 04-04-2003, 06:17 AM   #4
Unseen
Member
 
Registered: Feb 2003
Distribution: debian
Posts: 56

Rep: Reputation: 15
Is that a space you have between the mysql_connect and the (?

You should not have a space, it might just be as simple as that.
 
Old 04-04-2003, 11:32 AM   #5
modestmouse
LQ Newbie
 
Registered: Apr 2003
Location: Denver, CO
Distribution: RH 8
Posts: 3

Original Poster
Rep: Reputation: 0
The script that I typed on the server actually didn't have a space in it...my last post I re-typed it up really fast. I'm going to re-install RH 8 again (this time with the mysql and php that come with the distro) and also install the php-mysql package and see if that will work.

Have any of you out there that are reading this set up a LAMP configuration on RH 8? I'm trying to follow the RH 8 Bible's instructions for getting all of these parts running but if anyone could explain the steps to accomplishing a LAMP on RH that would help out a frustrated newbie tremendously! Thanks.
 
  


Reply


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 438 and mysql 41 fedora 2 wont talk phoebebright Linux - Software 0 11-02-2004 03:49 PM
Domo and mysql wont talk linux_console Linux - Software 0 08-08-2004 09:50 PM
Getting PHP to talk to MySql ? Greenman Linux - General 19 10-01-2003 02:49 PM
php wont talk to postgresql Pete Dogg Linux - General 1 09-10-2003 07:20 PM
php wont talk to postgresql Pete Dogg Linux - Software 0 09-10-2003 03:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:35 PM.

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