LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Getting PHP to talk to MySql ? (https://www.linuxquestions.org/questions/linux-general-1/getting-php-to-talk-to-mysql-43379/)

Greenman 01-30-2003 11:59 AM

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????

Wolven 01-30-2003 12:19 PM

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.

dleone 01-30-2003 12:51 PM

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.

Wolven 01-30-2003 01:47 PM

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.

dleone 01-30-2003 01:50 PM

Thanks!!

dleone 01-30-2003 02:03 PM

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.

Wolven 01-30-2003 02:27 PM

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 ?

dleone 01-30-2003 02:44 PM

UH oh. I just used the package manager to install the RPMs - nothing of that nature...

Greenman 01-31-2003 04:35 AM

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

Wolven 01-31-2003 09:41 AM

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!

Greenman 01-31-2003 10:58 AM

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

dleone 02-01-2003 01:39 PM

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 !

vcheah 02-28-2003 02:40 PM

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

TruckStuff 02-28-2003 03:39 PM

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

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.

vcheah 02-28-2003 04:01 PM

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?


All times are GMT -5. The time now is 12:33 AM.