Solved

PHP programs running through Firefox

Posted on 2016-11-09
4
33 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 110

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 110

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 110

Expert Comment

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

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

730 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