Forums

This topic is locked

Error 1064: using DMX, MYSQL, PHP - syntax is ok?

Posted 09 Oct 2005 19:47:36
1
has voted
09 Oct 2005 19:47:36 Nathan Hillman posted:
Can anyone help? I get the following error when I create a recordset:

<b>MM_ERROR:1064 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 '' at line 2 </b>

I have checked the syntax of my query direct in MYSQL (4.1.14) using PHPmyAdmin and it works perfectly. Even when creating the Recordset it works perfectly when I click Test.

Can anyone give me any ideas?

Thanks

My code is attached below:


&lt;?php require_once('Connections/SCL_Connection.php'); ?&gt;
&lt;?php
$varWeek_LeagueTable = "1";
if (isset($_POST['Week'])) {
$varWeek_LeagueTable = (get_magic_quotes_gpc()) ? $_POST['Week'] : addslashes($_POST['Week']);
}
mysql_select_db($database_SCL_Connection, $SCL_Connection);
$query_LeagueTable = sprintf("SELECT t.teamID, t.teamname, TOTAL.TotalPoints, WEEK.WeekPoints FROM nh_team AS t, (SELECT t.teamID, SUM(s.points) AS TotalPoints FROM nh_scores AS s, nh_team AS t WHERE s.teamID=t.teamID AND s.weekID&lt;=%s GROUP BY t.teamID ORDER BY TotalPoints DESC) AS TOTAL, (SELECT t.teamID, s.points AS WeekPoints FROM nh_scores AS s, nh_team AS t WHERE s.teamID=t.teamID AND s.weekID=%s) AS WEEK WHERE WEEK.teamID=TOTAL.teamID AND TOTAL.teamID=t.teamID ORDER BY TOTAL.TotalPoints DESC", $varWeek_LeagueTable,$varWeek_LeagueTable);
$LeagueTable = mysql_query($query_LeagueTable, $SCL_Connection) or die(mysql_error());
$row_LeagueTable = mysql_fetch_assoc($LeagueTable);
$totalRows_LeagueTable = mysql_num_rows($LeagueTable);
?&gt;
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;p&gt;League Table
&lt;/p&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
&lt;?php
mysql_free_result($LeagueTable);
?&gt;

Replies

Replied 10 Apr 2008 15:28:36
10 Apr 2008 15:28:36 Valentin Tin replied:
Hey there, I am also getting the same problem due to the nested SELECTS. Any info you might have would be highly appreciated. I was able to do this with DW 8, but with CS3 it is not working.

Cheers,

Valentin Secades
Developer/Trainer
QXDEV.com

Edited by - vsecades on 10 Apr 2008 15:29:24

Reply to this topic