Require("dbconnect.php");//works is used on other another page
echo $Customer_id;//Displays correctly
有人可以帮忙吗?
答案 0 :(得分:1)
将$sql.=
行更改为:
$sql.= " WHERE Job_Customer_id = '$Customer_id'"
'
周围的$Customer_id
。
答案 1 :(得分:1)
首先检查使用会话变量是否正在获取数据。 如果Customer id是varchar,那么在where子句中缺少单个倒置逗号。
session_start();
$Customer_id = $_SESSION['id'];
Require("dbconnect.php");//works is used on other another page
$sql = "SELECT Job_id FROM Job";
$sql.= " WHERE Job_Customer_id = '$Customer_id'";
$stmt = $dbh->query($sql);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$Job_id = $row['Job_id'];
echo $Customer_id;//Displays correctly
echo $Job_id;//Curently dose not display anything