Open asani opened 9 years ago
Well now i just continued the video as i figure that someone will find a solution for me seeing as my capacity is little limited code-wise, i contuniued with the active thingy and all went smooth...i figured that the error i had erlier would persist but i tried...but to my surprise i got a different message this time...
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/a9667120/public_html/admin/functions/data.php on line 39
Now suddely it says i have issues on data.php...i didnt even touch data since the last error...so its logical that the two have a connection...i just cant grasp my head around it!!
Line 39 in data is :
$data = mysqli_fetch_assoc($r);
WTF?
By the way to make the error search a little easier for the webMASTERS out there....even though i can add pages i get an error...but i now see that i also get
?page=(mergimsblog i
nsted of
?page=mergimsblog
on the page id thing!!
Anyone??
To fix this anoyng error, and to not chage the code every time I do it, I have modified the opened fuction, so that it works for every case I need... here is my code:
function data($dbc, $id, $tb, $col = NULL) {
if($dbc==NULL){die('no database to retrive from');}
if($tb==NULL){die('no table to retrive from');}
if(!is_numeric($id)){die('NULL id');}
if($col==NULL){$col='id';}else{mysqli_real_escape_string($dbc,$col);}
if(!$stmt = $dbc->query("SELECT * FROM $tb WHERE $col = '$id'")){
die("Update failed: (".$dbc->errno.") ".$dbc->error);
}
$data = $stmt->fetch_assoc();
return $data;
}
And in every place that I need the opened id thing.. I place in the query case this:
if(isset($_GET['id'])){$opened=data($dbc->(database variable),$_GET['id'],'(table-name)', '(colum-name)');}
Example:
case 'store':
if(isset($_GET['id'])){$opened = data($dbc, $_GET['id'], 'store', 'store_item_id');}
break;
-- If no colum if defined, then it will try to use the 'id' colum, so you can skip it to save code.
case 'blog_posts':
if(isset($_GET['id'])){$opened = data($dbc, $_GET['id'], 'blog_posts');}
break;
-- Also works if you define multiple gets per page.
case 'forum':
if(isset($_GET['categories'])){
if(isset($_GET['id'])){$opened = data($dbc, $_GET['id'], 'forum_categories');}
}
if(isset($_GET['topics'])){
if(isset($_GET['id'])){$opened = data($dbc, $_GET['id'], 'forum_topics');}
}
break;
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/a9667120/public_html/admin/index.php on line 143
Line 143 is
What iswrong here?
The first time around i could edit but not add pages so i followed McDucky74's tip and did this:
if(isset($_POST['id']) AND $_POST['id'] != '') {
Then i could add pages and edit, but got the line 143 error...by the way i did get this error earlier when i couldnt add pages to.
Iv runned dow the code and all seems to be A OK but when i run the query something is wrong!!
Anyone?