Jump to content

class help


vegnadragon

Recommended Posts

I am using phpbb but this is a regular php probelm, and i am new to object oriented, but the even thou i assing $data the value of the sql query, it doesn't contain any value on it. Any help?

 

class status

{

    var $data = array();

   

    //This function will display all status

    function status()

    {

        global $db, $auth, $user, $template, $game;

global $phpbb_root_path, $phpEx, $config;

       

        $user_id = $user->data['user_id'];

       

        $query = "SELECT * FROM status WHERE id_ref = ($user_id)  LIMIT 1;";

        $result = $db->sql_query($query);

        $this->data = $db->sql_fetchrow($result);

        $db->sql_freeresult($result);

 

    }

Link to comment
https://forums.phpfreaks.com/topic/86821-class-help/
Share on other sites

I'm not sure what sql_fetchrow() is doing but if it just calls mysql_fetch_row then your $data variable will be an enumerated array, not a associative one.

 

Also, I'm not sure if this:

"SELECT * FROM status WHERE id_ref = ($user_id)  LIMIT 1;"

is valid SQL syntax. Can someone clarify? Either way, try this:

"SELECT * FROM `status` WHERE `id_ref` = '$user_id'  LIMIT 1;"

Link to comment
https://forums.phpfreaks.com/topic/86821-class-help/#findComment-443899
Share on other sites

I'm not sure what sql_fetchrow() is doing but if it just calls mysql_fetch_row then your $data variable will be an enumerated array, not a associative one.

 

Also, I'm not sure if this:

"SELECT * FROM status WHERE id_ref = ($user_id)  LIMIT 1;"

is valid SQL syntax. Can someone clarify? Either way, try this:

"SELECT * FROM `status` WHERE `id_ref` = '$user_id'  LIMIT 1;"

 

I am using phpbb. sql_fetchrow is function that emulates mysql_fetchrow but with stuff, it all works, if i change $this->data for any variable i get my wanted array. i just can't asign it to my array. I want to assign the value on the array outside my function.

Link to comment
https://forums.phpfreaks.com/topic/86821-class-help/#findComment-443903
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.