$show =$_GET; //if i put the id manually it works and the content get changes
print_r($_GET); // Working
$news_sql=mysql_query( "SELECT *FROM latestnews WHERE id = '$show' ");//i cant retrieve id here
while($rsnews = mysql_fetch_assoc($news_sql)){

my code


6 Years
Discussion Span
Last Post by nonshatter

Check your form method in html page whether you have given method="get" or "post". if you gave get means, there will be no problem. If you use post and here you use $_GET, it definitely be a problem. And additionally, i suggest you to use post method, it is more reliable and have many advantages than Get method and this problem will get over. There is nothing in your code. Try it and solve.
If still any probs, please let me know..


You can still use the $_GET method to grab variables from your URL using form method="post", but you'd have to append the Id variable to the form action like this:

<form action="<?php 'process.php?id=$id' ?>" method="post">

(that's if you're actually using a form, you haven't stated whether you are).

Can you be a bit more specific with what you're trying to do?


Oh... But this id passing through code cannot works sometimes in Mozilla, IE and Opera. This will not works perfectly some times. So, directly passing through code is not good practice. I am sorry if my suggestion hurts..


Your sql query has a syntax error in it. There should be a space after *:

$news_sql=mysql_query( "SELECT * FROM latestnews WHERE id = '$show' ");

Edited by madCoder: n/a


The query will still work even if there isn't a space between the asterisk and the 'FROM'
The query looks fine. The issue is most likely with the variable not being set.
Try this and post the result:

    $show = $_GET['id'];

    if (isset($show))
        $news_sql = mysql_query("SELECT *FROM latestnews WHERE id='$show'") or die("MySQL syntax error: ". mysql_error());
    else { die ('$show isn't set! the $_get didn't work...'); }

Note:- The $_GET must mean that the URL has a variable called 'id' (www.site.com/script.php?id=2)
And say I used $_GET then the url should be something like (www.site.com/script.php?foo=bar)

Edited by nonshatter: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.