Re: Repeat Region Error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry guys .. resolved it doh!

I was freeing the recordset in

<?php
mysql_free_result($rsSearch);
?>

-Gary

""Gary Maddock-Greene"" <gmg@xxxxxxxxxxxxxxxxxxxx> wrote in message news:5A.42.33998.4B83E494@xxxxxxxxxxxxxxx
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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux