php - Error: mysqli_fetch_object() expects parameter 1 to be mysqli_result -
i don't know problem line or how fix it, before okay , i'm getting error:
mysqli_fetch_object() expects parameter 1 mysqli_result
here php code:
<?php } if($_get['action']=="user_info") { $userid = $_get['user_id']; $query = "select * user user_id ='{$userid}'"; $result = mysqli_query($link, $query); $user = mysqli_fetch_object($result); $queryt = "select * user_title id='".$user->title."'"; $resultt = mysqli_query($link, $queryt); $rowt = mysqli_fetch_object($resultt); $title = $rowt->name; $sorgu = "select * pub_author user_id='$userid'"; $publications = mysqli_query($link, $sorgu); while($a = mysqli_fetch_object($publications)) { $ids .= $a->pub_id . ','; } $ids = rtrim($ids,","); $sorgu2 = "select count(id) total , year publication id in ($ids) group year(`year`) order `year` "; $publications2 = mysqli_query($link, $sorgu2); while($a2 = mysqli_fetch_object($publications2)) { $mount = explode('-', $a2->year); $accyaz[$mount[0]] = $a2->total; } }
?>
as far exact error concerned 1 of query failing, following steps might help. ofcourse question looks duplicate here of things addresses question
your first query should this, no curly braces, ofcourse untill have explicitly ids wrapped in curly braces in table.
select * user user_id ='$userid'
secondly executing multiple queries might wanna consider error checking if query executes or not(because of syntax error columns mismatch table name mismatch many more possibilities): error checking while($a...)
part
if ($result=mysqli_query($link, $sorgu);) { while($a=mysqli_fetch_object($result)) { $ids .= $a->pub_id . ','; } $sorgu2 = "select count(id) total , year publication id in ($ids) group year(`year`) order `year` "; //... further code } else { echo "something went wrong while executing query :: $sorgu"; }
third see getting pub_id
make comma seperated list of can give parameter in last query long shot, why not use sub query in
clause this:
select count(id) total, year publication id in ( select pub_id pub_author user_id='$userid' ) group `year` order `year`;
Comments
Post a Comment