Título: Warning: mysql_fetch_assoc(): en Dreamweaver CS5 con BD Publicado por: DJmixmancar en 11 Diciembre 2010, 07:15 am Hola disculpe por volver a molesta ;D
tengo un problema con mi CODIGO eso creo ;D estoy asiendo consultas en php y Adobe Dreamweaver CS5 con conexiones. aprendido allamar y hacer consultas con Adobe Dreamweaver CS5 al base de datos. trabajo con mysql mi problema que qye me sale 1 registro nada mas. hay como 10 registros Citar Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result resource in C:\AppServ\www\12\demus\index2.php on line 59 id nombre clave titulo mensaje 1 juan carlo silva jejeje skdskds md ksdk skdskd ksd k echo todo exato loque esta en un tuto. pero me sale ese error este file : Citar <?php require_once('Connections/users.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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_users, $users); $query_mostar = "SELECT * FROM usuario"; $mostar = mysql_query($query_mostar, $users) or die(mysql_error()); $row_mostar = mysql_fetch_assoc($mostar); $totalRows_mostar = mysql_num_rows($mostar); mysql_free_result($mostar); ?> <table border="1" cellpadding="4" cellspacing="4"> <tr> <td>id</td> <td>nombre</td> <td>clave</td> <td>titulo</td> <td>mensaje</td> </tr> <?php do { ?> <tr> <td><?php echo $row_mostar['id']; ?></td> <td><?php echo $row_mostar['nombre']; ?></td> <td><?php echo $row_mostar['clave']; ?></td> <td><?php echo $row_mostar['titulo']; ?></td> <td><?php echo $row_mostar['mensaje']; ?></td> </tr> <?php } while ($row_mostar = mysql_fetch_assoc($mostar)); ?> </table> este de la conexion: Citar <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_users = "localhost"; $database_users = "demus"; $username_users = "root"; $password_users = "147"; $users = mysql_pconnect($hostname_users, $username_users, $password_users) or trigger_error(mysql_error(),E_USER_ERROR); ?> aver si me ayudan porfa. se lo gradesco de ante mano. gracias ;) Título: Re: Warning: mysql_fetch_assoc(): en Dreamweaver CS5 con BD Publicado por: Shell Root en 11 Diciembre 2010, 18:52 pm Para la conexión usa la siguiente, es lo mismo pero más organizado,
Código
Ahora para realizar la consulta realiza lo siguiente, Código
Título: Re: Warning: mysql_fetch_assoc(): en Dreamweaver CS5 con BD Publicado por: DJmixmancar en 12 Diciembre 2010, 03:48 am gracias amigos por la el codigo. pero sera mi torpesa. pero no me mostra 1 error
Citar Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\AppServ\www\travel\login\usuarios.php on line 87 pero alguna comentario al codigo. ya que lo genere con Dreamweaver CS5. me crea atomaticamente el codigo.Error: gracias. por tu aporte. Título: Re: Warning: mysql_fetch_assoc(): en Dreamweaver CS5 con BD Publicado por: Shell Root en 13 Diciembre 2010, 17:04 pm Entonces muéstranos unas partes de la linea de donde se muestra el error, es decir,
Código
Para ver donde esta el error. Título: Re: Warning: mysql_fetch_assoc(): en Dreamweaver CS5 con BD Publicado por: ~ Yoya ~ en 13 Diciembre 2010, 21:59 pm El problema esta en mysql_free_result (http://www.php.net/manual/es/function.mysql-free-result.php), ponerlo al final del while() o antes de cerrar la conexión.
Ejemplo de lo que haces: Código
Salida: Citar Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in /var/www/html/c.php on line 9 Código
Salida: Citar 1-> Ejemplo de saludar 3-> xsaludo de Hola mundo Saludos. Título: Re: Warning: mysql_fetch_assoc(): en Dreamweaver CS5 con BD Publicado por: DJmixmancar en 17 Diciembre 2010, 03:20 am ;D bueno encontre la solucion de Dreamweaver con refencia de ~ Yoya ~
bueno el problema esque cree un documento php en blanco. sin <html><head> </etc> :silbar: el Dreamwaver cuando trabaja con DB. puede generar codigo automatico. lo comoda dentro entre <HTML> al refrescar las consulta tiene que estar al final de codigo es decir esto es lo correcto Citar </body> </html> <? mysql_free_result($mostar); ?> yo via puesto asi Citar mysql_select_db($database_users, $users); $query_mostar = "SELECT * FROM usuario"; $mostar = mysql_query($query_mostar, $users) or die(mysql_error()); $row_mostar = mysql_fetch_assoc($mostar); $totalRows_mostar = mysql_num_rows($mostar); mysql_free_result($mostar); ?> <table border="1" cellpadding="4" cellspacing="4"> <tr> <td>id</td> <td>nombre</td> <td>clave</td> <td>titulo</td> <td>mensaje</td> </tr> <?php do { ?> <tr> <td><?php echo $row_mostar['id']; ?></td> <td><?php echo $row_mostar['nombre']; ?></td> <td><?php echo $row_mostar['clave']; ?></td> <td><?php echo $row_mostar['titulo']; ?></td> <td><?php echo $row_mostar['mensaje']; ?></td> </tr> <?php bueno si algien tiene un problema igual. en Dreamwaver con BD. Citar Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in lo unico es acomodar los mysql_free_result($mostar);solucionado. gracias ~ Yoya ~ Shell Root |