php - Debug MYSQLI Conversion -
i'm still bit new @ mysqli please go easy. i'm trying convert mysqli , i'm coming with.
db_conx.php
<?php $db_conx = mysqli_connect("localhost", "use", "pass", "db"); // evaluate connection if (mysqli_connect_errno()) { echo mysqli_connect_error(); exit(); } ?> <?php // connect mysql database include "includes/db_conx.php"; $sql = "select * content order id desc"; $result = mysqli_query($db_conx,$sql); $productcount = mysqli_num_rows($result); $bloglist = ""; if ($productcount > 0) { $adverts = array( 'test', 'test 2'); $counter = 0; while($row = mysqli_fetch_assoc($sqltwo)){ $id = $row["id"]; $article_title = $row["article_title"]; $category = $row["category"]; $author = $row["author"]; $date_added = $row["date_added"]; $article = $row["article"]; $short = substr(strip_tags($article), 0, 750); $shorttitle = substr(strip_tags($article_title), 0, 45); if($readmore == ''){ //code new post $bloglist .= '<div class="blogsnippettitle"><a href="http://www..php?id='.$id.'"><h2>'.$article_title.'</h2></a></div><div class="blogsnippet"><div class="blogimage"><img src="http://www./'.$id.'.jpg" height="142px" width="200px" alt="'.$category.' '.$shorttitle.'" /></div><div class="blogsnippetprev"><div class="citation">by <span style="color:#006699;">'.$author.'</span> on <span style="color:#99aacc;">'.$date_added.'</span> in <span style="color:#006699;">'.$category.'</span></div> <div class="snippet">'.$short.'...<br /></div> <div class="readmorebutton"><br /><a href="http://www..php?id='.$id.'"><img src="http://www.read_more.png" alt="read more graphic" /></a></div> </div> </div>'; } else{ //code old post $bloglist .= '<div class="blogsnippettitle"><a href="'.$readmore.'"><h2>'.$article_title.'</h2></a></div><div class="blogsnippet"><div class="blogimage"><img src="http://www./'.$id.'.jpg" height="142px" width="200px" alt="'.$category.' '.$shorttitle.'" /></div><div class="blogsnippetprev"><div class="citation">by <span style="color:#006699;">'.$author.'</span> on <span style="color:#99aacc;">'.$date_added.'</span> in <span style="color:#006699;">'.$category.'</span></div> <div class="snippet">'.$short.'...<br /></div> <div class="readmorebutton"><br /><a href="'.$readmore.'"><img src="http://www.read_more.png" alt="read more graphic" /></a></div> </div> </div>'; } if($counter < 2){ $bloglist .= $adverts[$counter]; $counter++; } } } ?>
the error i'm getting
[07-aug-2013 22:18:26 america/denver] php warning: mysqli_fetch_assoc() expects parameter 1 mysqli_result, null given in /home/learnsit/public_html/site-design-blog.php on line 23
you passing sqltwo
in mysqli_fetch_assoc()
but takes argument of mysqli_result
$result
try this,
while($row = mysqli_fetch_assoc($result)){
in place of
while($row = mysqli_fetch_assoc($sqltwo)){
read mysqli_fetch_assoc()
Comments
Post a Comment