473,427 Members | 1,842 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,427 software developers and data experts.

Error in page when checking http_get_vars("myvar") and "myvar" was not passed in URL string

I am new to PHP, coming from ASP coding

if (HTTP_GET_VARS['b']==1){
print "Yes";
}else{
print "No";
}

when "b" is not passed via
(http://www.mydomain.com?b=1

an error occurs and the "NO" is printed but an error is printed too.

How can I check for the value of "b" so that no error occurs if b is
not passed??

example

http=www.mydomain.com

$myvar=HTTP_GET_VARS['b']

causes an error because
"b" does not exist (ie. its not passed in the URL string.

$myvar maybe evaluated as NULL or Empty but the error is printed in
the page, anyway.
thanks
Jul 17 '05 #1
2 2396
John Pastrovick wrote:
I am new to PHP, coming from ASP coding

if (HTTP_GET_VARS['b']==1){
print "Yes";
}else{
print "No";
}

when "b" is not passed via
(http://www.mydomain.com?b=1

an error occurs and the "NO" is printed but an error is printed too.

How can I check for the value of "b" so that no error occurs if b is
not passed??

example

http=www.mydomain.com

$myvar=HTTP_GET_VARS['b']

causes an error because
"b" does not exist (ie. its not passed in the URL string.

$myvar maybe evaluated as NULL or Empty but the error is printed in
the page, anyway.
thanks

First of all $HTTP_GET_VARS is old you should use $_GET['b'] now and in
answer to your question

if (!isset($_GET['b']))
print "b isn't set!";
Jul 17 '05 #2
With total disregard for any kind of safety measures
pa*********@hotmail.com (John Pastrovick) leapt forth and uttered:
I am new to PHP, coming from ASP coding

if (HTTP_GET_VARS['b']==1){
print "Yes";
}else{
print "No";
}

when "b" is not passed via
(http://www.mydomain.com?b=1

an error occurs and the "NO" is printed but an error is printed
too.

How can I check for the value of "b" so that no error occurs if
b is not passed??

example

http=www.mydomain.com

$myvar=HTTP_GET_VARS['b']

causes an error because
"b" does not exist (ie. its not passed in the URL string.

$myvar maybe evaluated as NULL or Empty but the error is printed
in the page, anyway.
thanks


All variables and arrays in PHP must be prefixed with the $ glyph.
So it should be $HTTP_GET_VARS['b'], which is a deprecated array
anyway as the other poster said.

--
Phil Roberts | Nobody In Particular | http://www.flatnet.net/
Jul 17 '05 #3

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

Similar topics

8
by: Yannick Turgeon | last post by:
Hello all, We are currently changing our web server and, in the process, updating PHP version from 4.3.0 to 4.3.5. The problem we've got is that our PHP applications generate errors saying that...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
6
by: adamrfrench | last post by:
Let it be mentioned that Javascript is not my forte, so the solution to this could very well be a simple one. I am working on an AJAX function where I can pass a URL and the target ID in, and...
4
by: BB | last post by:
Hello all, I might be missing something here, but am trying to understand the difference between using application-level variables--i.e. Application("MyVar")--and global variables--i.e. public...
25
by: MLH | last post by:
Is it a common occurrence for A97 VBA to 'RACE' on past a debug.print statement? I have been trying to debug a problem (which turned out to be an attempt to assign Null to a Date Type variable)...
3
by: Pierre | last post by:
Hello, In an aspx page (mypage.aspx) from a web projet, I would like to get the value of a variable of the projet that is declared as public in a module. The variable can be called from...
11
by: Joseph S. | last post by:
Hi all, how do I avoid typing the keyword "$this->" every time I need to reference a member of a class inside the class? (coming from a world of cozy auto-complete enabled Java / .Net IDEs I...
4
by: Ronald S. Cook | last post by:
So most of the time I need to write the following to instantiate an object: Dim cnn As New SqlConnection() But sometimes Intellisense tells me not to include the "new": Dim dst As DataSet ...
5
by: jcolino | last post by:
Hi, I usually get stuck with one of two questions that keep coming up. Perhaps some of you brilliant people can shed some light... 1. How to do use if statements in load commands (I usually...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.