Jump to content


Photo

Query string error: Undefined index: id

php

  • Please log in to reply
3 replies to this topic

#1 jackgoddy123

jackgoddy123

    Member

  • Members
  • PipPip
  • 11 posts

Posted 22 January 2014 - 06:21 AM

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

   Query1.php:

<?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:

<?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....

 



#2 PravinS

PravinS

    Advanced Member

  • Members
  • PipPipPip
  • 403 posts
  • LocationNashik, India

Posted 22 January 2014 - 06:28 AM

try uncommenting the if condition

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

Thanks & Regards,
PravinS | Blog


#3 jackgoddy123

jackgoddy123

    Member

  • Members
  • PipPip
  • 11 posts

Posted 22 January 2014 - 12:10 PM

I already tried it before but it does'nt work. :( 

If i echo the value in Query1.php  i get the correct out put. That means the variable value does not pass in query_1.php page. The " get()" is not working there. got stuck there.



#4 jackgoddy123

jackgoddy123

    Member

  • Members
  • PipPip
  • 11 posts

Posted 23 January 2014 - 02:43 AM

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:


<?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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com