-3

I'm making a website so once your logged in it goes to your profile but once you log in it gives me this error. Unknown column 'tom' in 'where clause' Tom is the username. it don't tell me which line but im pretty sure its this one.

$result =  queryMysql("SELECT * FROM profiles WHERE user=`$user`");

quertyMysql is defined in another file.

function queryMysql($query)
{
    global $connection;
    $result = $connection->query($query);
    if (!$result) die($connection->error);
    return $result;
}

is this enough code for anyone to tell me whats doing wrong?

2 Answers2

0

Do the following

echo "SELECT * FROM profiles WHERE user=`$user`";

and you will see immediately whats wrong.

probably you should use

 "SELECT * FROM profiles WHERE user='$user'"

you cant use backticks for a parameter, only for table and column names

Etixpp
  • 320
  • 2
  • 11
0

Please change the query with this one :

$result =  queryMysql("SELECT * FROM profiles WHERE user='".$user."'");
Nitesh Singh
  • 328
  • 3
  • 13