Author Topic: $_GET['id'] not working  (Read 11119 times)

Rahul Kaushik

  • Newbie
  • *
  • Posts: 18
$_GET['id'] not working
« on: December 03, 2011, 11:08:51 AM »
i am facing problem to get  id from data base i tried many time and code goes  look like this
      $id = ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) ? intval( $_GET['id'] ) : 0;
        $id = ereg_replace('[^0-9]','',$_GET['id']);
       $q="SELECT * FROM countdown Where id =$_GET[id]";
       $result=mysql_query($q,$db);
       $num=mysql_num_rows($result);
       echo $num;
 pls give a better way to complete it
                                                            rahul kaushik

phpdeveloper

  • Newbie
  • *
  • Posts: 39
Re: $_GET['id'] not working
« Reply #1 on: December 22, 2011, 06:26:09 AM »
Hi rahul,
           
         you can work like this if you are working in any open source or home .

if(isset($_GET['id']) && preg_match('/^[0-9]{1,8}$/', $_GET['id']))
      {
       $Countdown = $_GET['id'];
 $result = "SELECT * from table name where id= $Countdown";

hope it will work for you.....
       
      

 

X

Do you know?

IfandBut.com is place where you can meet serious webmasters and make new ties to grow your business.
Join Now!