Closed Chriswilldo closed 9 years ago
Okay I am looking at this and there are a couple issues to look at...
Your Code:
function data_user($dbc, $id) {
$q = "SELECT * FROM users WHERE email = '$id'";
$r = mysqli_query($dbc, $q);
$data['fullname'] = $data['first'].' '.$data['last']; return $data;
$data['fullname_reversed'] = $data['last'].', '.$data['first'];
}
Should be:
function data_user($dbc, $id) {
$q = "SELECT * FROM users WHERE email = '$id'";
$r = mysqli_query($dbc, $q);
$data = mysqli_fetch_assoc($r); // put this back in...
$data['fullname'] = $data['first'].' '.$data['last'];
$data['fullname_reversed'] = $data['last'].', '.$data['first'];
return $data; // move this here...
}
Also, I tried $return $data and return $id a few extra times on data.php to try to fix it. It worked, except for the fact that I can't use <?php echo $user['fullname']; ?> in navigation.php or else it'll count it as an illegal string. Here's the edited data.php and navigation.php
data.php
<?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_user($dbc, $id) {
return $id;
$q = "SELECT * FROM users WHERE email = '$id'"; return $data;
$r = mysqli_query($dbc, $q); return $data;
$data['fullname'] = $data['first'].' '.$data['last']; return $data;
$data['fullname_reverse'] = $data['last'].', '.$data['first'];
}
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;
}
?>
navigation.php
<nav class="navbar navbar-default" role="navigation">
<ul class="nav navbar-nav">
<?php //nav_main($dbc, $pageid); ?>
<li><a href="#">Dashboard</a></li>
<li><a href="#">Pages</a></li>
<li><a href="#">Users</a></li>
<li><a href="#">Settings</a></li>
</ul>
<div class="pull-right">
<ul class=" nav navbar-nav">
<li>
<?php if($debug == 1) { ?>
<button type="button" id="btn-debug" class="btn btn-warning navbar-btn"><i class="fa fa-bug"; ><br> D-BUG</i></button>
<?php } ?>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php ?><b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="logout.php">Logout</a></li>
</ul>
</li>
</ul>
</div>
</nav>
the return must be the last thing you do in the function. You can only return one variable/array. So return $data;
must be the only return
used and you want it as the last statement in the function.
You need to take it off of the line that has:
$data['fullname'] = $data['first'].' '.$data['last']; return $data;
should be:
$data['fullname'] = $data['first'].' '.$data['last'];
otherwise it will return $data
before $data['fullname_reverse']
has been created and you do not want that.
ok so when everything is in its right spot, I still get the same errors. Both the indefined index for $data ['fullname'] and the parameter 1 is supposed to be mysqli_result error for $data = mysqli_fetch_assoc($r);
Also, return $ id; will work after $r = mysqli_query($dbc, $q); even if return $data is put in last, but it'll say or make <?php echo $user['fullname'] ?> an illegal string offset
you need to take the return $id out completely. i may be wrong... it may actually be returning the first return instead of the last. try taking that out.
When I do I get the same error:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\website\dynamic......\admin\functions\data.php on line 18:
($data = mysqli_fetch_assoc($r); )
Notice: Undefined index: last in C:\xampp\htdocs\website\dynamic......\admin\functions\data.php on line 21
( $data['fullname_reverse'] = $data['last'].', '.$data['first']; )
Got it to work! I just had to start the admin folder all over!
Glad that worked! On Oct 13, 2014 6:49 PM, "Chriswilldo" notifications@github.com wrote:
Got it to work! I just had to start the admin folder all over!
— Reply to this email directly or view it on GitHub https://github.com/thedigicraft/Atom.CMS/issues/73#issuecomment-58966342 .
Hello, currently my issue is with the $data = mysqli_fetch_assoc($r); For some reason mysqli_fetch_assoc($r); always seems to mess up on every time as the same parameter 1 Boolean error that has happened to me in the past. Also too, my return $data will only work before $data['fullname'], otherwise it'll cause even more errors. Any suggestions?
data.php:
setup.php:
navigation.php:
index.php: