Jump to content

[SOLVED] I am having alot of trouble changing a variable thru the URL, please help


wickedawsome

Recommended Posts

alright,  I am pretty new to php, so bare with me...

 

I am making a link to self with the id of a row in the mysql table  ie:  test.php?id=1    is how it looks in the URL

 

now obviously I am trying to set id=1  so that when the page reloads, an isset function catches it and deletes that ID from the table...  now the problem is...that the isset is coming back false...and I have no idea why.

 

here is the code

 

echo ($id);//to see the value of id, it does not show anything

 

    if (isset($id)) //obviously skips this part as said

    {

$conn = mysql_connect($host, $user, $password) or die(mysql_error());

$db = mysql_select_db($dbName, $conn) or die(mysql_error());

      $sql = 'DELETE FROM names WHERE id = $id ';

      if (mysql_query($sql)) {

        echo("<P>The ID has been deleted.</P>");

      }

      else {

        echo("<P>Error deleting ID: " .

            mysql_error() . "</P>");

      }

      }

else  //goes thru fine.

echo "failed";

 

 

so...I would asume that the var is not carying thru to the code...  here is how I am sending it to the code if that is relevant

 

<A HREF="test.php?id=<?php echo $id; ?>">Delete this id</A>

 

another recomendation as to how to do this is more than welcome, I just need it to work. 

 

Thank you very much

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.