thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Part: 19 Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in... data.php on line 7 #55

Closed Chriswilldo closed 10 years ago

Chriswilldo commented 10 years ago

There is also this guy who commented a week ago having the very same issue; not me.

hsia yvonne 1 week ago

I have got the problem as this; Waring: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\sampp\htdocs\series\dynamic\AtomCMS\functions\data.php on line $data = mysqli_fetch_assoc($r); the icon has shown in the setup.php, but not in data.php

Any ideas? For some reason it's saying that my $data = mysqli_fetch_assoc($r); should have a mysqli result boolean given. I'm not entirely sure on what that means... Without this fix, I can't use my debug button :|. I've continued to part 21 thinking the solution would resolve itself but still nothing.. I'd really like a solution to this if available because I really am stuck at this point.

Here's my data.php so far.

<?php

function data_setting_value($dbc, $id) {

$q = "SELECT * FROM settings WHERE id = '$id'";
$r = mysqli_query($dbc, $q); 

$data = mysqli_fetch_assoc($r);

return $data['value']; }

function data_page($dbc, $id) {

$q = "SELECT * FROM pages WHERE id = $id"; $r = mysqli_query($dbc, $q);

    $data = mysqli_fetch_assoc($r); 

    $data['body_nohtml'] = strip_tags($data['body']);

        if($data['body'] == $data['body_nohtml']) { $data['body_formatted'] = '<p>'.$data ['body'].'</p>'; }

            else { $data['body_formatted'] = $data['body']; }

                    return $data; }

?>

Chriswilldo commented 10 years ago

Line 7: $data = mysqli_fetch_assoc($r); return $data['value']; }

badreldenbeko commented 9 years ago

i have the same problem but i can't solve it

badreldenbeko commented 9 years ago

there was a wrong spelling in my SELECT statement when i solve this everything works OK check yours is all your spelling in database and function the same i hope i can help because my English not good

poojakhatri commented 6 years ago
$data = mysqli_fetch_assoc($conn, $r);
 return $data['value']; }
creptor commented 6 years ago

@poojakhatri the function mysqli_fetch_assoc() only needs one parameter to be given, which needs to be the result of mysqli_query(), mysqli_store_result() or mysqli_use_result(). If you give multiple values to mysqli_fetch_assoc() it will output an error.

To fix your error just replace $data = mysqli_fetch_assoc($conn, $r); by $data = mysqli_fetch_assoc($r);

For more information check the PHP manual, link here.