I’m getting a error 500 when i try to select something from the database:
I’ve test it without the select function and just return a random string and it worked. But when i try to get a value from the database i’ll get an error 500.
This is the function:
public function seasons_rules($CheckIn)
{
$Request = $this->db->get_results(
$this->db->prepare(
"SELECT A.rule_id
FROM $this->booking_rules_seasons_table AS A
INNER JOIN $this->seasons_dates_table AS B
ON B.season_id = A.seasons_id
INNER JOIN $this->booking_rules_table AS C
ON A.rule_id = C.id
WHERE ('%s' BETWEEN B.start_date AND B.end_date) OR C.all_seasons = 1
",$CheckIn), ARRAY_A);
$RulesIDs = '';
if ( ( $Request == NULL ) || ( count( $Request ) == 0 ) ) {
return false;
} else {
foreach ($Request as $response) {
$RulesIDs .= $response['rule_id'].',';
}
return $RulesIDs;
}
}
When i run the query directly into database. I’ll get a result back so there isn’t any errors in the query.
You’re passing the variable inside the string in the wrong way.
If you want to pass a variable of an object inside a string, you use this syntax:
You’re passing the variable directly without the braces.