954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Undefined Index: email

I know there is a lot of threads already on this website, but I cant find any that remotely looks like it'd be help to me.

I am getting frustrated over this bit of code error. Any help would be appreciated.

php line 64

$emails = $_REQUEST['email'];


$data = mysql_query("SELECT current_image, email FROM employees where email='$emails'") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array( $data )) { //Outputs the image and other data


Notice: Undefined index: email in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_u020672/public_html/assignment/user/members.php on line 64


I am asking it to take email and current image from my database, trying to return an image that relates to the email of a user.


Thanks, S

s1Lolz0rz
Newbie Poster
3 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

It means that a form field or querystring parameter called email doesn't exist. You should avoid using $_REQUEST - use $_POST or $_GET.

Where is $_REQUEST['email'] coming from? A form, a querystring? It appears to be none of these in your case.

It often pays to use an if statement to check the existence of a $_POST array.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

Thanks for the reply.

Basically i want the return to be email='$emails'" and i declared the variable ($email)

email is in the mysql database
i am going to ask it to return the image that relates to the email address.


there is no form, it's for a user profile so the user's image will be displayed for the user's email address.

s1Lolz0rz
Newbie Poster
3 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

THe whole point is

$emails = $_REQUEST['email'];


The $_REQUEST['email'] doesn't exist.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

how do I call the $emails variable then from the field known as 'email' in my database

s1Lolz0rz
Newbie Poster
3 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

Well, it depends what you're trying to do. Usually somebody logs in and has their id stored in a session variable. You then use that stored session variable to get the data (email etc) from the DB.

It's not clear what you're trying to achieve here. The $emails has to come from somewhere. AFAIK, you aren't giving it a value anywhere.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: