-2

I am trying to make a working script with LOGIN and REGISTER, and i can't read user information after he logged in.

I am using cookies to make sure he is "online" and he is, everything is working good.

The problem is that i can't read his information, don't know why.

$sql = "SELECT mod FROM korisnici where user = "'.$_COOKIES['username'].'"";

And if i put cookies['username'] instead of admin(real username), still doesnt work.

I am trying to get only MOD.

Rikard Olsson
  • 841
  • 1
  • 7
  • 28
  • 3
    You have syntax errors. Take a look how you use single and double quotes. – Jakub Matczak Feb 06 '17 at 13:02
  • Your PHP error log is telling you about your syntax error. Always check the error log. Also, your code is wide open to SQL injection, you should use prepared statements with query parameters instead. – David Feb 06 '17 at 13:03
  • There is no errors, this is code: http://prntscr.com/e56ial this is output: http://prntscr.com/e56hp2 – Никола Р. Feb 06 '17 at 13:18
  • 1
    @НиколаР.: `"There is no errors"` - Wrong. Just because you're not *checking* for errors doesn't mean there *are no* errors. Ignoring a problem doesn't solve the problem. – David Feb 06 '17 at 19:18

1 Answers1

-1

I think your apostrophe aren't at the right place:

$sql = "SELECT mod FROM korisnici where user = '" . $_COOKIES['username']. "'";
Vizz85
  • 195
  • 1
  • 13