Foros del Web » Programando para Internet » PHP »

Warning: mysql_free_result(): 5 is not a valid MySQL result ¿por que?

Estas en el tema de Warning: mysql_free_result(): 5 is not a valid MySQL result ¿por que? en el foro de PHP en Foros del Web. Estoy creando un sistema de m.p., pero me da el siguiente error: Cita: Warning: mysql_free_result(): 5 is not a valid MySQL result resource in e:\servidor\www\ffextremo_cms\users\mail\read.php ...
  #1 (permalink)  
Antiguo 05/05/2007, 14:59
Avatar de sumolari  
Fecha de Ingreso: mayo-2006
Ubicación: localhost
Mensajes: 1.367
Antigüedad: 17 años, 11 meses
Puntos: 18
Warning: mysql_free_result(): 5 is not a valid MySQL result ¿por que?

Estoy creando un sistema de m.p., pero me da el siguiente error:
Cita:
Warning: mysql_free_result(): 5 is not a valid MySQL result resource in e:\servidor\www\ffextremo_cms\users\mail\read.php on line 160
read.php
Código PHP:
<?php require_once('../../Connections/ffextremo_cms.php'); ?>
<?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;
}
}

mysql_select_db($database_ffextremo_cms$ffextremo_cms);
$query_site "SELECT sitename, sitedesc, siteauthor, sitekeywords, siteurl, siteys, siteyf FROM site";
$site mysql_query($query_site$ffextremo_cms) or die(mysql_error());
$row_site mysql_fetch_assoc($site);
$totalRows_site mysql_num_rows($site);

$colname_leer_mensaje "-1";
if (isset(
$_POST['id'])) {
  
$colname_leer_mensaje = (get_magic_quotes_gpc()) ? $_POST['id'] : addslashes($_POST['id']);
}
mysql_select_db($database_ffextremo_cms$ffextremo_cms);
$query_leer_mensaje sprintf("SELECT * FROM email WHERE id = %s"GetSQLValueString($colname_leer_mensaje"int"));
$leer_mensaje mysql_query($query_leer_mensaje$ffextremo_cms) or die(mysql_error());
$row_leer_mensaje mysql_fetch_assoc($leer_mensaje);
$totalRows_leer_mensaje mysql_num_rows($leer_mensaje);
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $row_site['sitename']; ?>  &raquo; Zona de usuarios registrados &raquo;Leer mensajes</title>
<meta name="description" content="<?php echo $row_site['sitedesc']; ?>"/>
<meta name="keywords" content="<?php echo $row_site['sitekeywords']; ?>" />
<meta name="author" content="<?php echo $row_site['siteauthor']; ?>" />
<script language="javascript" type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
    mode : "textareas",
    theme : "advanced",
    plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu",
    theme_advanced_buttons1_add_before : "save,separator",
    theme_advanced_buttons1_add : "fontselect,fontsizeselect",
    theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
    theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
    theme_advanced_buttons3_add_before : "tablecontrols,separator",
    theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_path_location : "bottom",
    plugin_insertdate_dateFormat : "%Y-%m-%d",
    plugin_insertdate_timeFormat : "%H:%M:%S",
    extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
    external_link_list_url : "example_data/example_link_list.js",
    external_image_list_url : "example_data/example_image_list.js",
    flash_external_list_url : "example_data/example_flash_list.js"
});
</script>
</head>

<body>
<p><a href="<?php echo $row_site['siteurl']; ?>"><?php echo $row_site['sitename']; ?></a>  &raquo; Zona de usuarios registrados &raquo; Leer mensajes </p>
<h2>Leer mensajes </h2>
<?php 
if (!isset($_POST['id'])) {
    echo 
"Error, no se ha definido la variable del mensaje seleccionado. Si ha accedido a esta error desde un enlace de la web contacte de immediato con el administrador.";
}
else 
{
echo 
"<table width=\"60%\" border=\"0\">
  <tr>
    <td><strong>Asunto:</strong></td>
    <td><label>"
; echo $row_leer_mensaje['title']; echo "</label></td>
  </tr>
  <tr>
    <td><strong>Remitente:</strong></td>
    <td><label>"
; echo $row_leer_mensaje['for']; echo "</label></td>
  </tr>
  <tr>
    <td colspan=\"2\"><strong>Texto:</strong></td>
    </tr>
  <tr>
    <td colspan=\"2\"><label>"
; echo $row_leer_mensaje['text']; echo "</label></td>
    </tr>
  
  <tr>
    <td><strong>Responder a </strong>"
; echo $row_leer_mensaje['for']; echo "</td>
    <td><form id=\"borrar\" name=\"borrar\" method=\"post\" action=\"delete.php\">
      <input name=\"id\" type=\"hidden\" id=\"id\" value=\""
; echo $row_leer_mensaje['id']; echo "\" />
                <label>
                <input type=\"submit\" name=\"Submit\" value=\"Borrar\" />
        </label>
</form>
    </td>
  </tr>
</table>"
;
}  
?>
<p>&nbsp; </p>
<p>Copyright &copy;
  <?php echo $row_site['siteys']; ?> - 
  <?php echo $row_site['siteyf']; ?> <?php echo $row_site['sitename']; ?></p> 
</body>
</html>
<?php
mysql_free_result
($site);

mysql_free_result($leer_mensaje);

mysql_free_result($site);
?>

Última edición por sumolari; 05/05/2007 a las 15:09 Razón: ¡¡En otro!!
  #2 (permalink)  
Antiguo 05/05/2007, 15:09
Avatar de sumolari  
Fecha de Ingreso: mayo-2006
Ubicación: localhost
Mensajes: 1.367
Antigüedad: 17 años, 11 meses
Puntos: 18
Re: Warning: mysql_free_result(): 5 is not a valid MySQL result ¿por que?

También ocurre en index.php :
index.php
Código PHP:
<?php require_once('../../Connections/ffextremo_cms.php'); ?>
<?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;
}
}

mysql_select_db($database_ffextremo_cms$ffextremo_cms);
$query_site "SELECT sitename, sitedesc, siteauthor, sitekeywords, siteurl, siteys, siteyf FROM site";
$site mysql_query($query_site$ffextremo_cms) or die(mysql_error());
$row_site mysql_fetch_assoc($site);
$totalRows_site mysql_num_rows($site);

$colname_lista_mail "-1";
if (isset(
$_COOKIE['username'])) {
  
$colname_lista_mail = (get_magic_quotes_gpc()) ? $_COOKIE['username'] : addslashes($_COOKIE['username']);
}
mysql_select_db($database_ffextremo_cms$ffextremo_cms);
$query_lista_mail sprintf("SELECT * FROM email WHERE `for` = %s"GetSQLValueString($colname_lista_mail"text"));
$lista_mail mysql_query($query_lista_mail$ffextremo_cms) or die(mysql_error());
$row_lista_mail mysql_fetch_assoc($lista_mail);
$totalRows_lista_mail mysql_num_rows($lista_mail);
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $row_site['sitename']; ?>  &raquo; Zona de usuarios registrados &raquo; Bandeja de entrada</title>
<meta name="description" content="<?php echo $row_site['sitedesc']; ?>"/>
<meta name="keywords" content="<?php echo $row_site['sitekeywords']; ?>" />
<meta name="author" content="<?php echo $row_site['siteauthor']; ?>" />
</head>

<body>
<p><a href="<?php echo $row_site['siteurl']; ?>"><?php echo $row_site['sitename']; ?></a>  &raquo; Zona de usuarios registrados &raquo; Bandeja de entrada </p>
<h2>Bandeja de entrada</h2>
<table width="60%" border="0">
  <tr>
    <td>Asunto:</td>
    <td>Remitente:</td>
    <td>Leer:</td>
    <td>Responder:</td>
    <td>Borrar:</td>
  </tr>
  <tr>
    <?php do { ?>
      <td><?php echo $row_lista_mail['title']; ?></td>
      <td><?php echo $row_lista_mail['for']; ?></td>
      <td><div align="center">
        <form id="leer" name="leer" method="post" action="read.php">
          <label>
            <input type="submit" name="Submit" value="Leer" />
            </label>
          <input name="id" type="hidden" id="id" value="<?php echo $row_lista_mail['id']; ?>" />
          </form>
          </div></td>
      <td><div align="center"><a href="create.php?to=<?php echo $row_lista_mail['for']; ?>">&raquo;</a></div></td>
      <td><div align="center">
        <form id="borrar" name="borrar" method="post" action="delete">
          <label>
            <input type="submit" name="Submit2" value="Eliminar" />
            <input name="id" type="hidden" id="id" value="<?php echo $row_lista_mail['id']; ?>" />
            </label>
          </form>
          </div></td>
      <?php } while ($row_lista_mail mysql_fetch_assoc($lista_mail)); ?></tr>
</table>
<p>&nbsp; </p>
<p>Copyright &copy;
  <?php echo $row_site['siteys']; ?> - 
  <?php echo $row_site['siteyf']; ?> <?php echo $row_site['sitename']; ?></p> 
</body>
</html>
<?php
mysql_free_result
($site);
mysql_free_result($lista_mail);
mysql_free_result($site);
?>
¿A qué puede deberse el error?

¡¡ Muchas gracias de antemano !!
  #3 (permalink)  
Antiguo 05/05/2007, 19:26
 
Fecha de Ingreso: diciembre-2005
Ubicación: San Blas, Nayarit
Mensajes: 45
Antigüedad: 18 años, 4 meses
Puntos: 1
Re: Warning: mysql_free_result(): 5 is not a valid MySQL result ¿por que?

mmmmmmmmmmm.. creo que por que ia liberaste una vez la consulta.. fijate hasta abajo de tu codigo ke ahi dos veces la liberacion de memoria mysql con la misma variable..
  #4 (permalink)  
Antiguo 06/05/2007, 00:32
Avatar de sumolari  
Fecha de Ingreso: mayo-2006
Ubicación: localhost
Mensajes: 1.367
Antigüedad: 17 años, 11 meses
Puntos: 18
Re: Warning: mysql_free_result(): 5 is not a valid MySQL result ¿por que?

¡¡Qué ciego estoy!! Como para no verlo...
¡¡Muchas gracias!!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:48.