Jump to content

mysql_query


bitcycle

Recommended Posts

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>
<?php
include "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

[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>
<?php
include "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 now
And 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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.