ardhix Posted March 27, 2013 Share Posted March 27, 2013 i have found warning message = Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given inC:\xampp\htdocs\articles\artikel.php on line 7 <?php include 'koneksi.php'; $articleid = $_GET['articleid']; $sql_query = 'SELECT ta.*, tca.category_article FROM article_news AS ta INNER JOIN tcategory_article AS tca ON ta.category_article_id = tca.category_article_id WHERE article_id = '.$articleid; $query = mysql_query($sql_query); $row = mysql_fetch_array($query); //--> this is line #7 $msg = $_GET['msg']; if(!empty($msg)){ if($msg = 100){ echo '<h5 style="text-align:center; color:#f00; font-weight: normal">.</h5>'; } } ?> <!--articles--> <a name="TemplateInfo"></a> <input type="hidden" name="prodid" value="<?php echo $row['article_id'];?>" size="1"/> <h1><?php echo $row['judul'];?></h1> <p><a href=""><img src="images/upload/<?php echo $row['photo'];?>" width="100" height="120" class="float-left"></a> <p><?php echo $row['artikel'];?></a>. </p> <!--end of articles--> <p><?php echo $row['category_article'];?></p> <p class="post-footer"> <a href="index.html" class="readmore">Read more</a> <a href="index.html" class="comments">Comments (7)</a> <span class="date"><?php echo $row['tanggal'];?></span> </p> please help me i'm sorry newbie here.. Link to comment https://forums.phpfreaks.com/topic/276204-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/ Share on other sites More sharing options...
haku Posted March 27, 2013 Share Posted March 27, 2013 Please wrap your code in code tags. You can do this using the <> button in the editor. As well, always point out which line is referred to in the error (in this case, which line is #53?). Link to comment https://forums.phpfreaks.com/topic/276204-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1421308 Share on other sites More sharing options...
ardhix Posted March 27, 2013 Author Share Posted March 27, 2013 i've change Please wrap your code in code tags. You can do this using the <> button in the editor. As well, always point out which line is referred to in the error (in this case, which line is #53?). i've change with editor, is that correct? Link to comment https://forums.phpfreaks.com/topic/276204-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1421310 Share on other sites More sharing options...
haku Posted March 27, 2013 Share Posted March 27, 2013 Your query is failing for some reason. Change this line: $query = mysql_query($sql_query); To this: $query = mysql_query($sql_query) or die(mysql_error()); Run the script again, and let us know the output. Link to comment https://forums.phpfreaks.com/topic/276204-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1421311 Share on other sites More sharing options...
ardhix Posted March 27, 2013 Author Share Posted March 27, 2013 Your query is failing for some reason. Change this line: $query = mysql_query($sql_query); To this: $query = mysql_query($sql_query) or die(mysql_error()); Run the script again, and let us know the output. now it shows message : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Link to comment https://forums.phpfreaks.com/topic/276204-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1421315 Share on other sites More sharing options...
haku Posted March 27, 2013 Share Posted March 27, 2013 What does this show: die($sql_query = 'SELECT ta.*, tca.category_article FROM article_news AS ta INNER JOIN tcategory_article AS tca ON ta.category_article_id = tca.category_article_id WHERE article_id = '.$articleid); I'm thinking $articleid is empty. Link to comment https://forums.phpfreaks.com/topic/276204-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1421324 Share on other sites More sharing options...
ardhix Posted March 27, 2013 Author Share Posted March 27, 2013 What does this show: die($sql_query = 'SELECT ta.*, tca.category_article FROM article_news AS ta INNER JOIN tcategory_article AS tca ON ta.category_article_id = tca.category_article_id WHERE article_id = '.$articleid); I'm thinking $articleid is empty. Solved now.. by removing $articleid, the data shows up, thank you very much Link to comment https://forums.phpfreaks.com/topic/276204-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1421343 Share on other sites More sharing options...
ardhix Posted March 27, 2013 Author Share Posted March 27, 2013 there's no value in $articleid, because no data passed to it (it used for detail of article) Link to comment https://forums.phpfreaks.com/topic/276204-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1421373 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.