php - echoing field from database isn't working as expected? -


it's simple thing reason im not seeing cant echo field mysql database field?

below code works except need echo out newly updated vote count, appreciated.

<?php require 'core/init.php'; $_session['score'] = $_post['score']; $_session['pid'] = $_post['pid'];  $score  = $_session['score']; $pid    = $_session['pid']; $ipaddy = $_server['remote_addr'];  $udvote = $db->query("insert ratings (score, pid, ip) values ('{$score}','{$pid}','{$ipaddy}')") && $db->query("update votes set votecount = votecount +1 pid='$pid'");  if ($udvote){     $votec = $db->query("select votecount votes pid='$pid' limit 1");         echo $votec; } else {     echo "error updating database"; } ?>   

in case else has issues , looks on here solution issue i'll post updated , working code below.

<?php require 'core/init.php';  $_session['score'] = $_post['score']; $_session['pid'] = $_post['pid'];  $score  = $_session['score']; $pid    = $_session['pid']; $ipaddy = $_server['remote_addr']; $records =array();  if($results = $db->query("select * votes")){     if($results->num_rows){         while($row = $results->fetch_object()){             $records[] = $row;         }         $results->free();     } }  $udvote = $db->query("insert ratings (score, pid, ip) values ('{$score}','{$pid}','{$ipaddy}')") && $db->query("update votes set votecount = votecount +1 pid='$pid'");  if ($udvote){     if(!count($records)){         echo 'no records';     }else{         foreach ($records $r){             echo escape($r->votecount);         }         die();     }     }else{         echo "error updating database"; }   ?> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -