0

Can anyone think of a reason why a PHP // comment cancels the execution of a file?

Here's the setup: I have an index.php file that loops through different commands.

if(in_array($act2, $a2))
		{
			if($act2 == "prods")
			{
                            require('prod.php');
			}
                        else if($act2 == "stats")
			{
				require('stats.php');
			}
			else if($act2 == "cust")
			{
				require('cust.php');
			}
		}

If a comment ( // style only ) is inside one of these files it will stop the parsing and stop output. I tried to avoid comments but this mysql statement seams to stop it too:

$catrow = mysql_fetch_assoc(mysql_query("SELECT * FROM tea_cats WHERE id='".$row['cat']."'")) or die(mysql_error());

The even stranger part is that it works perfectly fine on my own computer PHP 5.3.0, but not on my server with PHP 5.2.12.

Any answers or replies will be helpful,
Thanks eenceo.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by eenceo
0

Have you tried and other servers with different PHP versions too? If you have the same problems on servers with Php version below 5.3, then this is the problem

0

I am using PHP 5.2.10 for my local testing. I have had situations where commented lines of code cause PHP to lose its marbles and it just outputs the uninterpreted code from that point on. I never saw this on earlier versions of PHP and it has only happened a few times. The same code is fine when I run it on the server. My simple solution was to remove the offending comment and move on in the hope that it goes away in future PHP versions. I have many commented-out sections of code that cause no problems but I wasn't able to identify any pattern to it. It only seemed to affect specific lines that started with //. If I enclosed the line in /* ... */ it didn't seem to cause a problem.

0

I use wamp on my computer so I was able to install a closer version of PHP 5.2.11, but it still worked. Also the code just ignored from then on and isn't outputted almost as if I typed die(); One odd thing was if the comments were in an if statement it died with a $end unexpected error, which wouldn't happen with a die(). I've tried eliminating code, but no matter what i do it ends on that mysql statement.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.