Web Analytics Made Easy -
StatCounter Perfect code wired error - CodingForum

Announcement

Collapse
No announcement yet.

Perfect code wired error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    Echo out the value for $strQuery and paste that info here.

    Comment


    • #3
      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'";
      Be yourself. No one else is as qualified.

      Comment


      • #4
        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

        Comment


        • #5
          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

          Comment


          • #6
            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.
            Be yourself. No one else is as qualified.

            Comment


            • #7
              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.

              Comment


              • #8
                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.
                Be yourself. No one else is as qualified.

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎