bitcycle Posted December 10, 2006 Share Posted December 10, 2006 I keep getting mysql_fetch_array(): supplied argument is not a valid MySQL result resource. I have an id field of index type. Why would this not be working. Thanks mark <HTML><?phpinclude "connect.php";$result = mysql_query("SELECT * FROM music WHERE id=$id");$myrow=mysql_fetch_array($result);echo $myrow["artistname"]<br;?></HTML> Link to comment https://forums.phpfreaks.com/topic/30104-mysql_query/ Share on other sites More sharing options...
austine_power007 Posted December 10, 2006 Share Posted December 10, 2006 [quote author=bitcycle link=topic=118047.msg482042#msg482042 date=1165743258]I keep getting mysql_fetch_array(): supplied argument is not a valid MySQL result resource. I have an id field of index type. Why would this not be working. Thanks mark <HTML><?phpinclude "connect.php";$result = mysql_query("SELECT * FROM music WHERE id=$id");$myrow=mysql_fetch_array($result);echo $myrow["artistname"]<br;?></HTML>[/quote]Make the query like: $result = mysql_query("SELECT * FROM music WHERE id=[b][color=red]'$id'[/color][/b]");You missed the (' ') so try nowAnd also u have done wrong in echo statement it should be [b][color=red]echo $myrow[artistname]<br>;[/color][/b]no (" ") between column name of that table. Link to comment https://forums.phpfreaks.com/topic/30104-mysql_query/#findComment-138405 Share on other sites More sharing options...
JP128 Posted December 10, 2006 Share Posted December 10, 2006 What I did when I had the problem with mysql_num_rows was when I selected things from a database, I would change $result = mysql_query("SELECT * FROM music WHERE id=$id");to$result = mysql_query("SELECT * FROM music WHERE id='$id'");now if you didn't notice, i put apostrophes around $id to make it '$id'...try that. Link to comment https://forums.phpfreaks.com/topic/30104-mysql_query/#findComment-138410 Share on other sites More sharing options...
trq Posted December 10, 2006 Share Posted December 10, 2006 [quote]And also u have done wrong in echo statement it should be[/quote]Sorry austin_power007, but non numeric array keys should allways be surrouded by quotes. PHP will throw a [i]notice[/i] if you dont. Link to comment https://forums.phpfreaks.com/topic/30104-mysql_query/#findComment-138411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.