PHP5 not displaying echo commands
Moderator: General Moderators
PHP5 not displaying echo commands
Hello,
I have script that takes a host supplied by the viewer and pings it. This script works fine on two servers I have running PHP4, but will not work at all on another server that is running PHP5. I Have checked all the conf files (php.ini, httpd.conf etc.. etc...). I have installed all the packages for updates for PHP5.
THe code executes, gives no errors, but will not display some of the results from the echo commands. Some echo commands work others do not.
THe problem box is running Fedora core 4, and the code works on other fedora boxes, and centOS.
If anyone has any suggestions on how to get PHP5 to work, or on how to revert back to PHP4 please help.
I have script that takes a host supplied by the viewer and pings it. This script works fine on two servers I have running PHP4, but will not work at all on another server that is running PHP5. I Have checked all the conf files (php.ini, httpd.conf etc.. etc...). I have installed all the packages for updates for PHP5.
THe code executes, gives no errors, but will not display some of the results from the echo commands. Some echo commands work others do not.
THe problem box is running Fedora core 4, and the code works on other fedora boxes, and centOS.
If anyone has any suggestions on how to get PHP5 to work, or on how to revert back to PHP4 please help.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Here is the code (which works fine on all kinds of other servers just not my new Fedora Core 4 box running php5)
What is the best way to turn on error reporting???? I turned it on in the php.ini file, and I checked all the error logs.
No errors are being generated that I can find.
Thanks SO MUCH
feyd | Please use
Code: Select all
<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
// Address error handling.
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
// Obtain POST data.
$ping_ip_addr = $_POST['ping_ip_addr']; // input
$ping_count = $_POST['ping_count']; // select
// Remove any slashes if Magic Quotes GPC is enabled.
if (get_magic_quotes_gpc())
{
$ping_ip_addr = stripslashes($ping_ip_addr);
}
// Create arrays.
$ping_count_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25); // Ping count
?>
<head>
<title>Ping</title>
<style type="text/css">
body
{
margin: 0;
padding: 10px;
background-color: #ffffff;
}
div.output
{
margin: 0;
padding: 10px;
background-color: #eeeeee;
border-style: solid;
border-width: 1px;
border-color: #000000;
}
</style>
</head>
<body>
<h1>Ping</h1>
<a href="show.php">back to show</a><br>
<a href="noc1.html">back to main</a>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p><label for="ping_ip_addr">IP address:</label><br />
<input name="ping_ip_addr" id="ping_ip_addr" type="text" value="<?php echo $_POST['submit'] == 'Ping' ? htmlentities($ping_ip_addr, ENT_QUOTES) : $_SERVER['REMOTE_ADDR'];; ?>" size="40" maxlength="15" /></p>
<p><label for="ping_count">Ping count:</label><br />
<select name="ping_count" id="ping_count">
<?php
foreach ($ping_count_array as $ping_count_item)
{
echo '<option' . ($ping_count == $ping_count_item ? ' selected="selected"' : '') . '>' . $ping_count_item . '</option>' . "\n";
}
?>
</select></p>
<p><input type="submit" name="submit" value="Ping" /></p>
</form>
<p>Ping may take a while, please be patient.</p>
<?php
if ($_POST['submit'] == 'Ping') // Form has been submitted.
{
echo '<div class="output">' . "\n";
/**************************************************************************/
// Check for spoofed form submission.
$illegal = FALSE;
if (strlen($ping_ip_addr) > 15)
{
$illegal = TRUE;
}
if (!in_array($ping_count, $ping_count_array))
{
$illegal = TRUE;
}
/**************************************************************************/
if (!$illegal) // Form submission was not spoofed.
{
if (ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $ping_ip_addr)) // Acquired data contains no problems.
{
// Display result.
echo '<pre>' . "\n" .
'ping ' . $ping_count . ' ' . $ping_ip_addr . "\n\n";
system('ping ' . $ping_count . ' ' . $ping_ip_addr); // Ping IP address.
echo '</pre>' . "\n" .
'<p>Ping complete.</p>' . "\n";
}
else // Acquired data contains problems!
{
echo '<p>Please enter a valid IP address.</p>' . "\n";
}
}
else // Form submission was spoofed!
{
echo '<p>An illegal operation was encountered.</p>' . "\n";
}
echo '</div>' . "\n";
}
?>
</body>
</html>What is the best way to turn on error reporting???? I turned it on in the php.ini file, and I checked all the error logs.
No errors are being generated that I can find.
Thanks SO MUCH
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Well I am at work now and I can't get back into my home network. I had to tighten my firewall because some jerk is running a brute force against one of my servers. So I will try your suggestions when I get home.
Thanks in advance for you help, I worked on this problem for hours over the weekend. I am trying to develop a web base suite of networking tools for our NOC, and I am almost done.
Also would you know of how to install PHP4 with PHP5? Or how to change back to PHP4? After all the issues I am having with PHP5 I am not so sure I want to keep running it.
Thanks again.
Thanks in advance for you help, I worked on this problem for hours over the weekend. I am trying to develop a web base suite of networking tools for our NOC, and I am almost done.
Also would you know of how to install PHP4 with PHP5? Or how to change back to PHP4? After all the issues I am having with PHP5 I am not so sure I want to keep running it.
Thanks again.
Is there some condition (if) prior to echoing? Have you checked this http://fi.php.net/manual/en/features.sa ... e-exec-dir ?
I do beleive safe mode is off. I checked the php.ini, but then I removed php5 and tried to reinstall php4. I got php4 installed, but I couldn't get it to work with apache. So I reinstalled php5 and got everything back to how I had it before. However I didn't check the php.ini file after reconfiguring... So I bet it went back to defaults.... I will try that thanks!!!!!!!!!!