LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2002, 03:40 PM   #1
antken
Member
 
Registered: Nov 2000
Posts: 368

Rep: Reputation: Disabled
PHP if statements and variables


hi,


this is driving me up the wall

i am typing to make an if statement that will work out if a certain value is given from a database then it will perform a certain task

for example: if the database says the value is 1 then it changes the html to a different button is loaded if its 2 then an extra button is loaded and so on

every time i issue the statement i get back parse errror on line x
i have even looked it up and i cannot find the answer, here is what i am typing

if($lalala == '1'){
dothis();
}

and it fails every time

any ideas??
 
Old 09-24-2003, 01:27 AM   #2
Saraev
Member
 
Registered: Apr 2002
Location: Los Gatos, CA
Distribution: boring redhat 9
Posts: 163

Rep: Reputation: 30
A debugging trick I use when I can't for the life of me find the problem is to comment out the if($lalala section. Right above it, do something like "echo $lalala" so you can see what value is being compared.

As for the code shown, looks fine to me.
 
Old 09-24-2003, 04:28 AM   #3
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
try double quotes. may still fail, but try it anyway.


also, where was $lalala declared. i had that problem because i thought some variables were global but werent
 
Old 09-24-2003, 04:41 AM   #4
nephilim
Member
 
Registered: Aug 2003
Location: Belgium
Distribution: Debian (server), Kubuntu (desktop)
Posts: 248

Rep: Reputation: 30
Even if $lalala isn't declared, it shouldn't give you a parse error, it will just return false.

Could you post some more code, it could be that the line before the if statement is causing you trouble.
 
Old 09-24-2003, 12:45 PM   #5
then
Member
 
Registered: Oct 2002
Location: FDR India
Distribution: RH9, Knoppix, MEPIS
Posts: 65

Rep: Reputation: 15
Re: PHP if statements and variables

Quote:
Originally posted by antken
i am typing to make an if statement that will work out if a certain value is given from a database then it will perform a certain task

every time i issue the statement i get back parse errror on line x
i have even looked it up and i cannot find the answer, here is what i am typing

if($lalala == '1'){
dothis();
}
What's the output of the sql query? I can't see anything wrong with the if. AFAIK, don't need to use quotes when the value of the variable is numeric.

regards
theN
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Are PHP session variables held in memory when you leave a PHP site? Locura Programming 11 11-16-2008 08:37 PM
Can I use PHP variables in javascript? nickiv Programming 1 06-07-2005 05:41 AM
if statements and case statements not working in bourne shell script mparkhurs Programming 3 06-12-2004 02:41 AM
PHP: egrep For Loops and If Statements jhrbek Programming 14 12-31-2003 12:26 PM
IF statements in PHP antken Programming 6 09-17-2002 09:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration