473,583 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checking paramters in the url bar

<?php
if ((!isset($s)) && (!isset($msg))) {
echo("<table>
....
I want some pictures displayed on the main page if its a new visit, but when they
search and the url bar changes its skips displaying them, to save scrolling down all the time.

I tried the above to read the parameters but get an error when they are not set.

Is there something simple like this :

if (url has no parameters) {
echo("...draw front page section")
Herc

--
www.TopCounters.com www.Chatty.net
Jul 17 '05 #1
7 1898
"-erc" wrote:
<?php
if ((!isset($s)) && (!isset($msg))) {
echo("<table>
....
I want some pictures displayed on the main page if its a new visit,
but when they
search and the url bar changes its skips displaying them, to save
scrolling down all the time.

I tried the above to read the parameters but get an error when they
are not set.

Is there something simple like this :

if (url has no parameters) {
echo("...draw front page section")
Herc

--
www.TopCounters.com www.Chatty.net


url parameters are made available in $_GET array.

So you can say:
if (count($_GET) == 0) ....

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-checking...ict136679.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=456582
Jul 17 '05 #2
*** |-|erc wrote/escribió (Thu, 05 Aug 2004 03:00:59 GMT):
Is there something simple like this :

if (url has no parameters) {
echo("...draw front page section")


This should be enough:

if($_GET['parameter'] != ''){
echo foo();
}

You really don't need to have zero parameters, just check for the required
ones (you don't mind whether there's a PHPSESSIONID or anything similar).

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #3
.oO(Alvaro G Vicario)
This should be enough:

if($_GET['parameter'] != ''){
echo foo();
}


This will show a notice if there's no such parameter.

Better:

if (isset($_GET['parameter'])) {
...
}

Micha
Jul 17 '05 #4
*** Michael Fesser wrote/escribió (Thu, 05 Aug 2004 14:54:22 +0100):
if($_GET['parameter'] != ''){
echo foo();
}
This will show a notice if there's no such parameter.


Not for me. Does it depend on error_reporting settings?
if (isset($_GET['parameter'])) {
...
}


Just note that a parameter can be set and empty.

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #5
.oO(Alvaro G Vicario)
*** Michael Fesser wrote/escribió (Thu, 05 Aug 2004 14:54:22 +0100):
if($_GET['parameter'] != ''){
echo foo();
}


This will show a notice if there's no such parameter.


Not for me. Does it depend on error_reporting settings?


Yep. On a development system error_reporting should be set to E_ALL to
show everything. Even a notice could be a reason for a hard to find bug.
Good code should be notice-free IMHO.
if (isset($_GET['parameter'])) {
...
}


Just note that a parameter can be set and empty.


Of course. If necessary additional checks should be done, but first you
have to test if the parameter exists at all.

Micha
Jul 17 '05 #6
"steve" <Us************ @dbForumz.com> wrote in
"-erc" wrote:
> <?php
> if ((!isset($s)) && (!isset($msg))) {
> echo("<table>
> ....
>
>
> I want some pictures displayed on the main page if its a new visit,
> but when they
> search and the url bar changes its skips displaying them, to save
> scrolling down all the time.
>
> I tried the above to read the parameters but get an error when they
> are not set.
>
> Is there something simple like this :
>
> if (url has no parameters) {
> echo("...draw front page section")
>
>
> Herc
>
> --
> www.TopCounters.com www.Chatty.net


url parameters are made available in $_GET array.

So you can say:
if (count($_GET) == 0) ....


perfect thanks all, I found

if (isset($_GET['s'])) echo

in the code just after I posted works a treat. Don't you hate scolling down after a
big blocky forum header every single post? much faster now.

Herc

Jul 17 '05 #7
I just want to point out that PHP's behavior also changed (somewhere around 4.2.0 ?)

test URL: http://www.foobar.com/test.php?hello

isset($_GET['hello']) will return true in newer versions of PHP
slightly older versions require .../test.php?hello= 1 (or = any value)
to get around this, you can check $_SERVER['QUERY_STRING']
Michael Fesser <ne*****@gmx.ne t> wrote in message news:<9u******* *************** **********@4ax. com>...
.oO(Alvaro G Vicario)
This should be enough:

if($_GET['parameter'] != ''){
echo foo();
}


This will show a notice if there's no such parameter.

Better:

if (isset($_GET['parameter'])) {
...
}

Micha

Jul 17 '05 #8

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

Similar topics

0
2702
by: Ville Mattila | last post by:
Hello readers, I'm trying to install the latest PHP4 version from the scratch. The configure string is following: ../configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-curl --enable-exif --enable-mbsting=all --with-gd --with-openssl --with-zlib-dir=/usr --with-zlib Everything goes well until the cURL should be...
6
14309
by: Web Developer | last post by:
Hi, I come across the term "type checking" very often in my readings on C++, and have never heard it in Java. Besides the simplistic answer that it checks the "type", what more does it mean? WD
22
4897
by: Qopit | last post by:
Hi there, I'm pretty new to Python and am trying to figure out how to get "will this code compile?"-like code checking. To me this is a pretty basic language/environment requirement, especially when working with large projects. It is *much* better to catch errors at "compile-time" rather than at run-time. One thing I've "found" is the...
4
2368
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?
16
2601
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project where someone suggested to me I was spending too much time writing error messages, and that I was therefore missing the benefit of using a scripting...
125
6517
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this problem. http://www.jilp.org/vol9/v9paper10.pdf Specifically, they measured the overhead of a bounds
7
2611
by: polas | last post by:
Afternoon everyone. I have a quick question about standard C. Generally speaking, in my experience, whenever one accesses an array there is never any bounds checking done (either statically during compilation or dynamically during runtime.) However, I was wondering if whether there is anything defined in the standard about this. The...
5
1282
by: K Viltersten | last post by:
I discovered that when requested http://localhost:52698/ws3/page.aspx and issued a call Response.Write(Request.Params.Count); i got 50 parameters in count. When i actually added some as in
4
2954
by: BillE | last post by:
I have found articles on line about using word interop for spell checking with visual studio applications. Most of the articles are several years old, though - VS2003, maybe 2005. I couldn't find anything for VS2008. Are there any new improvements in spell checking with VS2008? Thanks Bill
0
7828
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...
0
8186
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. ...
0
8329
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...
1
7936
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...
0
8197
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...
0
5377
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3821
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...
1
2335
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
1
1436
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.