LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-17-2003, 11:44 PM   #1
lynger
Member
 
Registered: Nov 2003
Posts: 36

Rep: Reputation: 15
php and mysql


hi

im using openna linux and im hving problm how to connect php4 to mysql. i'v check the configurations and many times to some books but it stil dosnt display the results i needed.

here i tested if im really connected to the localhost database but unfortunately no display.

<html>
<title>test</title>
<body>



<?php

$db = mysql_connect("localhost", "username", "mypass") or die("could not connect:" . mysql_error()) ;
echo "link is ".$db;


?>

</body>
</html>



pls. help.. maybe some advices or tips i might need. thnk you for your time

lyn
 
Old 11-18-2003, 12:26 AM   #2
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
There are lots of things that could be wrong. And your post doesn't really give many clues. Is mysql running? Is it configured? How about apache? Will it process other php files?

The only thing I could suggest is opening the following php file to see if php is even configured for mysql, or if apache is configured for php:
Code:
<?php
phpinfo();
?>
Look at the page to see if there is something like this:
'--with-mysql=shared,/usr'
in the Configure Command section.

You have to post some more info about how you installed & configured php, mysql, and apache, otherwise we have no way of knowing what you need to do.

Enjoy!
--- Cerbere
 
Old 11-19-2003, 12:09 AM   #3
lynger
Member
 
Registered: Nov 2003
Posts: 36

Original Poster
Rep: Reputation: 15
hi,

I'm sory for the lack of details. but my answer is yes.. mysql-3.23 is configured and running, apache-2.0 server is configured and running. php is conifured.. and i got these result running phpinfo():

./configure' '--host=i686-pc-linux-gnu' '--build=i686-pc-linux-gnu' '--target=i686-openna-linux' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--prefix=/usr' '--with-layout=GNU' '--with-config-file-path=/etc/httpd' '--with-apxs2=/usr/sbin/apxs' '--with-exec-dir=/usr/bin' '--with-openssl' '--with-zlib' '--with-bz2' '--with-gd' '--with-ttf' '--with-png' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-freetype-dir=/usr' '--with-expat-dir=/usr' '--with-gmp' '--with-xml' '--with-curl' '--with-mm' '--with-imap=shared' '--with-imap-ssl' '--with-pspell' '--with-gettext' '--with-mysql=shared,/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-pgsql=shared' '--with-ldap=shared' '--with-pear' '--disable-static' '--disable-debug' '--disable-rpath' '--disable-posix' '--disable-tokenizer' '--enable-discard-path' '--enable-safe-mode' '--enable-magic-quotes' '--enable-bcmath' '--enable-dio' '--enable-gd-native-ttf' '--enable-sysvsem' '--enable-sysvshm' '--enable-sockets' '--enable-track-vars' '--enable-wddx' '--enable-inline-optimization' '--enable-memory-limit'

php.ini


[MySQL]
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket = /var/lib/mysql/mysql.sock
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 0
mysql.trace_mode = Off

httpd.conf
Dynamic Shared Object (DSO) Support
#
LoadModule access_module modules/mod_access.so
#LoadModule auth_module modules/mod_auth.so
#LoadModule auth_dbm_module modules/mod_auth_dbm.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule file_cache_module modules/mod_file_cache.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule ssl_module modules/mod_ssl.so
LoadModule mime_module modules/mod_mime.so
#LoadModule dav_module modules/mod_dav.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
#LoadModule actions_module modules/mod_actions.so
#LoadModule speling_module modules/mod_speling.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule perl_module modules/mod_perl.so
LoadModule php4_module modules/libphp4.so


---pls. help.. : (

Last edited by lynger; 11-19-2003 at 01:09 AM.
 
Old 11-19-2003, 02:12 AM   #4
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
I think you need to edit your php.ini file. The line:

mysql.connect_timeout = 0

should be:

mysql.connect_timeout = -1

for no limit. A value of 0 means it times out in 0 seconds.

Enjoy!
--- Cerbere
 
Old 11-19-2003, 03:04 AM   #5
lynger
Member
 
Registered: Nov 2003
Posts: 36

Original Poster
Rep: Reputation: 15
hi Cerbere

you're right about 0 and -1 but unfortunately it stl dosnt work.. i get no results or error using this:


<html>
<title>test</title>
<body>

<?php
define ('DB_USER', 'user1');
define ('DB_PASS', 'password');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'mydb');


$db = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('could not connect ' . mysql_error()) ;
mysql_select_db(DB_NAME) or die('could not connect to database ' . mysql_error());
$sql = "Select Username from Customer";
$result = mysql_query("$sql");
echo "Results are $result<br>\n";

?>
</body>
</html>
 
Old 11-19-2003, 05:02 AM   #6
slizadel
LQ Newbie
 
Registered: Jun 2003
Distribution: RH9, Gentoo, Slack
Posts: 23

Rep: Reputation: 15
When you say that you get no results or error, are you not recieving any output from the code, or are you simply not receiving the desired ouput from the code?

Quote:
echo "Results are $result<br>\n";
If apache and php are properly configured to work together, the code should at least return: Results are
 
Old 11-19-2003, 06:45 PM   #7
lynger
Member
 
Registered: Nov 2003
Posts: 36

Original Poster
Rep: Reputation: 15
hi

yes.. i dont get any result from the code above, at least i'm expecting an error to show if im not connectd to the db or its result if connectd.. but when i test phpinfo() i get the desired result (description of php) which tells me that php and apache are working.. On the side of mysql, the database is been used for months now. priviledges, users and passwords are set.

could i pls ask a sample copy of php.ini, httpd.conf ? thank you for your time
 
Old 11-20-2003, 12:30 AM   #8
lynger
Member
 
Registered: Nov 2003
Posts: 36

Original Poster
Rep: Reputation: 15
hi forum

i know found out the problm ( but not yet solve : ( ), i enabled log_errors to see some log files and there i came out an error after restarting httpd.
error: Unable to load dynamic library /usr/lib/php4/mysql.so

den i get an eror: PHP fatal error Call to undefined function mysql_connect()


it seems im missing mysql.so ...pls. help
 
Old 11-21-2003, 05:15 AM   #9
DirtDart
Member
 
Registered: Nov 2003
Distribution: Mandrake 10.1/Solaris 10 (sparc)
Posts: 96

Rep: Reputation: 16
Quote:
den i get an eror: PHP fatal error Call to undefined function mysql_connect()
You need to install the php-mysql package.
 
Old 11-21-2003, 06:30 AM   #10
lynger
Member
 
Registered: Nov 2003
Posts: 36

Original Poster
Rep: Reputation: 15
hi

sorry again for the lack of details.. if you have read above , php mysql and apache are installed.. so after restarting httpd i get an error saying "Unable to load dynamic library /usr/lib/php4/mysql.so "

so i get on testing by browsing my index.php where i get an error "PHP fatal error Call to undefined function mysql_connect()" in the log files..

thnx for your time
 
Old 11-21-2003, 10:02 AM   #11
_KDF
Member
 
Registered: Oct 2003
Distribution: FC4/5 & RHEL4
Posts: 133

Rep: Reputation: 15
Is the file even there ? do as root

updatedb

then (as any user)

locate mysql.so

and post the results.
 
Old 11-21-2003, 09:12 PM   #12
lynger
Member
 
Registered: Nov 2003
Posts: 36

Original Poster
Rep: Reputation: 15
hi..

the result(s) i had.... /var/lib/mysql/mysql.sock
 
Old 11-22-2003, 01:42 AM   #13
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
So, we're back to one of the questions from my first post: How did you install PHP (and mySQL and Apache)? I'm not familiar with openna Linux. Does it have some sort of package system, or did you install from source? It seems as if the install wasn't complete. You may have to reinstall PHP, paying particular attention to any configure options that deal with mySQL. For example:

./configure --with-mysql=/usr/local/mysql

Enjoy!
--- Cerbere
 
Old 11-23-2003, 11:31 PM   #14
lynger
Member
 
Registered: Nov 2003
Posts: 36

Original Poster
Rep: Reputation: 15
hi Cerbere : )

I installed all the packages via RPM's which came with the installer cd..

# rpm -Uvh php-4.0......

really not using tar files.. but as you've seen in the results from phpinfo(), there's the line your wanting to see..


gettext' '--with-mysql=shared,/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-pgsql=shared' '--with-ldap=shared'


..Gee.. i really had a hard time working with php Maybe i'l try reinstalling the package from start.. Is there an installer( rpm or tar files ) you could send me ??

thank you for you time..
 
Old 11-24-2003, 03:22 AM   #15
lynger
Member
 
Registered: Nov 2003
Posts: 36

Original Poster
Rep: Reputation: 15
hi forum

At last.. php and mysql are working well.. thank you all for your help..

more power forum..



---- after i reinstalled all the packages.. it worked wel..

Last edited by lynger; 11-26-2003 at 06:32 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
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
Installing MySQL.4.0.17 and php support for Mysql on RedHat 9.0 Neha Linux - Software 13 12-29-2003 12:06 AM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 08:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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