January 13th, 2013, 10:18 PM
There's probably some simple fundamental solution that I'm missing to solve my problem so please throw me a bone.
Let's say I have a dynamic url's setup to display user profiles based on a number that corresponds to a particular profile.
Now let's say 6 does not correspond to any userprofile. If you were to manually navigate to domain.com/?userprofile=6 the resulting page would be blank.
How would I go about checking to see if the sql query corresponding to 6 comes back empty, so that i can either send a redirect or error?
Note: I have have tested numerous values in if statements, such as:
$query = mysql_query("SELECT * FROM `users` WHERE `uploadID` = '$uploadID'");
if($query === 0)
I have also checked to see if an array holding the query data was empty, which didn't work either.
January 13th, 2013, 10:30 PM
You can use mysql_num_rows, or fetch a row (there should be only the one) and check if it is empty.
Also, please consider switching to PDO or mysqli. They are more effective and can be easier to use but most importantly they're safer.
January 14th, 2013, 01:13 AM
Thanks num rows works perfectly, and i will be converting over to PDO.
Originally Posted by requinix