LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-21-2016, 07:24 AM   #1
dwmolyneux
Member
 
Registered: Feb 2012
Location: United States of America
Distribution: "First Time Gentoo user",Debian, Fedora, LinuxMint
Posts: 124

Rep: Reputation: Disabled
Question Apache2 MySQL PHP7 Ubuntu


hi I am trying to setup local apache webserver for learning php and mysql but I keep running into an issue of getting blank/white pages where php is used and calling for data from the mysql database.
I goto http://localhost and the index.php page displays as it should...
https://drive.google.com/open?id=0B1...1JEaFpUMEY1WU0 but when I click on the nav links to changes pages the url uses a "index.php?pid=" and then instead of displaying the page as it should it gives a blank/white page....
https://drive.google.com/open?id=0B1...kpPcTBNWmozenc
I have checked the coding and all looks to me like it should and I have done multiple searches to try and find a solution but all I have found is either out-dated or things that are suggested can not be found using the sudo apt or sudo apt-get.
Code:
the files that I can think of that would contain the info https://drive.google.com/open?id=0B1A2ZuAmFkvMZkxLTnQ5eXVQNms was too long to post here and was given invalid when I tried to attach.

Any help would be very much appreciated and thank you a head of time. I'm driving myself insane trying to figure it out. I have been following the tutorials on youtube from "http://www.developephp.com" to give fare credit where do.
 
Old 10-21-2016, 02:20 PM   #2
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
What browser are you using? If Firefox, look at the source of the page you go from and to (right click displayed page and select 'View Source'). If not firefox there should be similar functionality somewhere similar. The source code the browser receives should provide at least a hint.
 
Old 10-21-2016, 03:19 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,924

Rep: Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305
A blank white page would indicate a php or HTML error. To see the errors look at the /var/log/apache2/error.log. It would help if you post the code (use code tags) or a link to the code.
 
Old 10-22-2016, 01:58 AM   #4
dwmolyneux
Member
 
Registered: Feb 2012
Location: United States of America
Distribution: "First Time Gentoo user",Debian, Fedora, LinuxMint
Posts: 124

Original Poster
Rep: Reputation: Disabled
here is the most recent log entry from /var/log/apache2/error.log
Code:
[Sat Oct 22 00:53:04.933584 2016] [:error] [pid 1423] [client 127.0.0.1:60912] PHP Notice:  Undefined index: pid in /var/www/html/index.php on line 7
[Sat Oct 22 00:53:13.665797 2016] [:error] [pid 1425] [client 127.0.0.1:60914] PHP Fatal error:  Uncaught Error: Call to undefined function ereg_replace() in /var/www/html/index.php:10\nStack trace:\n#0 {main}\n  thrown in /var/www/html/index.php on line 10, referer: http://localhost/
 
Old 10-22-2016, 05:27 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,924

Rep: Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305
There are errors in the index.php code. With out seeing the code there is not much else we can do to help.
 
Old 10-22-2016, 05:49 AM   #6
dwmolyneux
Member
 
Registered: Feb 2012
Location: United States of America
Distribution: "First Time Gentoo user",Debian, Fedora, LinuxMint
Posts: 124

Original Poster
Rep: Reputation: Disabled
index.php
Code:
<?php
session_start();
/* Created by Adam Khoury @ www.developphp.com */

require_once "scripts/connect_to_mysql.php";
// Determine which page ID to use in our query below ---------------------------------------------------------------------------------------
if (!$_GET['pid']) {
	$pageid = '1';
} else {
	$pageid = ereg_replace("[^0-9]", "", $_GET['pid']); // filter everything but numbers for security
}
// Query the body section for the proper page
$sqlCommand = "SELECT pagebody FROM pages WHERE id='$pageid' LIMIT 1"; 
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
while ($row = mysqli_fetch_array($query)) { 
    $body = $row["pagebody"];
} 
mysqli_free_result($query); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
// Query the module data for display ---------------------------------------------------------------------------------------------------------------
$sqlCommand = "SELECT modulebody FROM modules WHERE showing='1' AND name='footer' LIMIT 1"; 
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
while ($row = mysqli_fetch_array($query)) { 
    $footer = $row["modulebody"];
} 
mysqli_free_result($query); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
// Query the module data for display ---------------------------------------------------------------------------------------------------------------
$sqlCommand = "SELECT modulebody FROM modules WHERE showing='1' AND name='custom1' LIMIT 1"; 
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
while ($row = mysqli_fetch_array($query)) { 
    $custom1 = $row["modulebody"];
} 
mysqli_free_result($query); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
// Build Main Navigation menu and gather page data here -----------------------------------------------------------------------------
$sqlCommand = "SELECT id, linklabel FROM pages WHERE showing='1' ORDER BY id ASC"; 
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 

$menuDisplay = '';
while ($row = mysqli_fetch_array($query)) { 
    $pid = $row["id"];
    $linklabel = $row["linklabel"];
	
	$menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a><br />';
	
} 
mysqli_free_result($query); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
//mysqli_close($myConnection); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Website</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Arial Black, Gadget, sans-serif;
	font-size: 12px;
}
body {
	background-image: url(style/stripBG.jpg);
	background-repeat: repeat-x;
	color:#FFF;
	background-color: #996600;
}
a:link {
	color: #FBE7B7;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #FBE7B7;
}
a:hover {
	text-decoration: underline;
	color: #FFF;
}
a:active {
	text-decoration:none;
	color: #FFF;
}
-->
</style></head>

<body>
<table width="888" border="0" align="center" cellpadding="6">
  <tr>
    <td align="center"><table width="100%" border="0" cellpadding="8">
      <tr>
        <td colspan="2"><table width="100%" border="0">
          <tr>
            <td width="46%"><a href="index.php"><img src="style/logo.png" alt="My Magic Site Logo" width="360" height="80" border="0" /></a></td>
            <td width="54%" valign="top" bgcolor="#150D00"><?php echo $custom1; ?></td>
          </tr>
        </table>
      </td>
        </tr>
      <tr>
        <td width="22%" valign="top" bgcolor="#150D00" style="border:#6B450C thin solid; line-height:1.5em;">
		<?php echo $menuDisplay; ?>
          </td>
        <td width="78%" valign="top" bgcolor="#150D00" style="border:#6B450C thin solid;">
        <div style="width:656px; height:400px; overflow: auto;"><?php echo $body; ?></div>          
        </td>
      </tr>
      <tr>
        <td colspan="2" bgcolor="#150D00" style="border:#6B450C thin solid;"><?php echo $footer; ?>   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
        </tr>
    </table>
    &copy;Copyright 2009 Developphp.com</td>
  </tr>
</table>
<div align="center"><a href="administrator">Admin</a></div><br />
</body>
</html>
 
Old 10-22-2016, 05:52 AM   #7
dwmolyneux
Member
 
Registered: Feb 2012
Location: United States of America
Distribution: "First Time Gentoo user",Debian, Fedora, LinuxMint
Posts: 124

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dwmolyneux View Post
Code:
the files that I can think of that would contain the info https://drive.google.com/open?id=0B1A2ZuAmFkvMZkxLTnQ5eXVQNms was too long to post here and was given invalid when I tried to attach.
file link was posted in my original post.
 
Old 10-22-2016, 06:21 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,924

Rep: Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305
The ereg_replace function was removed in php 7

Try:
preg_replace("[^0-9]", "", $_GET['pid'])
 
Old 10-22-2016, 06:31 AM   #9
dwmolyneux
Member
 
Registered: Feb 2012
Location: United States of America
Distribution: "First Time Gentoo user",Debian, Fedora, LinuxMint
Posts: 124

Original Poster
Rep: Reputation: Disabled
Thank you and that worked. I'll have to look at the other files now and see if any others need to be changed but at least now I know that it was not the problem I was originally thinking it was.

I was starting to beat myself up thinking that I had failed to install something or missed a config somewhere. I'm still fairly new at learning linux.
 
Old 10-22-2016, 07:13 AM   #10
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,864
Blog Entries: 3

Rep: Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052
You can use "grep" to look around for other occurrences of the deprecated function.

Code:
grep -n 'ereg_replace' *.php
That will give you line numbers and file names. See the manual page for the full set of options, including PCRE.

One tip you might find useful while working on PHP is to use "tail" to monitor the web log live. Open up an extra terminal window and run it with the -f option:

Code:
tail -f /var/log/apache2/error.log
Then when something fails, just tab to the window to see the notes.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] Php7 Installation with Php5 on Ubuntu mahi_nix Linux - Server 3 02-12-2016 01:28 AM
ubuntu - LAMPP's mysql and apache2's mysql are overlapped bloodstreetboy Linux - Server 5 03-26-2013 09:32 AM
LXer: How To Set Up WebDAV With MySQL Authentication On Apache2 (Ubuntu 9.10) LXer Syndicated Linux News 0 06-02-2010 07:50 AM
php7 + apache2 installation problems Misha Ubuntu 4 05-23-2007 08:17 PM
Problems upgrading MySQL on Ubuntu, with Apache2/PHP4 peruvianllama Linux - Software 0 08-16-2005 09:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:32 AM.

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