Here's the snipped out part of the code I'm using: [code] $dbh = mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("database"); $movequery = "SELECT * FROM Gallery WHERE category=$category"; $moveresult = mysql_query($movequery); $query = "SELECT * FROM Gallery WHERE id=$id AND category=$category"; $result = mysql_query($query); mysql_close(); $numrows = mysql_num_rows($moveresult); if ( $id == $numrows ) { $nextid=1; } else { $nextid=$id + 1; } if ( $id == 1 ) { $previd=$numrows; } else { $previd=$id - 1; } $row = mysql_fetch_row($result); [/code] Running it at: [u]http://[my url]/gallery.php?id=3&category=0[/u] It gives me: [b]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /[my url]/gallery.php on line 18[/b] [b]Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /[mu url]/gallery.php on line 23[/b] Everything works fine if I change it to something like this: [code]$movequery = "SELECT * FROM Gallery WHERE category=1"; $moveresult = mysql_query($movequery); $query = "SELECT * FROM Gallery WHERE id=1 AND category=1"; $result = mysql_query($query); mysql_close();[/code] So I'm guessing it has something to do with how I'm referencing those variables, but I'm totally stumped, because it used to work, and then suddenly stopped, and I hadn't touched any of the code in the interim. I'm pretty new at this, primarily an artist, just trying to learn some programming skills on the side, so if I've made an idiotic error, you can just chalk it up to that... Thanks in advance for any help!