Error 500 WordPress database

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.

Read More

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.

Related posts

1 comment

  1. 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:

    echo "This is my string: {$obj->string}";
    

    You’re passing the variable directly without the braces.

Comments are closed.