Solved

PHP programs running through Firefox

Posted on 2016-11-09
4
15 Views
Last Modified: 2016-11-28
I've been doing some training working with PHP and MySQL, and have up to now, been running from a virtual machine operating with Debian Linux.
As I'm starting to work with MySQL, I don't want to be working on the VM so trying to run both from my own system as the server, but when I write the code and try and load through Firefox all I get is a blank screen. The code is as follows:

<html>
<head>
<title>Creating MySQL Database</title>
</head>
<body>
<?PHP
$dbhost = 'localhost:3036';
$dbuser = 'XXXX';
$dbpass = 'XXXXXXXX';

$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysqli_error($conn));
}
echo 'Connected successfully\n';
$sql = 'CREATE DATABASE TUTORIALS';
$retval = mysqli_query( $sql, $conn );
if(! $retval ) {
die('Could not create database: ' . mysqli_error($conn));
}
echo 'Database TUTORIALS created successfully\n';
mysqli_close($conn);
?>
</body>
</html>

Open in new window


I've downloaded PHP and MySQL through Wampserver64, and have been able to run PHPMYADMIN with no problems, and also able to turn on and off the MySQL through it's own Root Device, but cannot get it to run through Firefox.

Our own company system is built on PHP with Javascript which runs fine through Firefox.

Can anyone offer some help as to how I can resolve this issue?
0
Comment
Question by:Neil Brookes
  • 3
4 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41880330
First step - remove all of the HTML - that only muddies the water here.

Try adding these lines to the PHP script, right at the top.  This will let you see if PHP is getting used at all, and if it encounters any errors.
ini_set('display_errors', TRUE);
error_reporting(E_ALL);
echo 'Hello World';

Open in new window

0
 

Author Comment

by:Neil Brookes
ID: 41880335
Thanks Ray

I have just tried that, but all that does when I open with Firefox is display the entire code as a text document.
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points (awarded by participants)
ID: 41880346
Good!  That's actually progress.  It means that the script is not getting parsed through PHP.  If it's file is named ending in .php it should be possible to set up Apache so this happens automatically.  Please see this article (you may or may not want to parse HTML files, but you certainly want to parse PHP files)
https://encodable.com/parse_html_files_as_php/
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41903926
E-E asked me close this question
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Creating and Managing Databases with phpMyAdmin in cPanel.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now