0

I have always this same error and I dont know how to fix it. Anybody can help maybe?

if (isset($_POST['submit'])) {
    $char = stripslashes($_POST['char']);
    $price = stripslashes($_POST['price']);
    $mensagem = "";

    $charLevel = $SQL->query('SELECT * FROM players WHERE name = '.$char.'');
    foreach($charLevel as $dados){
            $level = $dados['level'];
    }


    foreach($players_from_logged_acc as $player)
    {
        if ($player->getName() == $char){
                $check = 1;
                if ($player->isOnline()){
                        $check = 0;
                        $mensagem = "Your char is online, please log out before placing it for sale!";
                }
                if ($player->getLevel() < 8){
                        $check = 0;
                        $mensagem = "Your character must have a level greater than 7!";
                }
                if ($price <= 0 or $price > 10000){
                        $check = 0;
                        $mensagem = "Please enter a price from 1 to 10000 Premium Points!";
                }
                if ($price % 25 != 0){
                        $check = 0;
                        $mensagem = "Please enter a positive value and a multiple of 25, example: 25, 50, 75, 100 ...";
                }
                break;
        } else {
                $check = 0;
        }
    }

Error is at line

foreach($charLevel as $dados){
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • 1
    [PHP parse/syntax errors; and how to solve them](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them). Look at the quotes in your query string. – KIKO Software May 06 '21 at 10:37
  • 2
    Obviously, $charLevel is not an array, so $SQL->query() is returning any different thing. You can var_export($charLevel) to see what is and debug. – José Carlos PHP May 06 '21 at 11:20

0 Answers0