echo statement doesn't work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
noelswanson
Forum Newbie
Posts: 1
Joined: Mon May 28, 2007 10:54 pm

echo statement doesn't work

Post by noelswanson »

There is something very bizarre going on here - but I don't know where to start in trying to figure this out.

I have a script that was working fine in the past. Now it dies. but here is the strange thing:

It dies at various different points depending on what I do with the echo statements. For example if I have this:


Code: Select all

print "<br>url: ";
print $url;
It is fine (but dies later on)

If i have this:

Code: Select all

print "<br>url: ".$url;
It dies on that line.

When I say it dies later on, I mean it dies on some other statement further down. For example, in this line, it dies half way through:

Code: Select all

if($value!="not used")if($hidden!="")$update=$update.',`hidden`=\''.$hidden.'\'';
how do I know? Because if I break that down into parts, it dies on the first letter d:

Code: Select all

if($value!="not used"){
 echo "if 1<br>\n";
 if($hidden!=""){
  echo "if 2, ".strlen($update)."<br>\n";
  $update.="";
  echo "if 2a<br>\n";
  $update.=",";
  echo "if 2a ,<br>\n";
  $update.="h";
  echo "if 2a h<br>\n";
  $update.="i";
  echo "if 2a i<br>\n";
  $update.="d";
  echo "if 2a d<br>\n";
  $update.="d";
  echo "if 2a d<br>\n";
  $update.="e";
  echo "if 2a e<br>\n";
  $update.="n";
  echo "if 2b<br>\n";
  $update.='=\'';
  echo "if 2c<br>\n";
  $update.=$hidden.'\'';
  echo "if 2d<br>\n";
  }
 echo "if 1b<br>\n";
 }
None of this makes any logical sense at all, so can anyone shed any light on what on Earth is going on? This is on my own dedicated server, ... hmm, just tried to run phpinfo(), but the script died at that point:

Code: Select all

print_r($tags);
print "hello";
phpinfo();
So I put it at the beginning, and it worked.

so - php 5.2.1 on apache/linux

in total it is a very simple script, nothing complicated, dies at around line 95.

Any ideas?

Thanks

Noel
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Does $url exist at the point where it fails?

It's fairly difficult to know how to fix things without seeing more of your code, I suspect.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

My very non-educated guess would be that you're going in and out of full tags (<?php) and short tags (<?) on a php installation that doesn't allow short tags. That often causes very weird results.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

scottayy wrote:My very non-educated guess would be that you're going in and out of full tags (<?php) and short tags (<?) on a php installation that doesn't allow short tags. That often causes very weird results.
That's what I was thinking.
Post Reply