-3

I have a problem with mysql_fetch_array, here's my code. Another thing, what id mysqli_* functions?

<?php
session_start();
include "config.php";
$conex = mysql_connect("localhost", "root");
$name = $_GET['name'];
$selected = "SELECT id,password,email,name FROM users WHERE username = '".$name."'";
$query = mysql_query($selected,$conex);
$rows = mysql_num_rows($query);
if($row = mysql_fetch_array($query))
{
        $username = $row['username'];
        $id = $row['id'];
        $password = $row['password'];
        $email = $row['email'];
}
?>

and when I run it on WAMP,it happens:

http://spectrum-solaris.besaba.com/stack3.PNG

Mat
  • 195,986
  • 40
  • 382
  • 396
  • 1
    mysqli functions are those little things that help you patch that gaping injection vulnerability in your code. – JJJ Nov 30 '13 at 08:03
  • Replace $query = mysql_query($selected,$conex); with $query = mysql_query($selected,$conex) or die(mysql_error()); You'll get the error – Nitesh morajkar Nov 30 '13 at 08:05

1 Answers1

0

"mysql_num_rows() and mysql_fetch_array() expects parameter to be resource, boolean given"
meaning that variable $query is of type 'boolean'. This is happening because the statement
mysql_query($selected,$conex) may have been returning a "false" result.

Check the SQL query...

Adi
  • 367
  • 1
  • 3
  • 13