Query string error: Undefined index: id

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jackgoddy123
Forum Newbie
Posts: 14
Joined: Sat Jan 11, 2014 8:10 am

Query string error: Undefined index: id

Post by jackgoddy123 »

Hello experts,
I am using a query string code. I want to "get" variable of one page to another page.

Query1.php:

Code: Select all

<?php
$konek = mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("test",$konek) or die("Cannot connect to the database");
$query = mysql_query("select * from persons where id='1'");
$row = mysql_fetch_array($query);
$q= $row['details'];
?>

<a href='query_1.php?id=" . $q . "'>aa</a>


query_1.php:

Code: Select all


<?php
//$ab=1;

//if(isset($_GET['id'])) 
$ab= $_GET['id'];
echo $ab;
?>

The above code does not run and give error:

Notice: Undefined index: id

I am not geting what i am missing.
So, can some help me out wid my mistake....
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: Query string error: Undefined index: id

Post by pbs »

try removing comment of line

if(isset($_GET['id']))
jackgoddy123
Forum Newbie
Posts: 14
Joined: Sat Jan 11, 2014 8:10 am

Re: Query string error: Undefined index: id

Post by jackgoddy123 »

Well..., the code works perfectly fine in Query1.php page. But if i would nt have pasted my link
i.e echo "<a href='edit_last_follow.php?id=" . $a . "'>aa</a>";

inspite only :

echo "<a href='edit_last_follow.php?id=" . $a . "'></a>";

so how will i get the $a on my next page which is query_1.php page:

Code: Select all

<?php  

if(isset($_GET['id']))   
$ab= $_GET['id'];  
echo $ab;  
?>
I want to echo $a of Query1.php page on query_1.php page.
I tried with the code above. I am stuck what i am missing.
Post Reply