Solved

Warning: Use of undefined constant

Posted on 2003-10-31
12
316 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Amazon Redshift 2 26
unset shopping cart session 15 31
Move wordpress site 3 18
Website Interactive tool that will do calculations 3 27
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

910 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

23 Experts available now in Live!

Get 1:1 Help Now