Re: Repeat Region Error

From: Date: Sun, 21 Dec 2008 13:10:56 +0000
Subject: Re: Repeat Region Error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-284908@lists.php.net to get a copy of this message
Sorry guys .. resolved it doh! I was freeing the recordset in <?php mysql_free_result($rsSearch); ?> -Gary ""Gary Maddock-Greene"" <gmg@maddock-greene.co.uk> wrote in message news:5A.42.33998.4B83E494@pb1.pair.com...
Hi All, I am getting the following error - Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in .... I think it has something to do with my Dreamweaver created code for a repeat region. The head code is: <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;
case "long": case "int":
     $theValue = ($theValue != "") ? intval($theValue) : "NULL";
     break;
case "double":
     $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
     break;
case "date":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;
case "defined":
     $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
     break;
} return $theValue; } } $colname_rsSearch = "-1"; if (isset($_GET['product_name'])) { $colname_rsSearch = $_GET['product_name']; } mysql_select_db($database_sondia_lighting, $sondia_lighting); $query_rsSearch = sprintf("SELECT * FROM products WHERE product_name LIKE %s", GetSQLValueString("%" . $colname_rsSearch . "%", "text")); $rsSearch = mysql_query($query_rsSearch, $sondia_lighting) or die(mysql_error()); $row_rsSearch = mysql_fetch_assoc($rsSearch); $totalRows_rsSearch = mysql_num_rows($rsSearch); ?> <?php mysql_free_result($rsSearch); ?> ... and the code in the page to generate my region is: <?php do { ?>
     <div class="productitem"><img src="products<?php echo $row_rsSearch['product_image']; ?>" />
       <div class="text">
         <h3><?php echo $row_rsSearch['product_name']; ?></h3>
           <p class="style1"><?php echo $row_rsSearch['product_subtitle']; ?></p>
           <a href="products<?php echo $row_rsSearch['product_url']; ?>">View Product</a>
         <div class="clear"></div>
         </div> <div class="clear"></div>
      <center>
         </center>
       </div>
<?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?> If anyone can assist I would really appreciate it - Gary


« previous php.general (#284908) next »