The Cellar  

Go Back   The Cellar > Main > Technology
FAQ Community Calendar Today's Posts Search

Technology Computing, programming, science, electronics, telecommunications, etc.

Reply
 
Thread Tools Display Modes
Old 03-06-2003, 12:57 AM   #1
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
Question Anyone know PHP

I've been doing a few little things in PHP over the last week for a particular purpose and i'm confused about one thing

I've got a script that refers to itself when it runs, checking a value ($id) that would have been set if the page/script is beign viewed for the second time

the code to check that is

if ($id) {

blahblabla

}

Which as i thought checked that $id existed (in the url). It doesn't seem to work. If i get $id to check against a certain value i know it will be it works, but clearly the person who told me this was wrong or i've totally missed something.

Any ideas from the crowd?
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain

Last edited by jaguar; 03-06-2003 at 01:26 AM.
jaguar is offline   Reply With Quote
Old 03-06-2003, 09:52 AM   #2
Skunks
I thought I changed this.
 
Join Date: Nov 2002
Location: western nowhere, ny
Posts: 412
Newer installs of PHP have a config option (register_globals) off. When it is on, GET, POST, and cookie variables are automagically set. Load foo.php?bar=baz, and $bar will be 'baz' within the script. It was disabled by default to protect people with horribly atrocious coding standards from people sending them bogus value and faking authentication.

Use $_GET['id'].
Skunks is offline   Reply With Quote
Old 03-06-2003, 09:55 AM   #3
Undertoad
Radical Centrist
 
Join Date: Jan 2001
Location: Cottage of Prussia
Posts: 31,423
Also, personally speaking I avoid such shortcuts. C programmers love to write weird conditions that take hours to figure out. That's not so critical when performance is not the major factor. If I have a php script that goes to page two, I write something really bloody obvious like

if ($page2 == "yes")
// --- Page TWO section ----------------

...because even though it takes more effort now, it means I'll be able to figure out what I did a year from now, when I've forgotten the whole project and the client wants me to change the whole thing.
Undertoad is offline   Reply With Quote
Old 03-06-2003, 10:29 AM   #4
dave
Guest
 
Posts: n/a
I would be fired if I didn't write clean, well-commented code. I'm in the habit now of writing more comment than code. It's just something you get used to.
  Reply With Quote
Old 03-06-2003, 12:24 PM   #5
That Guy
He who reads, sometimes writes.
 
Join Date: Sep 2001
Location: at the keyboard
Posts: 791
I've always had the mindset that if your vars and funcs were well-named, then you wouldn't necessarily need to comment. Then my last perl script came to 1500 lines before completion. Yikes!
That Guy is offline   Reply With Quote
Old 03-06-2003, 12:29 PM   #6
dave
Guest
 
Posts: n/a
That's how I used to be. Unfortunately, they don't stand for that shit here.
  Reply With Quote
Old 03-06-2003, 03:55 PM   #7
russotto
Professor
 
Join Date: Jan 2001
Posts: 1,788
If you can't understand it from a non-symbolic disassembly listing, you don't belong in the business, that's what I always say.
russotto is offline   Reply With Quote
Old 03-06-2003, 05:22 PM   #8
Cam
dripping with ignorance
 
Join Date: Oct 2002
Location: Grand Forks ND
Posts: 642
I realized this week that I have no idea how to program in Java anymore, I took it my first semester and now couldn't write a line of code without a book.

Okay I'm done crying now.
__________________
After the seventh beer I generally try and stay away from the keyboard, I apologize for what happens when I fail.
Cam is offline   Reply With Quote
Old 03-07-2003, 06:28 AM   #9
jaguar
whig
 
Join Date: Apr 2001
Posts: 5,075
Thanks skunks, the info dated to php3 (which i was not aware of). It's not anything related to anything authish so faking a var is not an issue, though i'll admit it's sloppy as hell, php is not a language i claim to know at all, i'm just playing around atm.

UT the code is commented etc, i just put the minimum to get the point across.
__________________
Good friends, good books and a sleepy conscience: this is the ideal life.
- Twain
jaguar is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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 On
HTML code is Off

Forum Jump

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


Powered by: vBulletin Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.