Undefined index: id
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
What does the code that select the information from the database look like
“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
if i click the name of link it displays only 1 candidate' s details for all the names...
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Could you paste the code you use
“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
This s the code..
<!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);
$id= isset($_GET['Id']);
$sql=" SELECT * FROM members1 WHERE Id='$id' ";
$result = mysql_query($sql);
?>
<?php
while($rows=mysql_fetch_array($result)) { // Start looping table row
?>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Id:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Id']; ?></td>
</tr>
<tr>
<td width="14%" bgcolor="#F8F7F1"><span class="style4">Name:</span></td>
<td width="2%" bgcolor="#F8F7F1">:</td>
<td width="84%" bgcolor="#F8F7F1"><?php echo $rows['Name']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Email:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Email']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Phone:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Phone']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Company:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Company']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Profession:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Profession']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">City:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['City']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Country:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Country']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Zip:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Comments']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Username:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Username']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Password:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Password']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Date:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Date']; ?></td>
</tr>
<?php } ?>
</table></td>
</tr>
</table><br>
</body>
</html>
<!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);
$id= isset($_GET['Id']);
$sql=" SELECT * FROM members1 WHERE Id='$id' ";
$result = mysql_query($sql);
?>
<?php
while($rows=mysql_fetch_array($result)) { // Start looping table row
?>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Id:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Id']; ?></td>
</tr>
<tr>
<td width="14%" bgcolor="#F8F7F1"><span class="style4">Name:</span></td>
<td width="2%" bgcolor="#F8F7F1">:</td>
<td width="84%" bgcolor="#F8F7F1"><?php echo $rows['Name']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Email:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Email']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Phone:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Phone']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Company:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Company']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Profession:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Profession']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">City:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['City']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Country:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Country']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Zip:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Comments']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Username:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Username']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Password:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Password']; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"><span class="style4">Date:</span></td>
<td bgcolor="#F8F7F1">:</td>
<td bgcolor="#F8F7F1"><?php echo $rows['Date']; ?></td>
</tr>
<?php } ?>
</table></td>
</tr>
</table><br>
</body>
</html>
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Vilash wrote:if i click the name of link it displays only 1 candidate' s details for all the names...
Code: Select all
$sql=" SELECT * FROM members1 WHERE Id='$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 thats fine but...i wanted like if i click on particular name it shud display only his details.But what m getiing is if i click any names of the link it s displaying the same contents of a person for all the link...
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Looks like the value of $_GET['id'] is the same for all the links; is there any way to view the source code of this page, a url or could you paste it here
“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
<!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
while($row = mysql_fetch_array($result))
{
?><tr>
<td bgcolor="#FFFFFF"><?php echo $row['Date']; ?></td>
<td><a href="member_display1.php?Id=<?php if (isset($row['Id'])) 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>
<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
while($row = mysql_fetch_array($result))
{
?><tr>
<td bgcolor="#FFFFFF"><?php echo $row['Date']; ?></td>
<td><a href="member_display1.php?Id=<?php if (isset($row['Id'])) 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>
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Code: Select all
$result = mysql_query(" SELECT Date,Name,Email,Phone FROM members1 ");On the other page i noticed this
Code: Select all
$id= isset($_GET['Id']);Code: Select all
if isset($_GET['Id']) { $id = $_GET['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
No it s not displaying anything...if i use $id= isset($_GET['Id']); i atleast get same person's details bt if i use if isset($_GET['Id']) { $id = $_GET['Id']; } nothing s displaying
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Undefined index: id
Tested the script with the data you supplied and it works perfectly; Two things i changed to get it working
1. The query on the first page where you select the data; i added 'Id' into the query to select the record id as well.
2. This works;
If you can't get it working PM me and i'll send you the scripts i have
1. The query on the first page where you select the data; i added 'Id' into the query to select the record id as well.
Code: Select all
<?php if (isset($_GET['Id'])) { $id = $_GET['Id']; } ?>If you can't get it working PM me and i'll send you the scripts i have
“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
Thank you very much.....it s working now.
Re: Undefined index: id
Hi m getting udefined index notice
Re: Undefined index: id
Hi m getting undefined index(name,email.....) notice for the following script...
<!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);
$applieddate = date('d-m-y');
$sql = "INSERT INTO business( CompanyName,Address,BPhone, BEmail,Website,City,Country,Zip,Category,Description,ContactPerson,CEmail,CPhone,Designation,SpecialNote,Date)
VALUES ('$_POST[companyname]', '$_POST[address]', '$_POST[bphone]','$_POST[bemail]', '$_POST[website]', '$_POST[city]','$_POST[country]', '$_POST[zip]', '$_POST[category]', '$_POST[description]', '$_POST[contactperson]','$_POST[cemail]', '$_POST[cphone]','$_POST[designation]','$_POST[specialnote]','$applieddate' )" or die(mysql_error());
if(!mysql_query($sql,$con))
{
die('Error:' . mysql_error());
}
echo "<strong>Thanx for the Info</strong>" . "<br />";
mysql_close();
?>
</body>
</html>
<!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);
$applieddate = date('d-m-y');
$sql = "INSERT INTO business( CompanyName,Address,BPhone, BEmail,Website,City,Country,Zip,Category,Description,ContactPerson,CEmail,CPhone,Designation,SpecialNote,Date)
VALUES ('$_POST[companyname]', '$_POST[address]', '$_POST[bphone]','$_POST[bemail]', '$_POST[website]', '$_POST[city]','$_POST[country]', '$_POST[zip]', '$_POST[category]', '$_POST[description]', '$_POST[contactperson]','$_POST[cemail]', '$_POST[cphone]','$_POST[designation]','$_POST[specialnote]','$applieddate' )" or die(mysql_error());
if(!mysql_query($sql,$con))
{
die('Error:' . mysql_error());
}
echo "<strong>Thanx for the Info</strong>" . "<br />";
mysql_close();
?>
</body>
</html>