0

keep getting this error: Undefined index: id in C:\xampp\htdocs\Projeto\edit.php on line 5
But i checked phpmyadmin and i have a index for id, it's in the table. Why do I get this? Never happened before.

<?php

require 'conf/connection.php';

$id = $_GET['id'];

$choose_user = mysql_query("SELECT * FROM users WHERE id = '$id'");
$r = mysql_fetch_array($choose_user);

?>
2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by richaell
0

It's the fact that there is no url querystring.

Use this:

<?php
if(isset($_GET['id'])){ 
  require 'conf/connection.php';
 
  $id = $_GET['id'];
 
  $choose_user = mysql_query("SELECT * FROM users WHERE id = '$id'");
  $r = mysql_fetch_array($choose_user);
}
?>

You also need to clean your input - have a look at mysql_real_escape_string() in the php.net manual.

This question has already been answered. 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.