Hallo php.de Community!
Ich habe ein problem mit meiner tokenbasierten Authenzifierungsanwendung:
Die Verifizierung läuft in diesem Include ab:
Das Skript läuft wen ich statt der Funktion $token direkt fomuliere und statt return echo. Wenn ich abe im Unterordner Test dieses Skript ausführe:
Kommen folgende Fehlermeldungen:
Notice: Undefined variable: db in /var/www/haohg/tokver.inc.php on line 6
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /var/www/haohg/tokver.inc.php on line 6
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /var/www/haohg/tokver.inc.php on line 7
Warum?
Danke im Voraus!
coder10
Ich habe ein problem mit meiner tokenbasierten Authenzifierungsanwendung:
Die Verifizierung läuft in diesem Include ab:
PHP-Code:
require_once("mysql.inc.php");
function tokver($token){
$time = time();
$sql = "SELECT UserId FROM token WHERE Token='$token' AND Expires > $time";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_assoc($result);
echo $row["UserId"];
}
PHP-Code:
<?php
require_once("../tokver.inc.php");
echo tokver("cb3ffa466e47e639b6a45f4635172d7b");
?>
Notice: Undefined variable: db in /var/www/haohg/tokver.inc.php on line 6
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /var/www/haohg/tokver.inc.php on line 6
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /var/www/haohg/tokver.inc.php on line 7
Warum?
Danke im Voraus!
coder10
Kommentar