html - error to do with endwhile in php code while makeing forum -
my new error this: have error in sql syntax; check manual corresponds mysql server version right syntax use near ') , type='o'' @ line 1 can fix , other errors in code:
<?php session_start(); require"db_connect.php"; //get page id if(isset($_get['id']) && is_numeric($_get['id'] )) { $id = $_get['id'] ; } else { die("error!"); } //check see if id valid id $idcheck = $db->query("select * forum_tabl forum_id = '$id'"); if($idcheck->num_rows !==1){ die("error"); } $row = $idcheck->fetch_object(); $sql = "select post_id, post_title forum_post forum_id=) , type='o'"; if($query = $db->prepare($sql)){ $query->bind_param('s', $id); $query->bind_result($post_id, $post_title); $query->execute(); $query->store_result(); }else{ echo $db->error; } ?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title><?php= $row->forum_name?>!</title> <html> <head> <body> <div id="page"> <center><h1>welcome our forms.</h1></center> <h2>our minecraft forum displayed below</h2> <table width="100%"> <?php if($query->num_rows!=0):?> <?php while($query-fetch()):?> <tr> <td><?- $post_title?></td </tr> <?php endwhile;?> <?php else:?> <tr> <td><p>no posts yet!</p></td> </tr> <?php endif;?> </html> </head> </body>
you should replace semicolon colon :
<?php while($query->fetch()): ?> <tr> <td><?- $post_title?></td </tr> <?php endwhile;?>
same if
, endif
condition.
Comments
Post a Comment