Apache2Triad Help, Support and Development Forum Index Search Profile Log in to check your private messages Log in Register Memberlist Attachments Statistics Crew/Ranks Archive
 [PHP] IF Statements not working
Google
Post new topic Reply to topic
Author Message
Supremacy
 
 


Joined: 29 Apr 2007
Posts: 3

PostPosted: Sun Apr 29, 2007 3:21 pm Reply with quoteBack to top

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
View user's profileSend private message
lku homer
 
 


Joined: 29 May 2006
Posts: 104

PostPosted: Sun Apr 29, 2007 10:25 pm Reply with quoteBack to top

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.
View user's profileSend private messageAIM AddressYahoo MessengerMSN MessengerICQ Number
Supremacy
 
 


Joined: 29 Apr 2007
Posts: 3

PostPosted: Mon Apr 30, 2007 7:26 am Reply with quoteBack to top

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.
View user's profileSend private message
dale
 
 


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

PostPosted: Thu May 03, 2007 8:05 am Reply with quoteBack to top

If you add the ; to the line

$num = 3

it works.
View user's profileSend private message
Supremacy
 
 


Joined: 29 Apr 2007
Posts: 3

PostPosted: Thu May 03, 2007 5:57 pm Reply with quoteBack to top

-_-

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

Any ideas?
View user's profileSend private message
dale
 
 


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

PostPosted: Fri May 04, 2007 6:49 am Reply with quoteBack to top

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.
View user's profileSend private message
invisible-root
 
 


Joined: 01 Jun 2007
Posts: 7

PostPosted: Fri Jun 01, 2007 8:26 am Reply with quoteBack to top

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.
View user's profileSend private message
Display posts from previous:      
Post new topic Reply to topic


 Jump to:   



View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme
All times are GMT