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

Recommended Answers

All 7 Replies

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?

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

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

Member Avatar for diafol
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.

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!).

commented: agreed +14
commented: thanks. Didn't know this +10

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.

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.