Reputation: 37
Require("dbconnect.php");//works is used on other another page
echo $Customer_id;//Displays correctly
Can anyone help?
Upvotes: 1
Views: 444
Reputation: 5834
First Check that use session variable is getting the data or not. If the Customer id is of varchar then you are missing single inverted comma in where clause.
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
Upvotes: 1
Reputation: 15609
Change the $sql.=
line to this:
$sql.= " WHERE Job_Customer_id = '$Customer_id'"
with the '
around $Customer_id
.
Upvotes: 1