Apache2Triad Help, Support and Development Forum Index Apache2Triad Help, Support and Development
The apache2triad help , support and development forums
 

[PHP] IF Statements not working
Click here to go to the original topic

 
       Apache2Triad Help, Support and Development Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Supremacy



Joined: 29 Apr 2007
Posts: 3

Posted: Sun Apr 29, 2007 3:21 pm    Post subject: [PHP] IF Statements not working  

Hi,

When I code in PHP, everything works fine until I use an IF statement. WHen I use one of them, the whole page comes out blank on my computer, and there is nothing wrong with the coding.

Show errors is on and everything, it happens when I use an IF statement.

Please help
Sup
Back to top  
lku homer



Joined: 29 May 2006
Posts: 104

Posted: Sun Apr 29, 2007 10:25 pm    Post subject:  

Well something is obviously wrong with the code unless your if statement tells it to be blank. I'm not trying to insult you, but there must be. And it makes it hard for anyone to help when there is no code to look at.
Back to top  
Supremacy



Joined: 29 Apr 2007
Posts: 3

Posted: Mon Apr 30, 2007 7:26 am    Post subject:  

Ive coded for over 2 years in PHP and I can tell you nothing is wrong. Even this simple code does not work.

Code:
<?php
$num = 3

if($num == 3){

echo('Hi');

}else{

echo('Bye');

}

?>

Even that doesnt work, all coding works until I use IF and ELSE or even just IF.
Back to top  
dale



Joined: 11 Jun 2006
Posts: 51
Location: las vegas, nv

Posted: Thu May 03, 2007 8:05 am    Post subject:  

If you add the ; to the line

$num = 3

it works.
Back to top  
Supremacy



Joined: 29 Apr 2007
Posts: 3

Posted: Thu May 03, 2007 5:57 pm    Post subject:  

-_-

Im talking bout the if statement, that was example coding.

Any ideas?
Back to top  
dale



Joined: 11 Jun 2006
Posts: 51
Location: las vegas, nv

Posted: Fri May 04, 2007 6:49 am    Post subject:  

Why don't you try to use debuging in the php part. Just go to your php.ini file and change

display_errors = Off

to On

so that you can see where the errors are. Since your sample code had an error, maybe there might be an error will just pop up. Without having the real code to look at, it is impossible for anyone else to see what could be wrong.

By the way, if you correct your sample code and run it does it work?

There is also a log file in the php folder where the errors are stored. You might want to look in there to see if there isn't a function that isn't turned on that needs to be turned on.
Back to top  
invisible-root



Joined: 01 Jun 2007
Posts: 7

Posted: Fri Jun 01, 2007 8:26 am    Post subject:  

What you need is to gather more information about the problem. PHP will never tell you what's wrong if you haven't asked it. To do that you can edit php.ini (as mentioned earlier by dale) or this:

Code:
<?php

error_reporting(E_ALL);
ini_set('display_errors', TRUE);

// rest of your code here...

?>


You might also be interested in http://php.net/ini_set and http://php.net/error_reporting

I strongly recommend when you write code, to have error_reporting set to E_ALL (so you will be informed about all errors ie undefined variables etc...) and display_errors = On. Do that only on your local server and not on a live webserver because if an attacker can see these information, he/she might be able to hack your application. Be careful with these things.

Hope that helps.
Back to top  
 
       Apache2Triad Help, Support and Development Forum Index -> Programming
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.13 © 2001, 2002 phpBB Group