php - mysqli_fetch_array() on a non-object -
getting error on code can 1 tell me doing wrong , how solve or 1 suggest me more simple code after select query because don't want mess code , not helping
here code
if(isset($_get['id'])){ $page_id = $_get['id']; $page_id = mysqli_real_escape_string($con, $page_id); $select_query = ("select id, title, image, cost, vid, content mobs id=?"); $stmt = $con->stmt_init(); if(!$stmt->prepare($select_query)) { print "failed prepare statement\n"; } else { $stmt->bind_param("s", $page_id); { $stmt->execute(); $result = $stmt->get_result(); if($result === false) { die(mysql_error()); } while($row->mysqli_fetch_array($result)) { $post_id = $row['id']; $post_title = $row['title']; $post_image = $row['image']; $post_cost = $row['cost']; $post_vid = $row['vid']; $post_cont= $row['content']; }
i getting these errors
notice: undefined variable: row in fatal error: call member function mysqli_fetch_array() on non-object
you're (incorrectly) combining procedural , oop-style calls. see mysqli_result::fetch_array
.
the correct object-oriented style call:
while($row = $result->fetch_array())
Comments
Post a Comment