Message: syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'

The following does not work and throws an exception.

leaderboard_mode.php

<?php

class Leaderboard_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }

    public function get_by_role()
    {
        $query = $this->db->query->("SELECT b. * FROM (SELECT a. *, @rank := @rank + 1 rank FROM (SELECT MAX(score) AS max_score, user_id FROM highscore WHERE game_mode="bungkata" GROUP BY user_id ORDER BY max_score DESC)a, (SELECT @rank := 0)r)b LIMIT 10");
        return $query->result();
    }
}

This is the exception:

An uncaught Exception was encountered

Type: ParseError

Message: syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'

Filename: C:\wamp\www\leaderboard\application\models\Leaderboard_model.php

Line Number: 12

Backtrace:

File: C:\wamp\www\leaderboard\application\controllers\Leaderboard.php Line: 9 Function: model

File: C:\wamp\www\leaderboard\index.php Line: 315 Function: require_once

You just need to remove -> from query->, like $this->db->query() Please see below updated code

public function get_by_role()
    {
        $query = $this->db->query("SELECT b. * FROM (SELECT a. *, @rank := @rank + 1 rank FROM (SELECT MAX(score) AS max_score, user_id FROM highscore WHERE game_mode='bungkata' GROUP BY user_id ORDER BY max_score DESC)a, (SELECT @rank := 0)r)b LIMIT 10");
        return $query->result();
    }

How to fix this error message: syntax error, unexpected '[', Please check your php version. Use [] not work in old php versions, change your code: $options = array( 'roles' => 'administrator', );. The error message syntax error near unexpected token ` (‘ occurs in a Unix-type environment, Cygwin, and in the command-line interface in Windows. This error will most probably be triggered when you try to run a shell script which was edited or created in older DOS/Windows or Mac systems.

leaderboard_model.php

<?php
 
class Leaderboard_model extends CI_Model {

	function __construct()
    {
        parent::__construct();
    }

    public function get_by_role()
  	{
	    $query = $this->db->query("SELECT b. * FROM (SELECT a. *, @rank := @rank + 1 rank FROM (SELECT MAX(score) AS max_score, user_id FROM highscore WHERE game_mode=bungkata GROUP BY user_id ORDER BY max_score DESC)a, (SELECT @rank := 0)r)b LIMIT 10");
	    return $query->result();
  	}
}

Parse error: syntax error, unexpected '}' on get_the_author_meta , Let's unwrap it to more readable form: <?php if ( ! empty( get_the_author_meta( ' facebook', $part_cur_auth_obj->ID ) ) ) { ?><a href="<?php� Parse error: syntax error, unexpected T_STRING, expecting '; ' in file.php on line 217 Which lists the possible location of a syntax mistake. See the mentioned file name and line number. A moniker such as T_STRING explains which symbol the parser/tokenizer couldn't process finally.

change this query $query = $this->db->query-> to $query = $this->db->query("your sql query")

public function get_by_role()
{
    $query = $this->db->query->("SELECT b. * FROM (SELECT a. *, @rank := @rank + 1 rank FROM (SELECT MAX(score) AS max_score, user_id FROM highscore WHERE game_mode="bungkata" GROUP BY user_id ORDER BY max_score DESC)a, (SELECT @rank := 0)r)b LIMIT 10");
    return $query->result();
}

Error message: Parse error: syntax error, unexpected '{' on line 11 , Error message: Parse error: syntax error, unexpected '{' on line 11. I'm not entirely sure what I'm doing wrong, but I keep getting the same error message. Here is� The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided. This might be a simple typo. Message

What is a Parse Error?, <?php echo "Hello World!; this(); that(); ?> php. The parser will display an error message similar to this one: Parse error: syntax error, unexpected end of file,� [Support Guide] Why do I see “Uncaught SyntaxError: Unexpected token <” errors? How can I use chunking or versioning for my assets at Netlify?

Parse error: syntax error, unexpected, There was an error in the plugin update, which caused the website to crash. Support � Plugin: Orbit Fox by ThemeIsle � Parse error: syntax error, unexpected to be fine but a day later my site went down with the following error message. eric@dev ~ $ php a.php PHP Parse error: syntax error, unexpected T_VARIABLE in /home/el/code/a.php on line 3 Explanation: The PHP parser converts your program to a series of tokens.

Parse Error: Syntax Error, Unexpected $end, When programming in PHP, webmaster can encounter an error with a message such as parse error:syntax error, unexpected $end. This error� The second and third further refine the description and indicate if there is a syntax problem or a connection problem, etc., has occurred. the most important set

Comments
  • please, look at my answer in this question