{"action":"created","issue":{"url":"https://api.github.com/repos/thedigicraft/Atom.CMS/issues/125","labels_url":"https://api.github.com/repos/thedigicraft/Atom.CMS/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/thedigicraft/Atom.CMS/issues/125/comments","events_url":"https://api.github.com/repos/thedigicraft/Atom.CMS/issues/125/events","html_url":"https://github.com/thedigicraft/Atom.CMS/issues/125","id":81166239,"number":125,"title":"Part 44 - $opened Problems","user":{"login":"asani","id":12589434,"avatar_url":"https://avatars.githubusercontent.com/u/12589434?v=3","gravatar_id":"","url":"https://api.github.com/users/asani","html_url":"https://github.com/asani","followers_url":"https://api.github.com/users/asani/followers","following_url":"https://api.github.com/users/asani/following{/other_user}","gists_url":"https://api.github.com/users/asani/gists{/gist_id}","starred_url":"https://api.github.com/users/asani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asani/subscriptions","organizations_url":"https://api.github.com/users/asani/orgs","repos_url":"https://api.github.com/users/asani/repos","events_url":"https://api.github.com/users/asani/events{/privacy}","received_events_url":"https://api.github.com/users/asani/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-26T22:31:28Z","updated_at":"2015-05-28T22:08:53Z","closed_at":null,"body":"Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/a9667120/public_html/admin/index.php on line 143\r\n\r\n\r\nLine 143 is\r\n\r\n           \t\t<input type=\"hidden\" name=\"id\" value=\"<?php echo $opened['id']; ?>\"> \r\n\r\nWhat iswrong here?\r\n \r\nThe first time around i could edit but not add pages so i followed McDucky74's tip and did this:\r\n\r\n\r\nif(isset($_POST['id']) AND $_POST['id'] != '') {\r\n\r\n\r\nThen 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.\r\n\r\nIv runned dow the code and all seems to be A OK but when i run the query something is wrong!!\r\n\r\nAnyone?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/thedigicraft/Atom.CMS/issues/comments/106614150","html_url":"https://github.com/thedigicraft/Atom.CMS/issues/125#issuecomment-106614150","issue_url":"https://api.github.com/repos/thedigicraft/Atom.CMS/issues/125","id":106614150,"user":{"login":"creptor","id":3092157,"avatar_url":"https://avatars.githubusercontent.com/u/3092157?v=3","gravatar_id":"","url":"https://api.github.com/users/creptor","html_url":"https://github.com/creptor","followers_url":"https://api.github.com/users/creptor/followers","following_url":"https://api.github.com/users/creptor/following{/other_user}","gists_url":"https://api.github.com/users/creptor/gists{/gist_id}","starred_url":"https://api.github.com/users/creptor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/creptor/subscriptions","organizations_url":"https://api.github.com/users/creptor/orgs","repos_url":"https://api.github.com/users/creptor/repos","events_url":"https://api.github.com/users/creptor/events{/privacy}","received_events_url":"https://api.github.com/users/creptor/received_events","type":"User","site_admin":false},"created_at":"2015-05-28T22:08:53Z","updated_at":"2015-05-28T22:08:53Z","body":"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:\r\n```\r\nfunction data($dbc, $id, $tb, $col = NULL) {\r\n\tif($dbc==NULL){die('no database to retrive from');}\r\n\tif($tb==NULL){die('no table to retrive from');}\r\n\tif(!is_numeric($id)){die('NULL id');}\r\n\tif($col==NULL){$col='id';}else{mysqli_real_escape_string($dbc,$col);}\r\n\tif(!$stmt = $dbc->query(\"SELECT * FROM $tb WHERE $col = '$id'\")){\r\n\t\tdie(\"Update failed: (\".$dbc->errno.\") \".$dbc->error);\r\n\t}\r\n\t$data = $stmt->fetch_assoc();\t\r\n\treturn $data;\r\n}\r\n```\r\n\r\nAnd in every place that I need the opened id thing.. I place in the query case this:\r\n```\r\nif(isset($_GET['id'])){$opened=data($dbc->(database variable),$_GET['id'],'(table-name)', '(colum-name)');}\r\n```\r\n\r\nExample:\r\n\r\n```\r\ncase 'store':\r\n\tif(isset($_GET['id'])){$opened = data($dbc, $_GET['id'], 'store', 'store_item_id');}\r\nbreak;\r\n```\r\n\r\n-- If no colum if defined, then it will try to use the 'id' colum, so you can skip it to save code.\r\n```\r\ncase 'blog_posts':\r\n\tif(isset($_GET['id'])){$opened = data($dbc, $_GET['id'], 'blog_posts');}\r\nbreak;\r\n```\r\n-- Also works if you define multiple gets per page.\r\n```\r\ncase 'forum':\r\n\tif(isset($_GET['categories'])){\r\n\t\tif(isset($_GET['id'])){$opened = data($dbc, $_GET['id'], 'forum_categories');}\r\n\t}\r\n\tif(isset($_GET['topics'])){\r\n\t\tif(isset($_GET['id'])){$opened = data($dbc, $_GET['id'], 'forum_topics');}\r\n\t}\r\nbreak;\r\n```"}}