Fatal error: Call to undefined function sanitize() in general.php on line 5
这是general.php:
include"connect.php";
function user_id_from_username($username)
{
$username = sanitize($username); //This is line 5/general.php
return mysql_result(mysql_query("SELECT `id` FROM `users` WHERE `username`='$username'"),0, 'id');
}
connect.php 包含我的数据库连接,我有一个困惑,我需要将它包含在函数中还是函数会自动连接到我的数据库?
我正在使用 user.php 中的函数作为:
if(isset($_GET["username"])===true && empty($_GET["username"])===false)
{
$username = $_GET["username"];
$user_id = user_id_from_username($username);
echo"$user_id";
}