LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux 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
  Search this Thread
Old 03-24-2008, 02:00 AM   #1
bjweb
LQ Newbie
 
Registered: Feb 2008
Posts: 3

Rep: Reputation: 0
mysql_connect resulting in blank web page


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
 
Old 03-24-2008, 07:44 AM   #2
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
Turn on display_errors in your php.ini file and the error will be displayed in the browser.
 
Old 03-25-2008, 04:44 AM   #3
bjweb
LQ Newbie
 
Registered: Feb 2008
Posts: 3

Original Poster
Rep: Reputation: 0
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???
 
Old 03-25-2008, 04:47 AM   #4
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
The error is because you do not have the php mysql module installed, what distro are you running ?
 
Old 03-25-2008, 08:41 AM   #5
simplicissimus
Registered User
 
Registered: Mar 2008
Posts: 104

Rep: Reputation: 15
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 04:57 AM.
 
Old 03-27-2008, 06:19 AM   #6
bjweb
LQ Newbie
 
Registered: Feb 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks now working

Thanks for that
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration