Solved

Warning: Use of undefined constant

Posted on 2003-10-31
12
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
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…

726 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