php - mysqli_num_rows() -
this question has answer here:
- reference - error mean in php? 29 answers
a part of php code doesn't work... when write code :
public $postcount = 10; public function updates($user_ids, $lastid) { if ($lastid == 0) { $loadmore = ''; } else { $loadmore = " , m.msg_id<$lastid "; } $db_conx = mysqli_connect("localhost", "root", "", "yusers"); $sql = "select m.msg_id, m.uid_fk, m.message, m.created, u.fname, u.lname, m.uploads, m.profile_uid messages m, users u m.uid_fk=u.uid , m.uid_fk in ($user_ids) $loadmore union select m.msg_id, m.uid_fk, m.message, m.created, u.fname, u.lname, m.uploads, m.profile_uid messages m, users u m.uid_fk=u.uid , m.profile_uid in ($user_ids) $loadmore order msg_id desc limit 10" . $this->postcount; $query = mysqli_query($db_conx, $sql);
i :
'warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given on line 26'
line 26 :
while($row = mysqli_fetch_array($query, mysqli_assoc)){ //something }
when test query :
if (!$query) { printf("error: %s\n", mysqli_error($db_conx)); exit(); }
it gives me :
"you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'msg_id desc limit10' @ line 2"
help me please
you need put space
query ends, , change order
order by
$sql = "select m.msg_id, m.uid_fk, m.message, m.created, u.fname, u.lname, m.uploads, m.profile_uid messages m, users u m.uid_fk=u.uid , m.uid_fk in ($user_ids) $loadmore union select m.msg_id, m.uid_fk, m.message, m.created, u.fname, u.lname, m.uploads, m.profile_uid messages m, users u m.uid_fk=u.uid , m.profile_uid in ($user_ids) $loadmore order msg_id desc limit " .$this->postcount;
Comments
Post a Comment