Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Perfect code wired error

    Can someone please help me out I am getting this 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 '= '202'' at line 1

    here is the PHP Code I am using

    PHP Code:
    //Fetch all needed records
    $strQuery "SELECT * FROM lead_partners_pages";
    $strQuery .="WHERE afid_seller = '202'";
    $result mysql_query($strQuery) or die(mysql_error());

    $strXML "<graph caption='Monthly Report' decimalPrecision='0' showNames='1' numberSuffix='dollars' pieSliceDepth='30' formatNumberScale='0'>";

    //Iterate through each month
    if ($result) {
    while(
    $ors mysql_fetch_array($result)) 
    {

    $strXML .= "<set name='" $ors['date'] . "' value='" $ors2['price_CIQFY_paid'] . "' />";
    }
    }

     
    //Finally, close <graph> element
    $strXML .= "</graph>";

    //Create the chart - Pie 3D Chart with data from $strXML

    echo renderChart("FusionCharts/FCF_Pie3D.swf"""$strXML"myFirst"270200); 

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    Echo out the value for $strQuery and paste that info here.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    You have NO SPACE before the word "WHERE" in your SQL query.
    Code:
    $strQuery = "SELECT * FROM lead_partners_pages";
    $strQuery .="WHERE afid_seller = '202'";
    either put a space after "..._pages" or before "WHERE" or just put it all on one line and keep it simple!
    Code:
    $strQuery = "SELECT * FROM lead_partners_pages WHERE afid_seller = '202'";
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New Coder
    Join Date
    Aug 2011
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am still getting the mysql_error for some reason the code line

    PHP Code:
    $result mysql_query($strQuery) or die(mysql_error()); 
    the die(mysql_error()); is happening all the time, but i am sure why the mysql query is not working it looks perfect correct

    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 '= '202'' at line 1

  • #5
    New Coder
    Join Date
    Aug 2011
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    You have NO SPACE before the word "WHERE" in your SQL query.
    Code:
    $strQuery = "SELECT * FROM lead_partners_pages";
    $strQuery .="WHERE afid_seller = '202'";
    either put a space after "..._pages" or before "WHERE" or just put it all on one line and keep it simple!
    Code:
    $strQuery = "SELECT * FROM lead_partners_pages WHERE afid_seller = '202'";


    yes sir you are right thank you so much

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Hmmm..."perfect" code, huh? <grin/>

    Anyway, you need to learn how to DEBUG DEBUG DEBUG.

    You did *NOT* do what GuelphDad asked you to do:
    Echo out the value for $strQuery
    You should *ALWAYS* use such debugging techniques!

    If you had done
    Code:
    //Fetch all needed records
    $strQuery = "SELECT * FROM lead_partners_pages";
    $strQuery .="WHERE afid_seller = '202'";
    
    echo "<hr>DEBUG SQL: " . $strQuery . "<hr>\n";
    
    $result = mysql_query($strQuery) or die(mysql_error());
    ...
    And then LOOKED at what the DEBUG output showed you, you would have seen the error for yourself.

    Debugging is AT LEAST 70% of all programming. In many projects, debugging (and testing) occupy 90% of the time of the project. You can't program if you can't debug.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New Coder
    Join Date
    Aug 2011
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Hmmm..."perfect" code, huh? <grin/>

    Anyway, you need to learn how to DEBUG DEBUG DEBUG.

    You did *NOT* do what GuelphDad asked you to do:

    You should *ALWAYS* use such debugging techniques!

    If you had done
    Code:
    //Fetch all needed records
    $strQuery = "SELECT * FROM lead_partners_pages";
    $strQuery .="WHERE afid_seller = '202'";
    
    echo "<hr>DEBUG SQL: " . $strQuery . "<hr>\n";
    
    $result = mysql_query($strQuery) or die(mysql_error());
    ...
    And then LOOKED at what the DEBUG output showed you, you would have seen the error for yourself.

    Debugging is AT LEAST 70% of all programming. In many projects, debugging (and testing) occupy 90% of the time of the project. You can't program if you can't debug.


    then in that case I will remember this I want to me a great programmer so I will learn. Thank you.

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Best of luck to you! You have the right attitude, so you should succeed.

    Note that many computer languages have debuggers, and those can be even more helpful than putting DEBUG messages into your code. I don't use PHP, so I don't know what debuggers are available for it. But I use JSP and ASP and ASP.NET, and there are good debuggers for all of those (and a wonderful one for ASP.NET). If you *can* use a debugger, it will save you many, many hours of frustration in the long run.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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