LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Thread Tools
Old 03-24-2008, 03:00 AM   #1
bjweb
LQ Newbie
 
Registered: Feb 2008
Posts: 3
Thanked: 0
mysql_connect resulting in blank web page


[Log in to get rid of this advertisement]
I recently purchased "build your own databased driven web site using PHP and MYSQL" and have been working though the exercises.

using PHP 5.0.4
mYSQL 4.1.11

from command line mysql appears to do everything that it should ie create dB, INSERT values etc when logged in under root user

Php is intact that is from phpinfo(); and a basic date script provides correct server date time

However the following script is resulting in a blank firefox web page with no error explanation at all

<?php
$link = mysql_connect ('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'connected successfully';
mysql_close($link);
?>

This is straight out of the PHP MYSQL CONNECT MANUAL

I can see no error in the httpd/error-log

Hence I am at a real loss to explain what is wrong

Any help would be appreciated
bjweb is offline     Reply With Quote
Old 03-24-2008, 08:44 AM   #2
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 655
Thanked: 10
Turn on display_errors in your php.ini file and the error will be displayed in the browser.
datopdog is offline     Reply With Quote
Old 03-25-2008, 05:44 AM   #3
bjweb
LQ Newbie
 
Registered: Feb 2008
Posts: 3
Thanked: 0

Original Poster
display_errors now on

Reports the following in the web page

Fatal error. Call to undefined function mysql_connect() in var/www/html/test_connect.php on line 9

line 9 is
$link=mysql_connect('localhost', 'root', 'root_pw');


with all statement rem except for the following

<?php
echo "Hello World";
?>

Displays as expected with no problems

I wonder what the problem is???
bjweb is offline     Reply With Quote
Old 03-25-2008, 05:47 AM   #4
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 655
Thanked: 10
The error is because you do not have the php mysql module installed, what distro are you running ?
datopdog is offline     Reply With Quote
Old 03-25-2008, 09:41 AM   #5
simplicissimus
Registered User
 
Registered: Mar 2008
Posts: 104
Thanked: 0
php-mysql

You need the 'php-mysql' package installed to access MySQL from within PHP. You will not have this available by default.

On RedHat/Fedora or similar systems run:
Code:
yum install php-mysql
After installation your script will work.

Regards,
SIMP

Fedora Development

Last edited by simplicissimus; 04-02-2008 at 05:57 AM..
simplicissimus is offline     Reply With Quote
Old 03-27-2008, 07:19 AM   #6
bjweb
LQ Newbie
 
Registered: Feb 2008
Posts: 3
Thanked: 0

Original Poster
Thanks now working

Thanks for that
bjweb is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
web page database access per page or per session? b0uncer Programming 6 01-13-2007 01:09 PM
Cant make web server run my local web page... Nik0s Linux - Newbie 22 10-08-2006 11:30 PM
httpd problems - blank web page shows up when access from outside of internet LAN wk4997 Linux - Networking 2 01-21-2006 10:59 AM
Jerky mouse when web browsers download web page stodge Linux - Software 1 07-08-2003 11:29 PM


All times are GMT -5. The time now is 07:36 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration