LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 03-13-2014, 10:26 PM   #16
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206

Don't use the IP address, it is still "localhost" from the context of the PHP script.

As for the white page, are you sure that Apache is processing PHP correctly? Try a simple

Code:
echo "It works";
To see if that works. If not, make sure Apache is sending PHP errors to the client - it may be disabled.
 
Old 03-13-2014, 10:30 PM   #17
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Your PHP is not valid code, the "or" cannot follow the closing ";" of the previous line.

Try this...

Code:
<?php


$hostname = "localhost";
$username = "user";
$password = "abc123";


// Create connection to the database
$dbhandle = mysql_connect($hostname, $username, $password);
 if(!$dbhandle){die("unable to connect to MySQL");}
echo "connected to MySQL";
?>
 
Old 03-14-2014, 12:12 AM   #18
cyberdome
Member
 
Registered: Mar 2014
Distribution: Fedora 23 - MariaDB 10.1 -
Posts: 130

Original Poster
Blog Entries: 2

Rep: Reputation: 8
Quote:
Originally Posted by astrogeek View Post
Your PHP is not valid code, the "or" cannot follow the closing ";" of the previous line.

Try this...

Code:
<?php


$hostname = "localhost";
$username = "user";
$password = "abc123";


// Create connection to the database
$dbhandle = mysql_connect($hostname, $username, $password);
 if(!$dbhandle){die("unable to connect to MySQL");}
echo "connected to MySQL";
?>



thanks for the attention to detail, you know in this line of business, you have to have attention to detail and every little symbol counts. your right my code is not valid.

Code:
<?php


$hostname = "127.0.0.1";
$username = "user";
$password = "abc123";


// Create connection to the database
$dbhandle = mysql_connect($hostname, $username, $password);  < ---  typo error I should look at the code more carefully
    or die ("unable to connect to MySQL");
echo "connected to MySQL";
?>

I took the semi-colon out and it works perfectly fine now. But initially, I did get that could get that could not connect error which was fixed by giving permissions to the USER in MySQL.

Code:
<?php 

  echo "rule #1 in PHP attention to detail, rule#2  attention to detail, rule#3  attention to detail";

?>



Thanks all for the help. I am grateful to you my friend (AstroGeek).

Now next step to learning more about PHP and MySQL


take care.
 
Old 03-14-2014, 12:14 AM   #19
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
You are welcome! Good luck!
 
  


Reply



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
[SOLVED] Unable to connect PHP to MySQL? armsman Linux - Software 1 09-14-2011 09:13 PM
Fresh CentOS5, PHP, mySQL Install, but Cant Pull up Localhost in Web browser. hungry4knowhow Linux - Newbie 9 04-20-2010 12:32 AM
Failed to launch VMware Web Access: unable to find a graphical web browser. rob0t Linux - Server 0 03-18-2009 02:32 PM
LXer: Backing up your MySQL database using your web browser and a PHP script LXer Syndicated Linux News 0 04-21-2007 10:16 PM
how to connect via web browser SlipAway172 Mandriva 6 01-13-2005 06:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

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