no html o/p

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
lipun4u
Forum Commoner
Posts: 82
Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:

no html o/p

Post by lipun4u »

Why the following code does not give any html o/p ???

Code: Select all

<!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=iso-8859-1" />
<title>Script7</title>
</head>
 
<body>
    <?php
        if( 1+2 == 3) 
            print "this is true<br>";
        $a = "yes";
        if($a == "yes") {
            print "$a is equal to yes<br>";
            $a="no";
        }
        $a=1;
        $b=6;
        $c="y";
        if(($a==$b)||($b+$a==7 && &c=="y") || 1) {
            print "example 3 is true<br>";
        }
        if($a=$b) {
            print "example 4 is true<br>";
        }
        if($a==$b) {
            print "example 5 is true<br>";
        }
    ?>
</body>
</html>
 
robnet
Forum Commoner
Posts: 85
Joined: Mon Aug 10, 2009 8:32 am
Location: South East, UK

Re: no html o/p

Post by robnet »

Hi lipun4u,
It looks like a parse error: check line 20:

Code: Select all

 
if(($a==$b)||($b+$a==7 && &c=="y") || 1) {
 
I think you meant to type $c rather than &c. - It runs fine after changing it
lipun4u
Forum Commoner
Posts: 82
Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:

Re: no html o/p

Post by lipun4u »

thanx
robnet
Forum Commoner
Posts: 85
Joined: Mon Aug 10, 2009 8:32 am
Location: South East, UK

Re: no html o/p

Post by robnet »

No worries - perhaps I hit send too soon though :oops:
It's worth turning error reporting on for dev work. These typos will happen whatever your skill level of php is, and error reporting can save hours of frustration and hundreds of kick-yourself moments! (Turn it off for live systems though!)

http://uk3.php.net/manual/en/errorfunc. ... -reporting

If you have access to php.ini add these lines:

Code: Select all

 
error_reporting  =  E_ALL
display_errors = On
 
Or if you don't have, you can add these lines to your php:

Code: Select all

 
error_reporting(E_ALL | E_STRICT);
ini_set("display_errors", 1);
 
This would have shown you the error:

Code: Select all

 
Parse error: syntax error, unexpected '&' in /path/to/file.php on line 20
 
lipun4u
Forum Commoner
Posts: 82
Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:

Re: no html o/p

Post by lipun4u »

Thank you robnet. It helped me a lot..
Post Reply