473,692 Members | 2,294 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 7914
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
2661
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
3376
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
5143
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
1485
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
2038
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
19536
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
3116
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
2376
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
17685
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
8610
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
8544
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,...
1
8810
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
8810
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6462
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2977
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
3
1961
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.