0

I have used urldecode to receive a member ID from a previous site. The correct ID is being displayed in the URL but I can't fetch information from the database.

<?php

$id = urldecode(trim($_GET['memberID']));
$query = "SELECT * FROM members WHERE memberID = '".$id."'";

if ($result = $db->query($query)) {

while ($row = $result->fetch_assoc()){
    printf("%s (%s)\n", $row["memberID"], $row['name']);
}
}

?>

All I get is a blank screen.

P A Hemingstam
  • 93
  • 2
  • 12
  • You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are also **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that a modern API would make it easier to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Feb 06 '13 at 17:04
  • Ah, thanks for pointing that out. I have now updated it. – P A Hemingstam Feb 06 '13 at 21:54

2 Answers2

1

change mysql.error() to mysql_error()

-1

$query = "SELECT * FROM members WHERE memberID = '".$id."'";

user1508136
  • 65
  • 1
  • 1
  • 9