• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$result->fetch_assoc() is failing

#1
I am trying to modify my password code with some code I got from from Codex. The Codex code has this:

PHP Code:
       if(array_key_exists("returnType",$conditions) && $conditions['returnType'] != 'all'){
 
           switch($conditions['returnType']){
 
               case 'count':
 
                   $data $result->num_rows;
 
                   break;
 
               case 'single':
 
                   $data $result->fetch_assoc();   <<<<this line
                    break
;
 
               default:
 
                   $data '';
 
           }
 
       }else{
 
           if($result->num_rows 0){
 
               while($row $result->fetch_assoc()){
 
                   $data[] = $row;
 
               }
 
           }
 
       }

But the fetch_assoc line is failing with this errorCall to undefined method CI_DB_mysqli_result::fetch_assoc()

Anyone know why
Reply

#2
(05-15-2018, 02:03 PM)richb201 Wrote: I am trying to modify my password code with some code I got from from Codex. The Codex code has this:

PHP Code:
       if(array_key_exists("returnType",$conditions) && $conditions['returnType'] != 'all'){
 
           switch($conditions['returnType']){
 
               case 'count':
 
                   $data $result->num_rows;
 
                   break;
 
               case 'single':
 
                   $data $result->fetch_assoc();   <<<<this line
                    break
;
 
               default:
 
                   $data '';
 
           }
 
       }else{
 
           if($result->num_rows 0){
 
               while($row $result->fetch_assoc()){
 
                   $data[] = $row;
 
               }
 
           }
 
       }

But the fetch_assoc line is failing with this errorCall to undefined method CI_DB_mysqli_result::fetch_assoc()

Anyone know why

Read the doc. https://www.codeigniter.com/user_guide/d...ult-arrays
Reply

#3
I see it that part of the manual. My result is this:

mysqli_result Object
(
[current_field] => 0
[field_count] => 10
[lengths] =>
[num_rows] => 6
[type] => 0
)

But the $result_array is [0]. The question is why would fetch_assoc() error out rather than return some type of return code?
Reply

#4
A careful reading of the error message shows me **Call to undefined method CI_DB_mysqli_result::fetch_assoc()**

There is no fetch_assoc method in a result object.
Searching the CI3 user guide for "fetch_assoc" doesn't show any results.

My guess is that the code you found is inappropriate!

Passwords would normally be saved as the result of "password_hash", if that is what you are trying to do.
Reply

#5
aha, but there is a mysqli_fetch_assoc in php. Could the answer be to append the mysqli_ onto it? I tried that but it didn't work. Because that would presume that I used
 
mysqli_query instead of the actual line below.

       $result = $this->db->query($sql);


Here is the def of what mysqi_fetch_assoc does:

(PHP 5, PHP 7)

mysqli_result::fetch_assoc -- mysqli_fetch_assoc — Fetch a result row as an associative array

perhaps I can build a command that does the same thing as thing as this non-existing function call?
Reply

#6
Well, this line seems to work

$data=$result->row_array();

so I am ok for the moment!
Reply

#7
Guys .. I know its out of subject but can someone help me here please:

https://forum.codeigniter.com/thread-70678.html
Reply

#8
That's pure MySQLi code which means that he never made a MySQLi connection.
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.