ID:278314
 
Code:
N/A


Problem description:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a2119527/public_html/Mutes.php on line 5

$num = intval(mysql_fetch_array(MYSQL_QUERY("SELECT * FROM mutes WHERE ckey='$_GET[ckey]'")));

Edit: I'm using MySql 5.0.81. 000Webhost is the hosting service.


As this is obviously a PHP problem I have moved this to a more appropriate forum.
In response to Nadrew
Do you know anygood hosting. which can fix this error and allows multiple MySQL Databases? (Free) O-o
Prestige Entertainment wrote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a2119527/public_html/Mutes.php on line 5

$num = intval(mysql_fetch_array(MYSQL_QUERY("SELECT * FROM mutes WHERE ckey='$_GET[ckey]'")));

mysql_query() (in this instance) returns either a resource if the query was successful, or FALSE if it wasn't.
mysql_fetch_array() requires a resource, and judging by the error message, you ain't giving it one, so mysql_query() must be returning FALSE.

I'm not 100% sure here, but doesn't the ckey in $_GET[ckey] need to be a string?
Put ya query in here and see what it outputs:
$result = mysql_query("SELECT * FROM mutes WHERE ckey='$_GET[ckey]'");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
In response to Murrawhip
Murrawhip wrote:
"SELECT * FROM mutes WHERE ckey='$_GET[ckey]'"


"SELECT * FROM mutes WHERE ckey='" . $_GET['ckey'] . "'"


That's the easiest method of going about not making little mistakes like forgetting the apostrophises in the array to reference an entry.
In response to Tiberath
Always be sure to
mysql_real_escape_string()
sprintf("SELECT * FROM `mutes` WHERE `ckey` = '%s'",
mysql_real_escape_string($_GET['ckey']));
In response to Leur
Leur wrote:
Always be sure to
mysql_real_escape_string()

Well, I personally don't use that mysql library for PHP. I use MySQLi. Which according to the folks at mysql.com is the preferred way to go about it.

I also have something like
foreach($_POST as $key => $value) $_POST[$key] = $mysqli->real_escape_string($value);
in my database.db file (which is called on every page load). Though it's a little more technical then that, 'cause I think we have MagicQuotes or whatever it is enabled.