wond3r Posted March 11, 2013 Share Posted March 11, 2013 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\Muratcea_S_3014_hw5\index.php on line 101 Call Stack # Time Memory Function Location 1 0.0003 149672 {main}( ) ..\index.php:0 2 0.0031 157128 mysql_fetch_array ( ) ..\index.php:101 ( ! ) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\Muratcea_S_3014_hw5\index.php on line 149 Call Stack # Time Memory Function Location 1 0.0006 150632 {main}( ) ..\index.php:0 2 0.0048 158232 mysql_num_rows ( ) ..\index.php:149 Im not sure what to include here so I will show those specific areas... <?php $con=0; while($row = mysql_fetch_array($movResults)){ if($con == 0) { echo "<div class=\"container\"> <div class=\"row\"> <div class=\"fourcol\"> <div class=\"movImg\"> <img src=\"images/".$row['products_thumb']."\" alt=\"".$row['products_name']."\"> </div> <div class=\"movTxt\"> <h3>".$row['products_name']."</h3> <p>".$row['products_price']."</p> <a href=\"productdetail.php?id=".$row['products_id']."\">View Product.....</a> </div> </div>"; $con++; }else if($con == 1){ echo "<div class=\"fourcol\"> <div class=\"movImg\"> <img src=\"images/".$row['products_thumb']."\" alt=\"".$row['products_name']."\"> </div> <div class=\"movTxt\"> <h3>".$row['products_name']."</h3> <p>".$row['products_price']."</p> <a href=\"productdetail.php?id=".$row['products_id']."\">View Product.....</a> </div> </div>"; $con++; }else if($con == 2){ echo"<div class=\"fourcol last\"> <div class=\"movImg\"> <img src=\"images/".$row['products_thumb']."\" alt=\"".$row['products_name']."\"> </div> <div class=\"movTxt\"> <h3>".$row['products_name']."</h3> <p>".$row['products_price']."</p> <a href=\"productdetail.php?id=".$row['products_id']."\">View Product.....</a> </div> </div> </div> </div> <div class=\"row\">"; $con = 0; } } $numRows = mysql_num_rows($movResults); $div = $numRows%3; if($div==1){ echo"<div class=\"eightcol last\"></div></div></div>"; }else if($div==2){ echo"<div class=\"fourcol last\"></div></div></div>"; } ?> I really dont understand whats happening. I'm new to this Quote Link to comment https://forums.phpfreaks.com/topic/275476-expects-parameter-1-to-be-resource/ Share on other sites More sharing options...
Barand Posted March 11, 2013 Share Posted March 11, 2013 (edited) mysql_error try using it to see why your query failed Edited March 11, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/275476-expects-parameter-1-to-be-resource/#findComment-1417879 Share on other sites More sharing options...
wond3r Posted March 11, 2013 Author Share Posted March 11, 2013 (edited) mysql_error try using it to see why your query failed I was looking into that for the last 15 minutes and I cant figure out where to put(inside of the php code at the top, or in that php code I posted which is the error section) that or how to use it exactly. Edited March 11, 2013 by wond3r Quote Link to comment https://forums.phpfreaks.com/topic/275476-expects-parameter-1-to-be-resource/#findComment-1417881 Share on other sites More sharing options...
Barand Posted March 11, 2013 Share Posted March 11, 2013 the usual place is $movResults = mysql_query($query) or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/275476-expects-parameter-1-to-be-resource/#findComment-1417887 Share on other sites More sharing options...
wond3r Posted March 11, 2013 Author Share Posted March 11, 2013 (edited) the usual place is $movResults = mysql_query($query) or die (mysql_error()); $movResults = mysql_query($allMov) or die (mysql_error()); No database selected Edited March 11, 2013 by wond3r Quote Link to comment https://forums.phpfreaks.com/topic/275476-expects-parameter-1-to-be-resource/#findComment-1417889 Share on other sites More sharing options...
Barand Posted March 11, 2013 Share Posted March 11, 2013 I don't know what your query is - you didn't post it. and I'm not clairvoyant Substitute yours for $query. Quote Link to comment https://forums.phpfreaks.com/topic/275476-expects-parameter-1-to-be-resource/#findComment-1417890 Share on other sites More sharing options...
wond3r Posted March 11, 2013 Author Share Posted March 11, 2013 this is my query at the top, sorry <?php require_once("connect.php"); if(isset($_GET['userSearch'])) { $srch=$_GET['userSearch']; $allMov = "SELECT * FROM tbl_products WHERE products_name LIKE '%". $srch."%' ORDER BY products_name"; } else if (isset($_GET['nav'])) { $select=$_GET['nav']; $allMov = "SELECT * FROM tbl_products, tbl_cat, tbl_l_pc WHERE tbl_products.products_id =tbl_l_pc.products_id AND tbl_cat.cat_id=tbl_l_pc.cat_id AND tbl_cat.cat_name = '".$select."' ORDER BY tbl_products.products_name ASC"; } else{ $allMov = "SELECT * FROM tbl_products ORDER BY products_name ASC"; } $movResults = mysql_query($allMov) or die (mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/275476-expects-parameter-1-to-be-resource/#findComment-1417891 Share on other sites More sharing options...
davidannis Posted March 11, 2013 Share Posted March 11, 2013 I'm guessing that you need to select a database or just failed to connect at all in connect.php. Documentation can be found here: http://php.net/manual/en/function.mysql-select-db.php Quote Link to comment https://forums.phpfreaks.com/topic/275476-expects-parameter-1-to-be-resource/#findComment-1417895 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.