...

View Full Version : Perfect code wired error



Atrhick
08-29-2011, 08:16 PM
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



//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", 270, 200);

guelphdad
08-29-2011, 08:43 PM
Echo out the value for $strQuery and paste that info here.

Old Pedant
08-29-2011, 08:55 PM
You have NO SPACE before the word "WHERE" in your SQL query.


$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!


$strQuery = "SELECT * FROM lead_partners_pages WHERE afid_seller = '202'";

Atrhick
08-29-2011, 08:57 PM
I am still getting the mysql_error for some reason the code line


$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 :confused:

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

Atrhick
08-29-2011, 09:06 PM
You have NO SPACE before the word "WHERE" in your SQL query.


$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!


$strQuery = "SELECT * FROM lead_partners_pages WHERE afid_seller = '202'";




yes sir you are right :) thank you so much

Old Pedant
08-29-2011, 09:30 PM
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

//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.

Atrhick
08-29-2011, 09:35 PM
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

//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.

Old Pedant
08-29-2011, 09:43 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum