Ok, here's my problem.

I'm coding a database for a friend of mine (first time I've done this sort of program) for a game he plays.

In the game you can "scout" someone, and you get information on the "kingdom" they are playing.

I take the scout, break it up into individual values, then save it. So far I have everything fixed, except one little detail.

I am using a SELECT query to see if data for that kingdom already exists. If it doesn't exist the data is saved using INSERT. If it does exist it is saved using UPDATE.

However, here is how I see if the kingdom exists:

$exists = mysql_query($select_query);

if (mysql_num_rows($exists)) {
// various things happen
}

The problem is with mysql_num_rows. When I execute the script I get the error:

Warning: Supplied argument is not a valid MySQL result resource in ../inc/mysql.php on line 58

I'm trying to use mysql_num_rows to find if any rows were found. If no rows where found then no data exists. If rows were found then data does exist.

Is there a different function I should use, or is my problem something entirely different?

    wears dunce cap

    Being the genius that I am, I decided to see what mysql_error() would say. It said I didn't select the database.

    I had placed my connect and selectdb outside of the function I'm using, and each where loaded with variables from an "editthis.php" file.

    Just incase a problem would appear I decided to move them both inside of the function without making the variables in them global.

    Someone shoot me.

    Problem solved and it works now...such a hollow victory.

      Write a Reply...