Having a problem getting the variable from the URL into my SQL statement. What am I doing wrong? If I hard code a variable in, I get the output.

whatson.php
....
echo"<tr>
<td width='15%' align='right'><font face='Trebuchet MS' size='2'>$startdate</font></td>
<td width='2%'><font face='Trebuchet MS' size='2'>&nbsp;</font></td>
<td><font face='Trebuchet MS' size='2'>$title</font></td>
<td width='15%'><font face='Trebuchet MS' size='2'><a href='whats_detail.php?$wid=$whatsid'>More >></a></font></td>
</tr>";
.....

whats_detail.php
.....
<?php
include ("config.inc.php");
$id=$_GET['wid'];
mysql_connect("$db_host", "$username", "$password");
mysql_select_db("$db_name") or die( "Unable to select database");

$sql="SELECT whatid, cost, venue, title FROM whatson WHERE whatid = '$id'";
$result=mysql_query($sql);	
$myrow=mysql_fetch_array($result);

?>
.....

Thanks in advance.

    In the first echo statement:

    // change this...
    <a href='whats_detail.php?$wid = $whatsid'>
    // ...to this...
    <a href='whats_detail.php?wid=$whatsid'>
    

      Thanks NotDog, no dice though unfortunately. Didn't work.

      In the URL reads this:
      .............whats_detail.php?=1

      So the id is there.... but I can't pick it up on the second page.

        Solved it myself: I took the $ out from in front of wid -----

        <a href='whats_detail.php?$wid=$whatsid'>More >></a>
        became
        <a href='whats_detail.php?wid=$whatsid'>More >></a>

        Thanks for the help anyway

          bladesedge wrote:

          Solved it myself: I took the $ out from in front of wid -----

          <a href='whats_detail.php?$wid=$whatsid'>More >></a>
          became
          <a href='whats_detail.php?wid=$whatsid'>More >></a>

          Thanks for the help anyway

          Which was one of the changes in my first reply. 😉

            Ahh ok sorry just noticed. Me not read goodly 🙂

              bladesedge wrote:

              Ahh ok sorry just noticed. Me not read goodly 🙂

              And me was too lazy to explain my changes. 😉

                Write a Reply...