Solved

Warning: Use of undefined constant

Posted on 2003-10-31
12
313 Views
Last Modified: 2006-11-17
I am using a php script for some purpose earlier it was running without any error but now it is displaying some errors mentioned below also an example of script is given.


<?php
$getty = $_GET[emladr];
echo $getty;
?>

it displays output as following


Warning: Use of undefined constant emladr - assumed 'emladr' in C:\W3Sites\dummyweb\www\msntr.php on line 2
hussainekazmi@hotmail.com

my page link is :

http://www.pindionline.net/msntr.php?emladr=hussainekazmi@hotmail.com

plese help me to resolve warning message why warning is displayed.

Thanks

0
Comment
Question by:hussaini
  • 3
  • 2
  • 2
  • +1
12 Comments
 

Accepted Solution

by:
keewooi earned 50 total points
Comment Utility
should be
$getty = $_GET['emladr'];
0
 
LVL 3

Expert Comment

by:red010knight
Comment Utility
Actually I would recommend $HTTP_GET_VARS['emladr']; over $_GET as it helps to secure the site a bit better.

Red010knight
0
 
LVL 11

Expert Comment

by:Zontar
Comment Utility
>  Actually I would recommend $HTTP_GET_VARS['emladr']; over $_GET as it helps to secure the site a bit better.

The PHP Manual says that superglobals are preferred, and that the $HTTP_*_VARS arrays are deprecated and likely to go away in a future release. (You will be able to turn them off in PHP5. This isn't and won't be the case with superglobals.)
0
 

Expert Comment

by:keewooi
Comment Utility
Found this from PHP manual:

Since PHP 4.1.0, the preferred method for retrieving external variables is with the superglobals mentioned below. Before this time, people relied on either register_globals or the long predefined PHP arrays ($HTTP_*_VARS). As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 11

Expert Comment

by:Zontar
Comment Utility
That's exactly what I was referring to, thanks.
0
 
LVL 3

Expert Comment

by:ashoooo
Comment Utility
emladr should be in double or single quotes
0
 
LVL 3

Expert Comment

by:red010knight
Comment Utility
Single, though I don't think that should actually matter in the code...

Red010Knight
0
 
LVL 3

Expert Comment

by:ashoooo
Comment Utility
It wasnt a question.
0
 
LVL 11

Expert Comment

by:Zontar
Comment Utility
Double, if you want to use variable interpolation:

$i = 2;
$_GET["something$i"] -->> $_GET["something2"]
$_GET['something' . $i] -->> $_GET["something2"]
$_GET['something$i'] -->> error (probably)

At any rate, keewooi pointed that out in the first response to this question.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now