MYSQL error - calculating paths to victory

Help
sksource
2011-03-21
2013-03-27
  • sksource
    sksource
    2011-03-21

    I tried to run "php ./calculate_paths_to_victory.php" from the CLI and I'm getting a MYSQL error:

    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 'group by b.id' at line 1

    Any ideas?

     
  • Rob J
    Rob J
    2011-03-21

    Are you running it from the right directory? I don't know if this matters. Just guessing.

     
  • sksource
    sksource
    2011-03-21

    Yea, from admin/

    I'm assuming this is the query it's talking about:

    $query = "SELECT b.id, b.name, count(*) c FROM `brackets` b,`possible_scores` p where p.bracket_id = b.id and p.rank <= " . $maxrank . " group by b.id";
    

    Also, here's the version of mysql I'm running: mysql -version
    mysql  Ver 14.14 Distrib 5.1.49, for debian-linux-gnu (x86_64) using readline 6.1

     
  • Botag
    Botag
    2011-03-21

    Do all your brackets have valid IDs?

     
  • sksource
    sksource
    2011-03-21

    It appears so, sequential numbers.

     
  • sksource
    sksource
    2011-03-22

    Have you guys tested it?  I'm curious if it's just me or if others are having the same problem.  Also, what version of MySQL are you running?

     
  • Botag
    Botag
    2011-03-22

    I have two instances of it running and I haven't experienced that error. I'm running mysql  Ver 14.12 Distrib 5.0.91.

    I wonder if it could be related to special characters in bracket names.

     
  • sksource
    sksource
    2011-03-22

    Besides A-Z 0-9, my bracket names have:

    #
    '
    -
    !
    _
    ?

    in them…

     
  • John Holder
    John Holder
    2011-03-22

    I'm on 5.0.45 with no issues.

     
  • sksource
    sksource
    2011-03-23

    I had it fwrite the query to STDOUT, and apparently the $maxrank variable isn't getting set?  Here's the output:

    SELECT b.id, b.name, count(*) c FROM `brackets` b,`possible_scores` p where p.bracket_id = b.id and p.rank <=  group by b.id
    

    So p.rank has no value being set.  I'm a novice with php at best, so any advice on how/where p.rank is supposed to get set or any other advice is greatly appreciated.

     
  • sksource
    sksource
    2011-03-23

    Also, I added some debugging to see what #maxScoreRanks is, as shown below:

     for( $scoreRank=1; $scoreRank <= $maxScoreRanks; $scoreRank++ )
            {
                    updateProbabilities( $roundMap, $seedMap, $childGraph, $scoring, $master_data, $scoreRank, $db );
            }
            // Also, do last place calc...
            updateProbabilities( $roundMap, $seedMap, $childGraph, $scoring, $master_data, $numBrackets, $db );
            fwrite(STDOUT, "Score rank: $maxScoreRanks \n");
            eliminatecalc($db, $maxScoreRanks);
    

    But it appears #maxScoreRanks doesn't have a value assigned to it… thoughts?

     
  • Rob J
    Rob J
    2011-03-23

    Ahh.

    Check your admin/database.php file. It is probably out of date.

    $maxScoreRanks is set in that file.

    admin/database.php is not under source control. admin/database.php.tmp is under source control.

    When you update your source, you need to manually copy and rename database.php.tmpl to database.php and reenter your authentication information.

     
  • sksource
    sksource
    2011-03-23

    That did it, thanks!