Jump to content

[SOLVED] Not a Valid MySQL result resource???


refiking

Recommended Posts

Heres what the script returns when ran:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/refiking/public_html/scripting/process.php on line 13

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/refiking/public_html/scripting/process.php on line 14

 

Here are line 12-14:

$sl =  mysql_query("SELECT * From tourney WHERE tid = '$tid' AND user = '$user'");
$fetch_em = mysql_fetch_array($sl);
$numrows = mysql_num_rows($sl);

 

Link to comment
https://forums.phpfreaks.com/topic/86923-solved-not-a-valid-mysql-result-resource/
Share on other sites

You failed to check your result before using it. The minimum syntax for a select should be...

 

<?php

$sql = "SELECT * From tourney WHERE tid = '$tid' AND user = '$user'";
if ($result =  mysql_query($sql)) {
  if (mysql_num_rows($result)) {
    $fetch_em = mysql_fetch_array($result);
  }
} else {
  die(mysql_error() . $sql);
}

?>

Actually, this is a tournament script.  I am searching to see if the name is listed under this tournament id.  There are 32 different players, so I'd like to search to see if their name is listed under one of the 32 columns for players.  Is there a way to accomplish this?

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.