Jump to content

Ben555

New Members
  • Posts

    7
  • Joined

  • Last visited

Ben555's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Or line 21 echo "<tr><td class='category_title'><a href='/Games Forum/topics.php?cid=".$row['cat_id']."scid=".$row['subcat_id']."'>".$row['subcategory_title']."<br />"; since again Im unsure of the syntax
  2. this is line 18 and im pretty sure the error is actually here somewhere. $select = mysqli_query($con, "SELECT cat_id, subcat_id, subcategory_title, subcategory_desc FROM categories, subcategories WHERE ($parent_id = categories.cat_id) AND ($parent_id = subcategories.parent_id"); not sure I have the syntax right
  3. Ok thank you! This is what I get back Error running query : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 Shooters Unfortunately it now refers to line 1, and I really cant find a syntax error. Nor is there a " on line 1. Im sure ive made a silly mistake somewhere.
  4. Hi and thanks. I am a new user so I apologise if I have breached forum etiquette. The apache logs show only this Sat Mar 28 18:43:39.275738 2020] [php7:warn] [pid 23828:tid 1924] [client ::1:53013] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in E:\\Utilities\\xampp\\htdocs\\Games Forum\\content_function.php on line 20 Line 20 is the while statement in the code below function dispsubcategories($parent_id) { include ('dbconn.php'); $select = mysqli_query($con, "SELECT cat_id, subcat_id, subcategory_title, subcategory_desc FROM categories, subcategories WHERE ($parent_id = categories.cat_id) AND ($parent_id = subcategories.parent_id"); echo "<tr><th width='90%'>Categories</th><th width='10%'>Topics</th></tr>"; while ($row = mysqli_fetch_assoc($select)) { echo "<tr><td class='category_title'><a href='/Games Forum/topics.php?cid=".$row['cat_id']."scid=".$row['subcat_id']."'>".$row['subcategory_title']."<br />"; echo $row['subcategory_desc']."</a><td>"; echo "<td class='num-topics'>".getnumtopics($parent_id, $row['subcat_id'])."</td></tr>"; } Im really very new at this and don't really know what Im doing, hence why I posted. Its an attempt to write a discussion forum for an assignment. The content_function.php is meant to display the name of the topics, sub topics and how many posts there are. I seem to have managed to print out the main topic headings but failed to display the rest.
  5. Hi Guys. Doing an assignment for uni, and stuck on an error. Ill attach some files to show the problem and any help very much appreciated. Error and the screen it comes on Code <?php function dispcategories() { include ('dbconn.php'); $select = mysqli_query($con, "SELECT * FROM categories"); while ($row = mysqli_fetch_assoc($select)) { echo "<table class='category table'>"; echo "<tr><td class='main-category' colspan='2'>".$row['category_title']."</td></tr>"; dispsubcategories($row['cat_id']); echo "</table>"; } } function dispsubcategories($parent_id) { include ('dbconn.php'); $select = mysqli_query($con, "SELECT cat_id, subcat_id, subcategory_title, subcategory_desc FROM categories, subcategories WHERE ($parent_id = categories.cat_id) AND ($parent_id = subcategories.parent_id"); echo "<tr><th width='90%'>Categories</th><th width='10%'>Topics</th></tr>"; while ($row = mysqli_fetch_assoc($select)) { echo "<tr><td class='category_title'><a href='/Games Forum/topics.php?cid=".$row['cat_id']."scid=".$row['subcat_id']."'>".$row['subcategory_title']."<br />"; echo $row['subcategory_desc']."</a><td>"; echo "<td class='num-topics'>".getnumtopics($parent_id, $row['subcat_id'])."</td></tr>"; } } function getnumtopics($cat_id, $subcat_id) { include ('dbconn.php'); $select = mysqli_query($con, "SELECT category_id, subcategory_id FROM topics WHERE ".$cat_id." = category_id AND ".$subcat_id." = subcategory_id"); return mysqli_num_rows($select); } ?> and the structure of the database
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.