php - Prepared statements doesn't return results -
i trying querys prepared statements new me , have troubles. first query , doesn't echo result table. i've done far. may realy newbie question new me.
if(isset($_get['joke_id'])){ $joke_id = $_get['joke_id']; $qry = $con->prepare("select * joke joke_cat = ?"); $qry->bind_param('i', $joke_id); $qry->execute(); $result = $qry->get_result(); $result->fetch_array(); $result = mysqli_query($con, $qry) or die("query failed: " . mysqli_errno($con));*/ $line = mysqli_fetch_array($result, mysql_both); if (!$line) echo ''; $previd = -1; $currid = $line[0]; if (isset($_get['id'])) { $previous_ids = array(); { $previous_ids[] = $line[0]; $currid = $line[0]; if ($currid == $_get['id']) break; $previd = end($previous_ids); $line = mysqli_fetch_array($result, mysql_both); } while ($line); } if ($line) { echo "<div id=\"box\">"; echo nl2br($line['text']) . "<br /><br />"; echo "<div id=\"share\"><span class='st_facebook' displaytext='facebook'></span> <span class='st_twitter' displaytext='tweet'></span> <span class='st_googleplus' displaytext='google +'></span></div>"; echo '<br /><br /><br />'; echo "</div>"; } else echo '<p>empty category</p><br/>';
this use right before try pdo , it's work no problems.
qry = "select * joke joke_cat = '$joke_id'"; $result = mysqli_query($con, $qry) or die("query failed: " . mysqli_errno($con));
$_get['joke_id']
, $_get['joke_cat']
set ?
or try
$qry = $con->prepare("select * joke joke_cat =:joke_cat"); $qry->bindparam(':joke_cat', $_get['joke_cat'], pdo::param_str); $qry->execute(); $result = $qry->fetchall();
Comments
Post a Comment