0

Hey guys,

I am trying to dynamically parametize my url, but it gets lost and I have no idea why. Perhaps some insight from you guys will help. Here's the code:

while($row = mysql_fetch_assoc($getID))
{
    echo "<tr>";
    echo "<td><a href='View.php?id='" . $row['ID'] . "'>" . $row['ID'] . "</a>" . "<br />" . "-" 
    . $row['Description'] . "</td>";
    echo "<td style='text-align:center; width:35%'>" . $row['dateCreated']. "</td>";
    echo "</tr>";
}

In View.php I have this to try and debug:

if (isset($GET['ID']))
    echo $GET['ID'];
else
    "Not set";

When I am redirected to this page, nothing displays and the url reads View.php?id=

Why is it empty?

Thanks

6
Contributors
7
Replies
44
Views
4 Years
Discussion Span
Last Post by while(!success)
0

First of all, you should get familiarized with mysql_fetch_array, since mysql_fetch_assoc is getting dropped in php5...

Second, check your mysql syntax for any errors. Does $row['dateCreated'] print any value?

0

Check if $getID has some value or not
by

if (!$getID) {
    echo "Could not successfully run query" . mysql_error();
    exit;
}

May be your query is having some error

Edited by code_rum

0

I am wondering what your code means, correct me if I am wrong, but when you write;

if (isset($GET['ID']))
    echo $GET['ID'];

Don't you mean;

if (isset($_GET['ID']))
    echo $_GET['ID'];

First check that out, then let us know what happens

0
echo "<td><a href='View.php?id='{$row['ID']}'>{$row['ID']}</a><br />-{$row['Description']}</td>";

I'm assuming $row['ID'] is an empty string or null. As is the description.

As webville points out $_GET['id'] would be the obvious error here.

2

First of all, you should get familiarized with mysql_fetch_array, since mysql_fetch_assoc is getting dropped in php5...

This statement is misleading. The reason mysql_fetch_assoc() is getting dropped is because the mysql extension is getting dropped. So to "get familiarized" with mysql_fetch_array() will not help. Instead use mysqli_fetch_assoc() with the mysqli extension (or even better, do it the OOP way!).

Votes + Comments
thanks. Didn't know this
agreed
0

Hey guys,

I appreciate the replies. To all those that pointed out the '$_GET' error, thank you! On the other hand it still did not echo out anything.

To clarify, however, everything gets echoed out in the while statement. $row['ID'], $row['Description'] and $row['dateCreated'] all get echoed out, but the first $row['ID'] doesn't show in the url.

0

Hi again,

I just looked through the code carefully and found that I had an extra apostrophe right after ?id=
Doh! Regardless, thanks for the help guys!

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.