0

I'm getting a http 500 error when trying to post to this leaderboard index:

<?php
$reference = "sorted";
$printboard = "leaderboard";

$my_win = 0;
$my_check = 0;


//get the name or member or element of the lowest score 
$my_check = $redis->zRange($reference, 0, 0);

//I have the lowest ranking member now get that members score to check against 
$my_win = $redis->zScore($reference, $my_check[0]);

//$wins is what I'm posting to this index
if ($my_win < $wins) {

$redis->zDelete($reference, $my_check);//I beat the lowest ranking user so take his spot 

//update the new score and push the new user to the print list 
$redis->zAdd($reference,$wins, $name);


//if im adding someone new I need to remove someone


//if this is running I want to strip the list of it's 99th user so don't use 1188 use 1176
$redis->listTrim($printboard, 0, 1176);

//then rpush the new player to have made the list 
$redis->rpush($printboard,$name,$avatar,$wins,$losses,$ties,$fave,$meter,$game1,$game2,$game3,$game4,$game5);

}

?>

Is my use of zRange correct?

$my_check = $redis->zRange($reference, 0, 0);

And then checking the first array spot?

$my_win = $redis->zScore($reference, $my_check[0]);

I think this may be my issue am I using the return of $my_check incorrectly?

Also, with Redis do you ever need to initialize anything? I frequently go over the phpredis GitHub manual and the redis website itself and didn't note any details about what happens if you use zRange on an empty sorted set.

Pfrex
  • 159
  • 2
  • 13
  • A 500 error means that a server error occurred. To see the _actual_ error message, check your servers error log. You can also change how PHP displays errors and tell it to show all errors directly on the screen (this is not something you want in production though, since it can show sensitive data, but during development, you should). Here's how to show all errors and warnings: https://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings – M. Eriksson Jun 08 '18 at 21:43
  • Thank you, that was part of my issue and the log did display an unwanted " = = " php parse error. – Pfrex Jun 08 '18 at 21:52
  • Then you should fix that issue and try again. – M. Eriksson Jun 08 '18 at 21:53
  • 1
    Yes, that was all of my problem apparently. Your answer solved my problem. – Pfrex Jun 08 '18 at 22:09
  • I just had another quick thought. How does the server error thing work? Specifically wondering about how it would deal with an error with redis syntax or would that just be silent? I originally thought I was doing something wrong with the Redis commands. So, I misspelled a Redis command to test and still got a 500 error, but nothing in the log... Anyways, thanks again if you post your comment as an answer I'll check mark it. – Pfrex Jun 08 '18 at 22:33

0 Answers0