Solved

PHP programs running through Firefox

Posted on 2016-11-09
4
42 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

691 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