0

Why do I get undefined variable errors when all the variables are defined below e.g. 'client_id' and 'order_limit' etc?

if (isset($id)) {
$sql = ("SELECT * FROM client WHERE client_id = '".$_GET["id"]."'");
    $result = mysql_query($sql);

if ($row = mysql_fetch_assoc($result)) {
    $client_id = $row["client_id"];
    $client_name = htmlentities($row["client_name"]);
    $order_limit = number_format($row["order_limit"]);
    $notes = htmlentities($row["notes"]);
} else {

    die();
}
}
Ross
  • 66
  • 12
  • 2
    FYI, [you shouldn't use `mysql_*` functions in new code](http://stackoverflow.com/questions/12859942/). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [red box](http://php.net/manual/en/function.mysql-connect.php)? Learn about [*prepared statements*](https://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide which one is best for you. – John Conde Jul 12 '17 at 12:00
  • Post the error please. – Alex Lucaci Jul 12 '17 at 12:00
  • Are you sure those columns exist in that table? – John Conde Jul 12 '17 at 12:00
  • 1
    `print_r($row)` and add result on this question.. and also i am mention that don't use mysql_* – Bilal Ahmed Jul 12 '17 at 12:01
  • They're only defined if `$id` is set. – jeroen Jul 12 '17 at 12:08
  • The columns definitely exist in the table, not sure what to do at all. – Ross Jul 12 '17 at 13:05

0 Answers0