MYSQL: 4.0.24
PHP: 4.3.11

This is a code from A-Mod, but doesn't see like no one really cares..so thought I'll post it here and maybe I'll get some help. When I'm on activity.php and click next page I get the following error:

Couldn't obtain game data

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5

SELECT * FROM phpbb_ina_games ORDER BY

Line : 749
File : activity.php

Lines 748 and 749:

748	if (!$result = $db->sql_query($sql) )
749		message_die(GENERAL_ERROR, $lang['no_game_data'], "", 

Lines 724-252:


  if ($where_clause) 
     { 
  $extra_where = "AND cat_id = '". $cat ."'"; 
  $new_orderby = "ORDER BY ". $admin_d; 
     } 
  else 
     { 
  $extra_where = "WHERE cat_id = '". $cat ."'";          
  $new_orderby = "ORDER BY ". $admin_d; 
     } 
  } 
   else 
      { 
   $extra_where = ''; 
   $new_orderby = 'ORDER BY '. $order_by; 
      } 


   $sql = "SELECT * 
           FROM ". iNA_GAMES ." 
           $where_clause 
           $extra_where          
$new_orderby"; if (!$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, $lang['no_game_data'], "", __LINE__, __FILE__, $sql); $game_count = $db->sql_numrows($result); $game_rows = $db->sql_fetchrowset($result);

Any help will do thanks a lot.

       $new_orderby = 'ORDER BY '. $order_by; 

    Where is $order_by supposedly being set? It's empty, and that's why your SQL query is failing... can you show us more of the code prior to that section?

      Lines 667-752:

      /* Finished With Adding New Games Bug. */
      
      $template->set_filenames(array('body' => 'amod_files/activity2_body.tpl') );
      if ($user_use_games)
      	$template->assign_block_vars('games_on', array());
      
      $gamelib_link = ($board_config['use_gamelib'] == 1) ? '<div align="center"><span class="copyright">' . $lang['game_lib_link'] . '</span></div>' : '';
      
      if ($board_config['use_point_system'] && $board_config['use_rewards_mod'])
      	$template->assign_vars(array('L_MONEY' => $board_config['points_name']) );
      elseif ( ($board_config['use_cash_system'] || $board_config['use_allowance_system']) && $board_config['use_rewards_mod'] )
      	$template->assign_vars(array('L_MONEY' => $lang['game_cost']) );
      else
      	$template->assign_vars(array('L_MONEY' => $lang['game_number']) );
      
      $where_clause 	= ($userdata['user_level'] == ADMIN) ? '' : "WHERE disabled = '1'";	
      $drop_block 	= ($where_clause) ? "AND disabled = '1'" : '';
      
      	$q1 =  "SELECT *
      			FROM ". iNA_GAMES ."
      			WHERE game_id <> '0'
      			$drop_block
      			ORDER BY proper_name ASC"; 
      	$r1 		= $db->sql_query($q1); 
      	while ($row	= $db->sql_fetchrow($r1) )
      		{
      	if ( ($row['game_parent']) && ($row['game_popup']) )
      		$game_i2 	= append_sid("activity.". $phpEx ."?mode=game&id=". $row['game_id'] ."&parent=true");
      	elseif ( ($row['game_parent']) && (!$row['game_popup']) )
      		$game_i2 	= append_sid("activity.". $phpEx ."?mode=game&id=". $row['game_id'] ."&parent=true");		
      	else
      		$game_i2 	= 'javascript:Gk_PopTart(\'activity.'. $phpEx .'?mode=game&amp;id='. $row['game_id'] .'&sid='. $userdata['session_id'] .'\', \'New_Window\', \''. $row['win_width'] .'\', \''. $row['win_height'] .'\', \'no\')';
      		$game_n2 = $row['proper_name'];
      
      	$template->assign_block_vars('drop', array(
      		'D_SELECT_1' => $game_i2,
      		'D_SELECT_2' => $game_n2) );			
      		}
      
      	$q2 =  "SELECT a.*, COUNT(b.cat_id) AS total
      			FROM ". INA_CATEGORY ." a, ". iNA_GAMES ." b
      			WHERE a.cat_id > '0'
      			AND a.cat_id = b.cat_id
      			GROUP BY a.cat_name
      			ORDER BY a.cat_name ASC"; 
      	$r2 		= $db->sql_query($q2);  
      	while ($row	= $db->sql_fetchrow($r2) )
      		{					
      	$template->assign_block_vars('cat', array(
      		'C_SELECT_1' => '('. $row['total'] .') '. $row['cat_name'],
      		'C_SELECT_2' => "activity.". $phpEx ."?mode=category_play&cat=". $row['cat_id'] ."&sid=". $userdata['session_id']) 
      			);			
      		}
      
      if ( ($mode == 'category_play') && ($HTTP_GET_VARS['cat']) ) 
        { 
      $cat = $HTTP_GET_VARS['cat']; 
      
        if ($where_clause) 
           { 
        $extra_where = "AND cat_id = '". $cat ."'"; 
        $new_orderby = "ORDER BY ". $admin_d; 
           } 
        else 
           { 
        $extra_where = "WHERE cat_id = '". $cat ."'";          
        $new_orderby = "ORDER BY ". $admin_d; 
           } 
        } 
         else 
            { 
         $extra_where = ''; 
         $new_orderby = 'ORDER BY '. $order_by; 
            } 
      
      
         $sql = "SELECT * 
                 FROM ". iNA_GAMES ." 
                 $where_clause 
                 $extra_where          
      $new_orderby"; if (!$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, $lang['no_game_data'], "", __LINE__, __FILE__, $sql); $game_count = $db->sql_numrows($result); $game_rows = $db->sql_fetchrowset($result);

        Just before the $sql variable is set on line 743, stick this in here and tell me what it outputs:

        echo 'order by: ' . $order_by . '<br>';
        echo 'page_order: ' . $page_order . '<br>';
        echo 'admin_d: ' . $admin_d;

          Same thing. Just some errors saying it can't modify page_header.php which is part of a header template.

            Sorry, as I'm not familiar with this I don't think I can offer much help.

              There should be more to the error message, it should show the full $sql trying to be run after the line numer and file.

                Write a Reply...