Solved

Warning: Use of undefined constant

Posted on 2003-10-31
12
318 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
ID: 9661909
should be
$getty = $_GET['emladr'];
0
 
LVL 3

Expert Comment

by:red010knight
ID: 9662919
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
ID: 9664253
>  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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Expert Comment

by:keewooi
ID: 9664941
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
 
LVL 11

Expert Comment

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

Expert Comment

by:ashoooo
ID: 9716452
emladr should be in double or single quotes
0
 
LVL 3

Expert Comment

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

Red010Knight
0
 
LVL 3

Expert Comment

by:ashoooo
ID: 9717560
It wasnt a question.
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9719389
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
This article discusses four methods for overlaying images in a container on a web page
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

803 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