Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

php echos don't work

I have this code in a program at the VERY top:
ini_set('session.cache_limiter','public');
	session_cache_limiter(false);
	session_start();
	echo "quick = " . $_SESSION['quick'] . "<br>";
	echo "Session[sssmed] = " . $_SESSION['sssmed'] . "<br>";
	if ($_SESSION['quick'] && $_SESSION['sssmed'] == "sep") {
		header("Location: opts_ref20.php");
	}

Open in new window


When that program runs, there is NOTHING echoed. See attached file.
no_echos.JPG
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard Korts

ASKER

I thought of that, but the fixed text part should still display.
if ($_SESSION['quick'] && $_SESSION['sssmed'] == "sep") {
this is wrong in php, you got to use this instead in php:
if ($_SESSION['quick'] . $_SESSION['sssmed'] == "sep") {

Open in new window

On your code you are calling session_cache_limiter( false ), but the online manual states that the values that you can use are:
public, private_no_expire, private, and nocache.  Try passing one of those values and try again.

Did you look at your server log?
at the top of your page add this.
session_start();
echo 'Session output';
echo "<pre>" . print_r($_SESSION, true) . "</pre>";
die(__FILE__ . ': Line ' . __LINE__);

Open in new window

What does that do?
Julian,

I abandoned that one, got around it somehow but a similar one has this Javascript:
if (ac == "go") {
			alert("go to ac = go");
			alert("group = " + group);
			if (group == "sand") {
				if (document.st.voltage.value == "") {
					alert("Voltage required.");
					return false;
				}	
				document.st.action = "opts_ref21.php?voltage=" + document.st.voltage.value;
				return true;
			}
			alert("cltype = " + cltype);	
			if (cltype == "F") {
				document.st.action = "options.php?fr=cust";
				return true;
			}
			alert("ssmed = " + ssmed);
			if (ssmed == "") {
				if (document.st.voltage.value == "") {
					alert("Voltage required.");
					return false;
				}	
			}	
			document.st.action = "options.php?fr=cust&ssmed=" + ssmed;
			return true;
		}

Open in new window


The alerts all show, except alert("ssmed = " + ssmed);, which implies cltype = F but it = S.

The beginning of options.php has this (per your previous suggestion:
error_reporting(E_ALL);
// decide applicable option list
session_start();
echo 'Session output';
echo "<pre>" . print_r($_SESSION, true) . "</pre>";
die(__FILE__ . ': Line ' . __LINE__);

Open in new window


It shows NOTHING, but it takes 5 - 8 seconds to run before it shows the next page, which will only show if ssmed = "Y", which it does.

This is all a result of running the program in a development environment, same programs & database, content of some tables are different.

Thanks,

Richard

PS - I have not payed your invoice, I don't remember the amount can you send me that in a private email. And, do you accept PayPal?
Ok if nothing is showing then the next page then the code I gave you is not running. It has a die() statement in it so it should terminate execution and not show anything on the screen.

If you comment out line 15 does the alert show?
I suspected it is not being executed at all. I put a VERY small version of the whole php program, this code instead:
<?php
error_reporting(E_ALL);
// decide applicable option list
session_start();
echo 'Session output';
echo "<pre>" . print_r($_SESSION, true) . "</pre>";
die(__FILE__ . ': Line ' . __LINE__);
	echo "get[ssmed] = " . $_GET['ssmed'] . "<br>";
	$cltype = $_SESSION['cltype'];
	if ($_GET['fr'] == "cust") {
		$_SESSION['voltage'] = $_POST['voltage'];
	}
?>	

Open in new window


Nothing.

But it goes somewhere else it needs to go.

I put another question in a few hours ago about the Javascript that leads to this. Might be some clues there.

I believe it is this: https://www.experts-exchange.com/questions/29132894/JavaScript-appears-to-be-NOT-working.html

Thanks,

Richard
Are we not dealing with some sort of caching here? Are you sure that the code you are putting on the server is what is actually executing and not a cached version?
Julian.

I thought of that myself, so I cleared the cache in Firefox, tried again.

Then I made  new version of a program called main.php, made a change in eliminating one button, saved it as main1.php & tried it on the server. It gives me a 404. I looked on the server, main1.php is there. I use Filezilla, so I can view source on the server, the source was correct.

I tried the real program in Microsoft Edge (I never use that except to a few things in cases like this), I have never used edge on this app, it still uses the old versions of the programs, they could not be cached as I do not use that browser.

I communicated with Chihost about the 404, they responded to that with "were looking into that".

Not sure what all that means; right now until the other stuff is straightened out I need to use main1.php on the live site to prevent customers from trying to use the feature (all this) that the button leads to.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It was a server issue. The host had changed the server on this account & a 3rd party managing the DNS  did not complete changes to the DNS. I was uploading to & running the code on a different server. Today, they got that fixed & it works.