Jump to content

Recommended Posts

 

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 

Link to comment
https://forums.phpfreaks.com/topic/275476-expects-parameter-1-to-be-resource/
Share on other sites

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 by wond3r

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());



?>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.