Skip to content Skip to sidebar Skip to footer

Run Php Function Using Ajax To Update Phpbb Template Variable

NOTE: There are a lot of details here, so if anyone needs a condensed version of this, I'm happy to summarize. I am trying to run a function in my php file, that will in turn, upda

Solution 1:

Think I found the problem. At the beginning of my PHP, I have an include statement to include the PHP file containing the class for connecting to the database. In the statement $result = $db->sql_query($sql);, $db is set in this other PHP file. I don't entirely understand, but because of that, $db was outside of the scope of my function get_vehicle_makes(). I had to create a class inside my PHP file, and pass $db as a parameter to the function using:

classvehicle{

    publicfunction__construct($db)
    {
        $this->db = $db;
    }

functionget_vehicle_makes()
{
    $sql = 'SELECT make FROM phpbb_vehicles
            WHERE year = ' . $select_vehicle_year;  
    $result = $this->db->sql_query($sql);

Hope this helps.

Post a Comment for "Run Php Function Using Ajax To Update Phpbb Template Variable"