对不起..我只是想早点澄清我的帖子。
<?php
$db = pg_connect("host=localhost dbname=dbname user=user password=password");
$sql = "SELECT * FROM users WHERE user_id = 8320 AND password = 'admin' ";
$query = pg_query($sql);
$row = pg_fetch_array($query);
var_dump($row); //DUMPS EXACTLY WHAT I WANTED.. BUT WHEN I put it on a function like this.
?>
<?php
function checkLogin($user_id, $password)
{
$db = pg_connect("host=localhost dbname=dbname user=user password=password");
$sql = "SELECT * FROM users WHERE user_id = $user_id AND password = $password ";
$query = pg_query($sql);
$row = pg_fetch_array($query);
return $row;
}
?>
//CALL HERE
$data = checkLogin(8320, 'admin'); var_dump($data); // 转储 NULL
为什么会这样?