ardhix Posted March 27, 2013 Share Posted March 27, 2013 (edited) 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.. Edited March 27, 2013 by ardhix Quote 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?). Quote 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? Quote 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. Quote 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 Quote 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 (edited) 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. Edited March 27, 2013 by haku Quote 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 Quote 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) Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.