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.... Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.