473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CHecking variable Existence

Hey guys, I want to PHP to do stuff only if a sertain form variable exists.
How do i check to see if a variable exists or not?

Something like If $http_post_vars['name'] exists, then do this.

syntax please? :)
Jul 17 '05 #1
5 7905
I noticed that Message-ID: <Of*****************@fe1.texas.rr.com> from
Tesla contained the following:
Something like If $http_post_vars['name'] exists, then do this.

syntax please? :)


yes. :)
if($http_post_vars['name']){do this}

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Geoff Berrow a écrit le 20/02/2004 :
Something like If $http_post_vars['name'] exists, then do this.

syntax please? :)


yes. :)
if($http_post_vars['name']){do this}


I prefer using isset() function : http://www.php.net/isset
Jul 17 '05 #3
In article <me********************************@free.fr.Remove this>,
Jedi121 <je*********@free.fr.Removethis> wrote:
if($http_post_vars['name']){do this}


I prefer using isset() function : http://www.php.net/isset


I have a similar issue as the first poster.

isset($_POST['name']) works, as does if ($_POST['name']!=NULL) . The
problem is that, if error_reporting is set to E_ALL, both of those will
pop up an error that says "Notice: Undefined index: name" at the top of
the page. Yes, you can make that go away by setting error_reporting to
ignore Notices, but when I'm testing scripts I like to keep it on E_ALL
so I know if I'm doing something that's not fatal but still stupid.

So is there a way to check for a variable's existence without PHP
whining if it doesn't exist? :P

if ($POST['name']) seems to always evaluate as true in my tests -- as
well as pop up a Notice.
Jul 17 '05 #4
Garrett Albright <g_******************@ya-nospam-hoo.com> schrieb:
isset($_POST['name']) works, as does if ($_POST['name']!=NULL) . The
problem is that, if error_reporting is set to E_ALL, both of those will
pop up an error that says "Notice: Undefined index: name" at the top of
the page.


isset($_POST['name']) shouldn't give a notice. Please recheck that.

Regards,
Matthias
Jul 17 '05 #5
In article <c1**********@usenet.esken.de>,
Matthias Esken <mu******************@usenetverwaltung.org> wrote:
isset($_POST['name']) shouldn't give a notice. Please recheck that.


Recheck I did, and it did not give a notice. I must have had an error
elsewhere in the code. My bad. :/
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bart Nessux | last post by:
Are these equivelent? Is one approach prefered over the other #check to see if var contains something... if so proceed. if var is not None: continue #check to see if var is empty... if so...
5
by: Thierry S. | last post by:
Hello. I would to test the existence of a variable before to use it (like isset($myVar) in PHP). I try using "if myVar: ", but there is the error meesage (naturally): "NameError: name 'myVar'...
4
by: GujuBoy | last post by:
i want to check to see if a certain program is installed on my windows box using python. how can i do that...(ie, i want to see if "word" is installed) please help
1
by: Xeno Campanoli | last post by:
I'm having a hard time checking existence of windows. The only thing I found on this is page 224 of Rhino. Why is there no function to check this? Is there a publication on this part of the...
2
by: mike | last post by:
I had a form like below that validated that a file was there before it would submit. <form name="attach" method="POST" action="run_this_pgm.cfm" enctype="multipart/form-data"...
5
by: Richard L Rosenheim | last post by:
What's the proper technique for checking for the existence of an attribute within a node? Lets say I did a SelectSingleNode which returned this element: <AnAddress city="San Francisco"...
6
by: Vmusic | last post by:
Hi, I am using Javascript to add rows to tables, etc. in a function I am calling. I pass the function the ID of the div, and what I want in the rows, and it will add rows to a table in the div. ...
4
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw...
8
by: Brad Pears | last post by:
I want to check to see if a particular object exists using vb.net 2005. I have a class called clsContract. When the user clicks the 'New Contract' button, I want to check to see if a clsContract...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.