whayooe Posted June 16, 2012 Share Posted June 16, 2012 i have the syntax to display the article but there is a problem in his line 5 .. anyone can help me. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\json-parsingxml2\artikel-xml.php on line 5 {"agenda" : []} <?php include("koneksi.php"); $q = mysql_query('SELECT * FROM agenda'); $v = '{"agenda" : ['; while($r=mysql_fetch_array($q)) { $ob = array('"','<br>','</br>'); $v .= '{"id" : "'.$r['id_agenda'].'", "tema" : "'.str_replace($ob,' ',strip_tags($r["tema"])).'", "isi_agenda" : "'.str_replace($ob,' ',strip_tags($r["isi_agenda"])).'", "tempat" : "'.str_replace($ob,' ',strip_tags($r["tempat"])).'", "pengirim" : "'.str_replace($ob,' ',strip_tags($r["pengirim"])).'", "tgl_mulai" : "'.str_replace($ob,' ',strip_tags($r["tgl_mulai"])).'", "tgl_selesai" : "'.str_replace($ob,' ',strip_tags($r["tgl_selesai"])).'", "jam" : "'.str_replace($ob,' ',strip_tags($r["jam"])).'"}'; } $v .= ']}'; echo $v; ?> Link to comment https://forums.phpfreaks.com/topic/264274-warning-mysql_fetch_array-expects-parameter-1-to-be-resource/ Share on other sites More sharing options...
trq Posted June 16, 2012 Share Posted June 16, 2012 You failed to check that $q is a resource before using it within mysql_fetch_array. Link to comment https://forums.phpfreaks.com/topic/264274-warning-mysql_fetch_array-expects-parameter-1-to-be-resource/#findComment-1354311 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.