?
Solved

PHP programs running through Firefox

Posted on 2016-11-09
4
Medium Priority
?
45 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 111

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 111

Accepted Solution

by:
Ray Paseur earned 2000 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 111

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 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