Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.