SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Syntax Error

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    167
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Syntax Error

    PHP Code:
    if (isset(($user_info['uid']) = $c_row['adminid']) && ($u_row ['accounttype'])== 1)
    {
         
    mysql_query("UPDATE `companies` SET `eviews` = `eviews` + 1 WHERE `adminid` = '${user_info['uid']}'");

    Error: Parse error: syntax error, unexpected T_STRING, expecting '(' on line 22

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by unemployment View Post
    PHP Code:
    if (isset(($user_info['uid']) = $c_row['adminid']) && ($u_row ['accounttype'])== 1)
    {
         
    mysql_query("UPDATE `companies` SET `eviews` = `eviews` + 1 WHERE `adminid` = '${user_info['uid']}'");

    Error: Parse error: syntax error, unexpected T_STRING, expecting '(' on line 22
    Those are great.

    I've had loads of those, I didn't post them here though; that would be silly.

    I eventually figured out how to address them myself. Sometimes though, I politely asked for help after detailing what my desired outcome was.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    167
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    Those are great.

    I've had loads of those, I didn't post them here though; that would be silly.

    I eventually figured out how to address them myself. Sometimes though, I politely asked for help after detailing what my desired outcome was.
    Whoops... this was the error I meant to display...

    Parse error: syntax error, unexpected '('

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,017
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    there's something wrong with your sql
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    From da manual
    isset() only works with variables as passing anything else will result in a parse error.

  6. #6
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    167
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    I removed the isset

    PHP Code:
    if ((($user_info['uid']) = $c_row['adminid']) && ($u_row ['accounttype'] = 1))
            {
                
    mysql_query("UPDATE `companies` SET `eviews` = `eviews` + 1 WHERE `adminid` = '${user_info['uid']}'");
            } 
    Still getting this error: Parse error: syntax error, unexpected '='

  7. #7
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    You have too many parentheses in your code.

    Try this:

    PHP Code:
    if($user_info['uid']) == $c_row['adminid'] && $u_row ['accounttype'] == 1)
            {
                
    mysql_query("UPDATE `companies` SET `eviews` = `eviews` + 1 WHERE `adminid` = '${user_info['uid']}'");
            } 
    Also, if you want to compare values, use ==
    To make sure the values are completely identical, you can use ===
    A single = is an assignment, and will always return true - so in your code above, you were trying to set $user_info['uid'] to have the same value as $c_row['adminid']

    Let us know if that's cleared it up for you!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •