*

Recent

Author Topic: Categories fix  (Read 11364 times)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Categories fix
« on: February 01, 2012, 08:35:49 PM »
Right now there is a bug with categories where if there are no games added to it then the site spits out a bunch of errors. On base-home.php there is no attempt to stop this, however, on browse.php there is and yet fails to work. Heres how to fix it.

On base-home.php

Code: [Select]
Search for
$baseir1 = sqlcache($sqltitle, $cachelife, $baseir2);

Add after
if(isset($baseir1)){

Now search for
<a href=\''.$playlink.'\'>Play</a></div></td>
      </tr>';
      };

Add after
}else{
echo'<tr>
<td width=\'45\' height=\'45\' valign=\'top\' class=\'content\'>
No games have been added to this category yet.
</td>
</tr>';
}

This comes up twice in the file, do it for each

On browse.php

Code: [Select]
Search for
if(!$db->num_rows($r)){
echo '<tr>
 <td colspan=\'2\' class=\'content\'>There currently are no games in this category.</td>
</tr>';
}

Replace with
if(!isset($r1)){
echo '<tr>
<td colspan=\'2\' class=\'content\'>There currently are no games in this category.</td>
</tr>';
}else{

Search for
}
$count++;
}

Add after
}

lopa

  • Newbie
  • *
  • Posts: 20
  • Force: +1/-0
Re: Categories fix
« Reply #1 on: February 02, 2012, 07:22:49 AM »
Keep in mind the usefulness of if (empty(Blah to create some of your arguments.

But you are right in that the errors are being generated because there is no argument to determine the status of the function.

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Categories fix
« Reply #2 on: February 02, 2012, 09:51:07 PM »
This was a big reason I coded it so that categories would be created inactive by default. It gives you a chance to upload some games into it before it goes live, so that the errors didn't occur. I should have added in some error trapping as well. Sorry folks.

And thanks for the fix!

lopa

  • Newbie
  • *
  • Posts: 20
  • Force: +1/-0
Re: Categories fix
« Reply #3 on: February 04, 2012, 04:55:02 AM »
I just came across this where it covers all of the above and includes "Pages and Blog" also ?

http://freearcadescript.net/forums/index.php/topic,506.msg1852.html#msg1852

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Categories fix
« Reply #4 on: January 08, 2013, 07:21:11 AM »
Quote
if(!isset($r1)){

isset should be used as a last resort when there are no variables to bounce an argument off.

if(empty($r1)){ etc.

Doesn't rely on url's to do the checking ;)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Categories fix
« Reply #5 on: January 08, 2013, 04:31:32 PM »
Quote
if(!isset($r1)){

isset should be used as a last resort when there are no variables to bounce an argument off.

if(empty($r1)){ etc.

Doesn't rely on url's to do the checking ;)

Thanks i will look into changing it.