473,839 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7927
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_v ars['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_v ars['name']){do this}


I prefer using isset() function : http://www.php.net/isset
Jul 17 '05 #3
In article <me************ *************** *****@free.fr.R emovethis>,
Jedi121 <je*********@fr ee.fr.Removethi s> wrote:
if($http_post_v ars['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**********@u senet.esken.de> ,
Matthias Esken <mu************ ******@usenetve rwaltung.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
2669
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 prompt user again.
5
3391
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' is not defined" Please, could you tell me what for function exist to test the variable with Python?
4
5154
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
1491
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 protocol I can read as a newbie? Please can someone make a suggestion one what to read or try? Sincerely, Xeno -- Community FIRST, Then Trade! http://www.eskimo.com/~xeno, xeno@eskimo.com, Xeno Campanoli
2
2047
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" onSubmit="return(validateData(this))"> <input type="file" name="txtFileToUpload"> <input type="submit" name="btnAdd" value="Add" class="form_button"> </form> function checkFile(frm)
5
19540
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" state="CA" /> What's the best why of determining if the attribute zipcode exists in this node? If I try accessing the attribute with code like: ZipCode = myNode.Attributes("zipcode").Value
6
3127
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. The problem is I need to test for the existence of the table - and if the variable or object doesn't exist already my code errors - PLEASE REMEMBER - I don't know the name of the variable or object I am testing the existance for - it is created...
4
2397
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 exceptions?
8
17731
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 object already exists and if so what the state of that object is before doing anything else. I thought I could use ... if IsNothing(clsContract) then 'somc code
0
9854
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9696
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10903
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10584
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10645
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5681
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.