LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-30-2003, 12:59 PM   #1
Greenman
Member
 
Registered: Jan 2003
Posts: 34

Rep: Reputation: 15
Question Getting PHP to talk to MySql ?


System Redhat8 MySql 3.23.53 PHP 4.2.2
I am unable to get PHP to pass data to MySql
I gett the following error when I run the scrypt below in a browser

Fatal error: Call to undefined function:
mysql_connect() in /var/www/html/test1.php3 on line 2

<?php
$link = mysql_connect("localhost", "user", "password")
or die("Could not connect");
print ("Connected successfully");
mysql_close($link);
?>

The odd thing is that I can run PHPMyAdmin fine and manage my databaseds logging in as this user.

Any ideas????

Last edited by Greenman; 01-31-2003 at 05:37 AM.
 
Old 01-30-2003, 01:19 PM   #2
Wolven
Member
 
Registered: Jan 2003
Posts: 195

Rep: Reputation: 30
Have you made sure that the php module line is uncommented in apache's configuration file?

Once you do this, you will have to restart apache, of course.


Did you use an RPM, or compile from source? If you compile from source, you usually need to have either dynamic modules available, or support for php built in there from the beginning.

Let me know, and I'll respond further.
 
Old 01-30-2003, 01:51 PM   #3
dleone
LQ Newbie
 
Registered: Jan 2003
Posts: 13

Rep: Reputation: 0
I have the same issue; I don't even see a php module in my httpd.conf file. Could you please copy and paste this section?

(I am running the same version RH and PHP. I have posted a separate question on this forum earlier today.
 
Old 01-30-2003, 02:47 PM   #4
Wolven
Member
 
Registered: Jan 2003
Posts: 195

Rep: Reputation: 30
Sorry, I should have done that from the beginning.
Mine looks like this.



LoadModule php4_module /usr/lib/apache/1.3/libphp4.so


and it goes in my /etc/apache/httpd.conf file, amidst all the rest of the LoadModules.


You might want to search your hard drive and see if that file is there


the command would look something like this (as root)


find / -name "libphp*.so"

If you see it in a different spot, modify the above directory (/usr/lib/apache/1.3) to match yours.
 
Old 01-30-2003, 02:50 PM   #5
dleone
LQ Newbie
 
Registered: Jan 2003
Posts: 13

Rep: Reputation: 0
Thanks!!
 
Old 01-30-2003, 03:03 PM   #6
dleone
LQ Newbie
 
Registered: Jan 2003
Posts: 13

Rep: Reputation: 0
Wolven - I'll do this tonight and restart httpd. BTW - php NOT accessing MySQL works fine now even (printing Hello World, etc.) just the MySQL stuff doesn' twork.
 
Old 01-30-2003, 03:27 PM   #7
Wolven
Member
 
Registered: Jan 2003
Posts: 195

Rep: Reputation: 30
Take a quick look at this page, and tell me if any of this seems wrong/right with what you did.


http://logidac.com/apache/apache-install-rpm.phtml



The main thing I'm asking here, is did you compile php with support for MySQL ?
 
Old 01-30-2003, 03:44 PM   #8
dleone
LQ Newbie
 
Registered: Jan 2003
Posts: 13

Rep: Reputation: 0
UH oh. I just used the package manager to install the RPMs - nothing of that nature...
 
Old 01-31-2003, 05:35 AM   #9
Greenman
Member
 
Registered: Jan 2003
Posts: 34

Original Poster
Rep: Reputation: 15
Hi

I have had a look in httpd.conf
and when I put in the line

LoadModule php4_module modules/libphp4.so

and restart Apache I get the following error

[warn] module php4_module is already loaded, skipping

so i have remed out this line

oddly I can run PHPmyAdmin fine so PHP is talking to MySQL to an extent??


G
 
Old 01-31-2003, 10:41 AM   #10
Wolven
Member
 
Registered: Jan 2003
Posts: 195

Rep: Reputation: 30
Seems it's already in there.. hrmm..

Okay, let's check this now. Make sure you have

extension=mysql.so

in your php.ini file.

Check your extension_dir under there as well.

You can run the above command to find the mysql.so file if you need.


find / -name mysql.so

Let me know, I'll keep trying to help!
 
Old 01-31-2003, 11:58 AM   #11
Greenman
Member
 
Registered: Jan 2003
Posts: 34

Original Poster
Rep: Reputation: 15
Hi Wolven

It is in /usr/lib/php4/mysql.so

The last thing I have tried is
downloaded php-4.3.0 and ran

./configure --with-mysql (I didnít run --apxs as I donít think I need this??)
make
make install
copied php.ini-dist to php.ini
and checked this line in there
extensions=mysql.so

phpinfo runs fine.

But when I run php -m I am missing my
mysql module

I have tried running php-mysql-4.2.2-8.0.5.i386 again but it says that this package is already installed.

do you know how I can remove this and reinstall
I have tried running rpm -e php-mysql but no joy
 
Old 02-01-2003, 02:39 PM   #12
dleone
LQ Newbie
 
Registered: Jan 2003
Posts: 13

Rep: Reputation: 0
I found the answer:
First issue this command:

rpm -qa|egrep "mysql|php"

This is some of what you should see...'

php-ldap-4.2.2-8.0.5
mysql-3.23.52-3
php-imap-4.2.2-8.0.5
mysql-server-3.23.52-3
php-pgsql-4.2.2-8.0.5

php-mysql-4.2.2-8.0.5 <<<-----------------IF you dont have this in the list, then put CD #3 and issue this command:

rpm -ivh php-mysql-4.2.2-8.0.5.i386.rpm

restart apach and viola' - php-mysql-city !
 
Old 02-28-2003, 03:40 PM   #13
vcheah
Member
 
Registered: Nov 2001
Distribution: redhat 8.0
Posts: 110

Rep: Reputation: 15
I tried
rpm -ivh php-mysql-4.2.2-8.0.5.i386.rpm


and I got response of
warning: php-mysql-4.2.2-8.0.5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: Failed dependencies:
mysql is needed by php-mysql-4.2.2-8.0.5
libmysqlclient.so.10 is needed by php-mysql-4.2.2-8.0.5
Suggested resolutions:
mysql-3.23.52-3.i386.rpm

then i used the Suggested Resolutions

rpm -ivh mysql-3.23.52-3.i386.rpm
warning: mysql-3.23.52-3.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: Failed dependencies:
perl-DBD-MySQL is needed by mysql-3.23.52-3
Suggested resolutions:
perl-DBD-MySQL-2.1017-3.i386.rpm

not giving up i try
rpm -ivh perl-DBD-MySQL-2.1017-3.i386.rpm
warning: perl-DBD-MySQL-2.1017-3.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: Failed dependencies:
libmysqlclient.so.10 is needed by perl-DBD-MySQL-2.1017-3
Suggested resolutions:
mysql-3.23.52-3.i386.rpm

then now back to the suggested resolution again
what should i do
 
Old 02-28-2003, 04:39 PM   #14
TruckStuff
Member
 
Registered: Apr 2002
Posts: 498

Rep: Reputation: 30
Just get the PHP source code and compile and install it that way. Its practially idiot-proof (even I can do it. ):

gunzip php-4.3.0.tar.gz
tar -xvf php-4.3.0.tar
cd php-4.3.0
./configure --with-mysql --apxs
make
make install

Then READ THE PHP INSTALLATION FILE! There is a section in there telling you what to add to httpd.conf to make it work w/ Apache.
 
Old 02-28-2003, 05:01 PM   #15
vcheah
Member
 
Registered: Nov 2001
Distribution: redhat 8.0
Posts: 110

Rep: Reputation: 15
My root problem. problem of all problem is

./httpd restart
Stopping httpd: [ OK ]


Starting httpd: Syntax error on line 6 of /etc/httpd/conf.d/auth_mysql.conf:
Cannot load /etc/httpd/modules/mod_auth_mysql.so into server: libmysqlclient.so.10: cannot open shared object file: No such file or directory [FAILED]



do you thing i should reinstall the php?

Last edited by vcheah; 02-28-2003 at 05:04 PM.
 
  


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 On
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 04:49 PM
Domo and mysql wont talk linux_console Linux - Software 0 08-08-2004 10:50 PM
php wont talk to postgresql Pete Dogg Linux - General 1 09-10-2003 08:20 PM
php wont talk to postgresql Pete Dogg Linux - Software 0 09-10-2003 04:16 PM
getting php and mysql to talk! modestmouse Programming 4 04-04-2003 12:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:39 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