0

Hi

Please see code below, when I query my db I am getting an unefined variable issue, any ideas?

I am quiet new to PHP so please help.

 mysql_connect("localhost","root","");
 mysql_select_db("db");

 $id = intval($_GET['id']);
 $res = "SELECT * FROM table WHERE id=$id";

 echo "<table>";
 echo "<tr>";

 echo "<td>"; echo "<h4>".$row['item']."</h4>"; echo "</td>";  echo "</tr>";
 echo "<td>";?> <img src ="<?php echo $row['image']; ?>" height ="100" width ="100"> <?php echo "</td>";
 echo "</tr>";

 echo "<td>"; echo $row['description']; echo "</td>"; echo "</tr>";
 echo "<td>"; echo $row['price']; echo "</td>";

 echo "</tr>";
 echo"</table>";
 ?>

Edited by pritaeas: Added markdown.

4
Contributors
3
Replies
23
Views
4 Years
Discussion Span
Last Post by broj1
0

It could be that $_GET['id'] does not exist. To make sure it exists, do a check:

if(isset($_GET['id'])) {
    $id = intval($_GET['id']);
} else {
    // do something to handle the error
}

It would help much if you posted the exact error message (error message text including variable names, line number etc).

Ups, I just figured out that you did not send the query at all. Well, above still applies.

Edited by broj1

This topic has been dead for over six months. 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.