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???? |
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. |
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. |
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. |
Thanks!!
|
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.
|
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 ? |
UH oh. I just used the package manager to install the RPMs - nothing of that nature...
|
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 |
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! |
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 |
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 ! |
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 |
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. |
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? |
MySql - PHP
Being no expert, uninstalling and reinstalling has been an option for me both in the windows and linux world. Unless someone comes along who can provide a better answer, that is the best I can come up with. Sorry, man.
|
Hi, there.
I tried to install PHP which is expected to be working with mysql. I followed your installation advice above....and when I typed ./configure --with-mysql--apxs it did process something but stopped with the following error message: check for gcc... no check for cc... no configure: error: no acceptable found in $path What did I miss? And how do I rectify the above errors? I'm really a stupid newbie to this. Please help! Cheers. |
you didn't insatll a complier.... nothing to do with php / mysql... you just have no delveopment tools installed at all. install gcc and the may dependencies it has. or just install from rpm.
and i'd advise to serach this site for answers, and not to drage up really old threads, thanks |
AHA! There is a very simple solution to this problem: RedHat 8 for some reason comes with PHP-MySQL support nonfunctional. This error has caused me no small measure of aggravation, BUT: To fix this you need only download a 27kb patch and install it as an RPM. Simple as that. All I need to do is find that patch again...
AHA here it is: http://www.redhat.com/swr/i386/php-m....0.5.i386.html The following is from a Macromedia article concerning Dreamweaver and RedHat 8 with PHP4.2.2: Quote:
|
rpm *does* have the option of putting "--force --nodeps" after it as a parameter, so you can force the install if you are positive that you will be installing the rpms it needs afterwards. This should allow you to bypass your problem of not being able to install the mysql client, which is what the last error you posted was about.
Hope this helps! |
All times are GMT -5. The time now is 12:30 PM. |