-1

I can't figure out why when i try to select a string from a database it throws an error and truncated the string. The code I'm using is:

<?php define('something_made_for_security', true); include('mysql.php');
if(!sqlConnect()) die();

echo $_COOKIE['key'];
$currSession = Query('SELECT * FROM {sessioni} WHERE uid = 1 AND key = {0}', $_COOKIE['key']); //Queries the datatabase

if(NumRows($currSession)) { //Get number of rows
    $cuser = Fetch(Query('SELECT * FROM {utenti} WHERE nome = '.$_COOKIE['uid']));
    print_r($cuser);
}

Output of this is: http://prntscr.com/g4bkgs . Looks like the issue is not php-specific, since it does the same in PhpMyAdmin.

So why is the string truncated. Field 'key' is char(128) for a SHA512 hash.

By edit: i forgot that "key" was a keyword and i generally do not encapse strings.

1 Answers1

0

try this

$currSession = Query('SELECT * FROM {sessioni} WHERE uid = 1 AND `key` = {0}', $_COOKIE['key']); //Queries the datatabase
Ali Faris
  • 17,754
  • 10
  • 45
  • 70