jeva39 Posted September 23, 2006 Share Posted September 23, 2006 HelloI use this simple code to try something in my Web Server (Using PHP 4.4 and mySql 4.1):[code]<?php$con = mysql_connect("localhost", "username", "pass");mysql_select_db("jv");$query = "SELECT tema, ritmo FROM temas where ritmo='BALADA' order by tema";$result = mysql_query($query);while($row = mysql_fetch_array($result, MYSQL_NUM)) // Line 8{ echo "Tema : {$row[0]} " . " Ritmo : {$row[1]} <br>";} mysql_close($con);?>[/code]But I receive this error:[color=red]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\Inetpub\vhosts\prolatin.com\httpdocs\php\jv_mysql.php on line 8 [/color]The Database don't have problem. Please do you can help me what is wrong?In my computer all run OK.Thanks in advanced.... Link to comment https://forums.phpfreaks.com/topic/21808-mysql_fetch_array-problem/ Share on other sites More sharing options...
xyn Posted September 23, 2006 Share Posted September 23, 2006 try this...[code=php:0]<?php$con = mysql_connect("localhost", "username", "pass");mysql_select_db("jv");$result = mysql_query("SELECT tema, ritmo FROM temas where ritmo='BALADA' order by tema") or die('Result Error: '.mysql_error().'');while($row = mysql_fetch_array($result, MYSQL_NUM)) // Line 8{ echo "Tema : {$row[0]} " . " Ritmo : {$row[1]} <br>";} mysql_close($con);?>[/code] Link to comment https://forums.phpfreaks.com/topic/21808-mysql_fetch_array-problem/#findComment-97387 Share on other sites More sharing options...
Destruction Posted September 23, 2006 Share Posted September 23, 2006 Not a valid result resource means the query returned no rows or failed for another reason. You should ideally be checking at each stage to make sure it's successful before performing the next step.Dest Link to comment https://forums.phpfreaks.com/topic/21808-mysql_fetch_array-problem/#findComment-97390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.