Undefined index: id
Moderator: General Moderators
Undefined index: id
Hi, i am new to php,have created a login page which s working properly. But m getting undefined index error in admin login page.The code s below.
Getting error in
(<td><a href="member_display1.php?Id=<?php echo $row['Id'] ?>"><?php echo $row['Name']; ?></a></td>)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$con = mysql_connect("localhost", "login", "login123" );
if(!$con)
{
die('Could not connect:' . mysql_error());
}
mysql_select_db("test",$con);
$result = mysql_query(" SELECT Date,Name,Email,Phone FROM members1 ");
?>
<table width="100%" border="1" >
<tr>
<th>Date</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
</tr>
<?php
$id=$_GET['id'];
while($row = mysql_fetch_array($result))
{
?><tr>
<td bgcolor="#FFFFFF"><?php echo $row['Date']; ?></td>
<td><a href="member_display1.php?Id=<?php echo $row['Id'] ?>"><?php echo $row['Name']; ?></a></td>
<td><?php echo $row['Email']; ?></td>
<td><?php echo $row['Phone']; ?></td>
<?php } ?>
</tr>
</table>
</body>
</html>
If anybody can troubleshoot please revert me as soon as possible..
Getting error in
(<td><a href="member_display1.php?Id=<?php echo $row['Id'] ?>"><?php echo $row['Name']; ?></a></td>)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$con = mysql_connect("localhost", "login", "login123" );
if(!$con)
{
die('Could not connect:' . mysql_error());
}
mysql_select_db("test",$con);
$result = mysql_query(" SELECT Date,Name,Email,Phone FROM members1 ");
?>
<table width="100%" border="1" >
<tr>
<th>Date</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
</tr>
<?php
$id=$_GET['id'];
while($row = mysql_fetch_array($result))
{
?><tr>
<td bgcolor="#FFFFFF"><?php echo $row['Date']; ?></td>
<td><a href="member_display1.php?Id=<?php echo $row['Id'] ?>"><?php echo $row['Name']; ?></a></td>
<td><?php echo $row['Email']; ?></td>
<td><?php echo $row['Phone']; ?></td>
<?php } ?>
</tr>
</table>
</body>
</html>
If anybody can troubleshoot please revert me as soon as possible..
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Code: Select all
<?php $result = mysql_query(" SELECT Date,Name,Email,Phone FROM members1 "); ?>Hth
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Undefined index: id
How can i modify it...
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Assuming you have an id column in the database the query below should remedy the problem
Code: Select all
<?php $result = mysql_query(" SELECT Id, Date,Name,Email,Phone FROM members1 "); ?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Undefined index: id
i did this bt its nt working... i wanted to display the registered members and if i click the names of the registered members it should display their details...i wanted to give link to their names through their id.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Are you still receiving the error? What fields do you have in your database and which one contains a value unique to each user
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Undefined index: id
ya i am still getting error, i have id,name,email,phone,company,profession,city ,country,zip,comments,username,password,date.
id s primary key
id s primary key
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Paste the error here please; the error is really a notice and it indicates a variable that is not set. Have a look at the results of your query, see if the id value is passed along
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Undefined index: id
Notice: Undefined index: id in C:\wamp\www\Extra\login9\member_display.php on line 41
this s the error m getting...
this s the error m getting...
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
This checks if the value is set; if it is it will echo the value to the browser; it should fix the notice you are getting; Does the value of $row['id'] display at all?
Code: Select all
<?php if isset($row['id']) echo $row['id']; ?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Undefined index: id
ya the value of $row['id'] is displaying.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
And the notice?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Undefined index: id
notice s still there...where should i include the this php script <?php if isset($row['id']) echo $row['id']; ?>
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Assuming this is line 41 you can modify like the code below
Code: Select all
<td><a href="member_display1.php?Id=<?php if isset($row['Id']) echo $row['Id']; ?>"><?php echo $row['Name']; ?></a></td>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Undefined index: id
nw the link is working...bt if i click on the link i displays only the header nt the contents ...
Id :
Name:
Email :
Phone :
Company :
Profession:
City :
Country:
Zip :
Comments:
Username:
Password:
Date:
Id :
Name:
Email :
Phone :
Company :
Profession:
City :
Country:
Zip :
Comments:
Username:
Password:
Date: