Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/botomul/public_html/whatsnew.php on line 130

Can Anyone tell me, How could i solve this issue, Please I need help immidiately.

<?php error_reporting (E_ALL ^ E_NOTICE); ?>
<?php
	$item=$_GET['id'];
	include ("header.php");
	$mark = mysql_query("select * from product order by product_id DESC");
	$counter=0;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Welcome to the biggest marketplace-BOTOMUL.COM</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<link rel="stylesheet" type="text/css" href="style.css" />
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="iecss.css" />
<![endif]-->
<script type="text/javascript" src="js/boxOver.js"></script>
</head>
<body>
<div id="main_container">
  <div id="header">
    <div class="top_right">
      <div class="big_banner"> <a href="#"></a> </div>
    </div>
    <div id="logo"> <a href="index.html"><img src="images/logo.png" alt="" border="0" /></a> </div>
  </div>
  <div id="main_content">
    <div id="menu_tab">
      <ul class="menu">
        <li><a href="index.html" class="nav">Home</a></li>
        <li class="divider"></li>
        <li><a href="whatsnew.php" class="nav">What’s New?</a></li>
        <li class="divider"></li>
        <li><a href="add_item.php" class="nav">Post free ads</a></li>
        <li class="divider"></li>
        <li><a href="contact.html" class="nav">Contact Us</a></li>
        <li class="divider"></li>
        <li><a href="about.html" class="nav">About Botomul</a></li>
		<li class="divider"></li>
        <li><a href="legal.html" class="nav">Legal Obligations </a></li>
      </ul>
    </div>
    <!-- end of menu tab --><div class="crumb_navigation"> Navigation: <span class="current"><a href="whats.php">What’s New?</a></span><script type="text/javascript"><!--
google_ad_client = "pub-8864553545203442";
/* 468x15, created 2/9/11 */
google_ad_slot = "7003637958";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
     <div class="left_content">
      <div class="title_box">Jobs</div>
      <ul class="left_menu">
       <li class="odd"><a href="jobs_item.php?id=Accounting/Finance">Accounting/Finance</a></li>
        <li class="even"><a href="jobs_item.php?id=Bank/Insurance/Leasing">Bank/Insurance/Leasing</a></li>
        <li class="odd"><a href="jobs_item.php?id=Commercial/Supply Chain">Commercial/Supply Chain</a></li>
        <li class="even"><a href="jobs_item.php?id=Education/Training">Education/Training</a></li>
        <li class="odd"><a href="jobs_item.php?id=Engineer/Architecture">Engineer/Architecture</a></li>
		<li class="even"><a href="jobs_item.php?id=Garments/Textile">Garments/Textile</a></li>  
		<li class="odd"><a href="jobs_item.php?id=HR/Org. Development">HR/Org. Development</a></li>
        <li class="even"><a href="jobs_item.php?id=Admin">Admin</a></li>
        <li class="odd"><a href="jobs_item.php?id=Design/Creative">Design/Creative</a></li>
        <li class="even"><a href="jobs_item.php?id=IT/Telecommunication">IT/Telecommunication</a></li>
        <li class="odd"><a href="jobs_item.php?id=Call Center">Call Center</a></li>
		<li class="even"><a href="jobs_item.php?id=Advertisement/Event Mgt.">Advertisement/Event Mgt.</a></li>
		<li class="odd"><a href="jobs_item.php?id=Medical/Pharmaceutical">Medical/Pharmaceutical</a></li>
        <li class="even"><a href="jobs_item.php?id=NGO/Development">NGO/Development</a></li>
        <li class="odd"><a href="jobs_item.php?id=Research/Consultancy">Research/Consultancy</a></li>
        <li class="even"><a href="jobs_item.php?id=Secretary/Receptionist">Secretary/Receptionist</a></li>
        <li class="odd"><a href="jobs_item.php?id=Data Entry/Operator/BPO">Data Entry/Operator/BPO</a></li>
		<li class="even"><a href="jobs_item.php?id=Others">Others</a></li>          
      </ul>
      <div class="title_box">Botomul Village</div>
       <ul class="left_menu">
        <li class="odd"><a href="bo_item.php?id=Events">Events</a></li>
        <li class="even"><a href="bo_item.php?id=Art">Art</a></li>
        <li class="odd"><a href="bo_item.php?id=Creative Writing">Creative Writing</a></li>
        <li class="even"><a href="bo_item.php?id=Theater">Theater</a></li>
        <li class="odd"><a href="bo_item.php?id=Music">Music</a></li>
		<li class="even"><a href="bo_item.php?id=Media">Media</a></li>       
		<li class="odd"><a href="bo_item.php?id=Fashion">Fashion</a></li>
		<li class="even"><a href="bo_item.php?id=Food">Food</a></li>       
		<li class="odd"><a href="bo_item.php?id=Health/Fitness">Health/Fitness</a></li>
		<li class="even"><a href="bo_item.php?id=Groups and Association">Groups and Associations</a></li>       
		<li class="odd"><a href="bo_item.php?id=Matchmaking">Matchmaking</a></li>
		<li class="even"><a href="bo_item.php?id=Friendship">Friendship</a></li>       
		<li class="odd"><a href="bo_item.php?id=Humanitarian Appeal">Humanitarian Appeal</a></li>
		<li class="even"><a href="bo_item.php?id=Botomul Mag">Botomul Mag </a></li>
		<li class="odd"><a href="bo_item.php?id=Miscellaneous">Miscellaneous</a></li>   
		<li class="odd"><script type="text/javascript"><!--
google_ad_client = "pub-8864553545203442";
/* 200x200, created 2/9/11 */
google_ad_slot = "3037108602";
google_ad_width = 200;
google_ad_height = 200;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></li>     
       </ul>              
    </div>
		
	
    <!-- end of left content -->
    <div class="center_content22">
	   <table style="font-size:14px" align="center" width="100%" bgcolor="#FFFFFF" >

					<tr>				
					
							<th width="18%" height="39" style="background-color:#E1E0E0">Image</th>
	
							<th width="19%" height="39" style="background-color:#E1E0E0">Title</th>
							
							<th width="63%" height="39" style="background-color:#E1E0E0">Description</th>
														

					</tr>



<?php



while($data = mysql_fetch_array($mark)) {
		if($counter>=20)
			break;
 ?>
<?php if($counter%2==0) {
	   				$counter++;						
	   				?> 
						<tr bgcolor="#E9E9E9">
					<?php }
						else {
							$counter++;
							
					?>
					<tr bgcolor="#F0F4F5">
					<?php
						}
						?>
					
						<td align="center">
							<a href="se_details.php?product_id=<?php echo $data['product_id']; ?>">
							<?php
								if($data['picture1'] != '') {
								?>
								<img src="ad_file/<?php echo $data['picture1']; ?>" width="55px" height="50px" />
								<?php 
									}
									else {
								?>
									<img src="images/de.gif" width="55px" height="50px" />
								<?php 
								}
								?>
							</a>
						</td>
						
						<td align="center">
							<div class="product_title">
								<div align="left"><a href="se_details.php?product_id=<?php echo $data['product_id']; ?>">
							    &nbsp;<?php echo $data['title'] ?>								</a> </div>
							</div>
					  </td>

						<td align="left">
							<div class="product_title">
								&nbsp;
								<?php if($data['details'] == '')
														echo "NA";
												  else {
												     
													 	$temp = $data['details'];
														$a = strlen($temp);
														echo $temp1 = substr($temp, 0, 80);  // abcd
													?>
														<a href="o_details.php?product_id=<?php echo $data['product_id']; ?>">
														<?php /*?><span class="more" style="color:#FF8040">
														<?php
															echo " more...";
														?></span><?php */?>
														</a>
													<?php	
														
													} ?>
						</div>
						</td>
						

<?php } ?>
	  </table>
	</div>
      
		 
	<div class="footer">
    
   <div class="right_footer"><a href="about.html">About Botomul</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="legal.html">Legal Obligations</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="contact.html">Contact Us</a></div>
  </div>
 
	 
     
</div>
<!-- end of main_container -->
</body>
</html>

Dani AI

Generated

The warning means the value passed into mysql_fetch_array was not a valid result resource — in other words the SELECT did not return a usable result (query failure, no DB connection, or the result variable was changed). The replies by and about checking names and by about surfacing the DB error are on point; add to those by confirming the connection made in header.php actually succeeded and by running the same SELECT directly in your database client so you see the server error text instead of only the fetch warning. Prefer logging the database error to the server log during development rather than halting output in production.

A more robust, long‑term fix is to move off the legacy mysql extension and use PDO or mysqli with proper error handling and output escaping. For example (PDO, minimal):

<?php
try {
    $pdo = new PDO('mysql:host=HOST;dbname=DBNAME;charset=utf8', 'USER', 'PASS', [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    ]);
    $stmt = $pdo->query('SELECT product_id,title,picture1,details FROM product ORDER BY product_id DESC LIMIT 20');
    $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
    foreach ($rows as $r) {
        echo '<td>' . htmlspecialchars($r['title'], ENT_QUOTES, 'UTF-8') . '</td>';
    }
} catch (PDOException $e) {
    error_log('DB error: ' . $e->getMessage());
    echo 'Service temporarily unavailable.';
}

Finally, checklist before iterating results: confirm the connection resource, verify the SQL runs in the DB shell, ensure the result variable isn’t overwritten earlier, and guard against empty result sets. Note that the old mysql extension was removed from modern PHP releases, so migrating to PDO/mysqli also avoids compatibility problems and improves security (use prepared statements when incorporating user input).

Recommended Answers

All 4 Replies

check that the spelling in your query is right for rows, columns and tables.

eg. is yout table called product or products?

also try

mysql_fetch_assoc

instead of

mysql_fetch_array

change: $mark = mysql_query("select * from product order by product_id DESC"); to: $mark = mysql_query("select * from product order by product_id DESC") or die( mysql_error() ); It should tell you WHY the query is failing.

$mark = mysql_query("select * from product order by product_id DESC");

Make ensure that the field names are correct (`product`, `product_id`). Recommend to do as hielo's way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.