Help Please - error in your SQL syntax;

Discussion in 'MySQL' started by indeep2k7, Oct 10, 2008.

  1. #1
    Hey All,

    I am getting this error when I try to access my past records page.

    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 1select pickid from tblpickgroups where groupid=
    Code (markup):
    Does anyone know what this means?

    What I did was built the site on a dummy domain then I uploaded it to the new domain and this is the error I am receiving.

    Any help would be appreciated.
     
    indeep2k7, Oct 10, 2008 IP
  2. crivion

    crivion Guest

    Best Answers:
    0
    #2
    that means that you have a ' in minus or in plus
    let us know the query
     
    crivion, Oct 10, 2008 IP
  3. indeep2k7

    indeep2k7 Active Member

    Messages:
    700
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Here is what gets imported.

    DROP TABLE IF EXISTS `tblpickgroups`;
    
    CREATE TABLE `tblpickgroups` (
    
      `pickgroupid` int(10) unsigned NOT NULL auto_increment,
    
      `pickid` int(10) unsigned default NULL,
    
      `groupid` int(10) unsigned default NULL,
    
      PRIMARY KEY  (`pickgroupid`)
    
    ) ENGINE=MyISAM AUTO_INCREMENT=430 DEFAULT CHARSET=latin1;
    
    
    
    --
    
    -- Dumping data for table `tblpickgroups`
    
    --
    
    
    
    LOCK TABLES `tblpickgroups` WRITE;
    
    /*!40000 ALTER TABLE `tblpickgroups` DISABLE KEYS */;
    
    INSERT INTO `tblpickgroups` (`pickgroupid`, `pickid`, `groupid`) VALUES (288,52,17),(287,52,19),(289,53,14),(290,54,17),;
    
    /*!40000 ALTER TABLE `tblpickgroups` ENABLE KEYS */;
    
    UNLOCK TABLES; 
    
    PHP:
     
    indeep2k7, Oct 10, 2008 IP
  4. crivion

    crivion Guest

    Best Answers:
    0
    #4
    what's with that comma at the final?
    you should remove it - replace with this
    INSERT INTO `tblpickgroups` (`pickgroupid`, `pickid`, `groupid`) VALUES (288,52,17),(287,52,19),(289,53,14),(290,54,17);
     
    crivion, Oct 10, 2008 IP
  5. justkidding

    justkidding Active Member

    Messages:
    937
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    comma can be the issue, try to remove that and run the query else break to multiple insert queries.
     
    justkidding, Oct 10, 2008 IP
  6. indeep2k7

    indeep2k7 Active Member

    Messages:
    700
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Ok, here is the full table

    DROP TABLE IF EXISTS `tblpickgroups`;
    CREATE TABLE `tblpickgroups` (
      `pickgroupid` int(10) unsigned NOT NULL auto_increment,
      `pickid` int(10) unsigned default NULL,
      `groupid` int(10) unsigned default NULL,
      PRIMARY KEY  (`pickgroupid`)
    ) ENGINE=MyISAM AUTO_INCREMENT=430 DEFAULT CHARSET=latin1;
    
    --
    -- Dumping data for table `tblpickgroups`
    --
    
    LOCK TABLES `tblpickgroups` WRITE;
    /*!40000 ALTER TABLE `tblpickgroups` DISABLE KEYS */;
    INSERT INTO `tblpickgroups` (`pickgroupid`, `pickid`, `groupid`) VALUES (288,52,17),(287,52,19),(289,53,14),(290,54,17),(291,55,17),(320,56,17),(319,56,18),(306,57,33),(322,58,17),(321,58,18),(302,59,14),(303,59,15),(304,59,16),(305,60,33),(317,61,20),(315,62,18),(310,63,33),(311,64,18),(312,64,17),(313,65,18),(314,65,17),(316,62,17),(318,61,17),(323,66,33),(324,67,14),(325,67,15),(326,68,14),(327,68,15),(328,69,18),(329,69,17),(330,70,18),(331,70,17),(335,71,17),(334,71,18),(336,72,33),(337,73,18),(338,73,17),(381,74,16),(380,74,15),(379,74,14),(384,76,16),(349,75,33),(348,75,16),(383,76,15),(382,76,14),(361,77,16),(360,77,15),(359,77,14),(362,78,14),(363,78,15),(364,78,16),(365,78,33),(371,79,16),(370,79,15),(369,79,14),(372,80,18),(373,80,17),(374,81,33),(375,82,18),(376,82,17),(377,83,18),(378,83,17),(425,84,16),(424,84,15),(423,84,14),(388,85,33),(389,86,14),(390,86,15),(391,86,33),(392,87,26),(393,87,27),(394,87,28),(395,88,18),(396,88,17),(397,89,18),(398,89,17),(399,89,33),(400,90,33),(401,91,19),(402,91,18),(403,91,17),(422,92,17),(421,92,18),(420,93,17),(419,93,18),(418,93,19),(417,94,17),(416,94,18),(415,94,19),(428,95,28),(427,95,27),(426,95,26),(429,96,33);
    /*!40000 ALTER TABLE `tblpickgroups` ENABLE KEYS */;
    UNLOCK TABLES;
    PHP:
    you can see that there is no comma in the code.

    I am lost, been working on this all morning, Might have been easier to just redo them manually.
     
    indeep2k7, Oct 10, 2008 IP
  7. chisara

    chisara Peon

    Messages:
    141
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I got sucked into the , sign as well but when reading back you see that the threadstarter tell us he has a problem with a SELECT statement. He was helpfull enough to give us a sample database dump the problem is not in his dump.

    But since indeep2k7 has a problem with a SELECT statement would you care to give your select statement or if possible the file that produces this error and the url (input parameters) used to create this error. Then we might be able to help you further.

    Cheers,
     
    chisara, Oct 10, 2008 IP
  8. crivion

    crivion Guest

    Best Answers:
    0
    #8
    I've been executed that code and it worked nicely without any problems in my local mysql server

    you must give us the select statement not the insert
    you might find it in your php code
     
    crivion, Oct 10, 2008 IP
  9. indeep2k7

    indeep2k7 Active Member

    Messages:
    700
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #9
    Here is the php

    <?
    session_start();
       require('stts/hit.inc');
    
    include("conn.php");
    include("functions.php");
    
    function getresult($status)
    {
    	$arr=array(0=>"Pending",1=>"Won",2=>"Loss",3=>"Tie");
    	return $arr[$status];
    }
    list($pagetitle,$pagehtml)=getPage("records2.php");
    ?>
    <HTML><HEAD><TITLE><?=$pagetitle?></TITLE>
    <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
    <style>
    <?=$cssstylesheet;?>
    </style>
    <SCRIPT language=JavaScript type=text/JavaScript>
    <!--
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </SCRIPT>
    
    <META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
    <BODY class="mainbody" onLoad="MM_preloadImages('memberbutton1.gif','signbutton1.gif','freebutton1.gif','recordbutton1.gif','servicesbutton1.gif','questionsbutton1.gif')" topmargin="0" leftmargin="0" rightmargin="0">
    <TABLE cellSpacing=0 cellPadding=0 width=780 align=center class="bgcolor" 
    border=0><!--DWLayoutTable-->
      <TBODY>
      <?
      include("top.php");
      ?>
      <TR>
        <TD vAlign=top width=137 height=494>
          <? include("left.php");?></TD>
        <TD vAlign=top width=683 rowSpan=2>
          <table cellspacing=0 cellpadding=14 width="100%" class="maintable" border=0><!--DWLayoutTable-->
            <TBODY>
            <TR>
              <TD vAlign=top width=626 height=229><?=$pagehtml?><br><br>
    		  <table width="80%" cellpadding="0" cellspacing="0"  align="center">
    		<?
    	$strSQL = "select * from tblconfig ";
    	$result=mysql_query($strSQL);
    	$totalrecords=mysql_result($result,0,"totalrecords");
    	
    	$strSQL="select pickid from tblpickgroups where groupid=$groupid";					
    	$strPickIDs=getCommaSeperatedColumn($strSQL,"pickid");	
    					
    						
    	$strSQL = "select * from tblpicks where result<>0 AND ishiderecord=0 AND pickid in ($strPickIDs) order by dateadded desc limit 0,$totalrecords";
    	$result=mysql_query($strSQL);
    	$noresult=mysql_num_rows($result);
    	$win=0;
    	$lose=0;
    	$tie=0;
    	while($row=mysql_fetch_assoc($result))
    	{
    		$win=$row['result']==1?$win+1:$win;
    		$lose=$row['result']==2?$lose+1:$lose;
    		$tie=$row['result']==3?$tie+1:$tie;
    	if($row['team1logo']!="" || $row['team2logo']!="")
    	{
    	?>
    	<tr align="center">
    		<td><? if($row['team1logo']!="") { ?><img src="service_img/<?=$row['team1logo']?>"><? } ?>&nbsp;
    		<? if($row['team2logo']!="") { ?><img src="service_img/<?=$row['team2logo']?>"><? } ?></td>
    	</tr>	
    	<?
    	}
    	?>
    	<tr class="templatebg2">
    		<td class="heading" align="center"><strong><?=$row['team1']?>&nbsp;<?=$row['spread1']?></strong> <?=$row['middletext']?> <strong><?=$row['team2']?>&nbsp;<?=$row['spread2']?></strong></td>
    	</tr>	
    	<tr>
    		<td ><?=$row['isteam1']==1?$row['team1']:""?>&nbsp;<?=$row['isspread1']==1?$row['spread1']:""?></td>
    	</tr>
    	<tr>
    		<td ><?=$row['isteam2']==1?$row['team2']:""?>&nbsp;<?=$row['isspread2']==1?$row['spread2']:""?></td>
    	</tr>
    	<?
    	if($row['isoverunder']==1)
    	{
    	?>
    	<tr>
    		<td >Over/Under:&nbsp;<?=$row['overunder']?></td>
    	</tr>
    	<?
    	}
    	if($row['isdateadded']==1)
    	{
    	?>
    	<tr>
    		<td >Event Date:&nbsp;<?=date("m/d/Y",strtotime($row['dateadded'],date("Y-m-d")))?></td>
    	</tr>
    	<?
    	}
    	if($row['ishidetime']==0)
    	{
    	?>
    	<tr>
    		<td >Event Time:&nbsp;<?=$row['eventhour']."&nbsp;".$row['eventdn']."&nbsp;".$row['eventesppst']?></td>
    	</tr>
    	<?
    	}
    	if($row['isplay']==1)
    	{
    	?>
    	<tr>
    		<td >Play:&nbsp;<?=$row['play']?></td>
    	</tr>
    	<?
    	}
    	if($row['isscore']==1)
    	{
    	?>
    	<tr>
    		<td >Score:&nbsp;<?=$row['score']?></td>
    	</tr>
    	<?
    	}
    	if($row['iscomments']==1)
    	{
    	?>
    	<tr>
    		<td >Comments:&nbsp;<?=$row['comments']?></td>
    	</tr>
    	<?
    	}
    	if($row['isresult']==1)
    	{
    	?>
    	<tr>
    		<td >Result:&nbsp;<strong><?=getresult($row['result'])?></strong></td>
    	</tr>	
    	<?
    	}
    	}
    	?>
    	</table>
    	<?
    	if($noresult==0)
    		echo "<center>There are no records available!<center><br>";
    	else
    		echo "<hr><div align=center>Win:<strong>$win</strong> Losses:<strong>$lose</strong> Tie:<strong>$tie</strong></div>";
    	?>
    	
    		  </TD></TR>
    		  <? include("bottom.php");?>
    		  </TBODY></TABLE></TD>
        <TD vAlign=top width=136 rowSpan=3>
          <? include("right.php");?></TD></TR>
      <TR>
        <TD height=1></TD></TR>
      <TR>
        <TD height=2></TD>
        <TD></TD></TR>
    	</TBODY></TABLE></BODY></HTML>
    
    PHP:
     
    indeep2k7, Oct 11, 2008 IP
  10. crivion

    crivion Guest

    Best Answers:
    0
    #10
    you must have (') like below
    $strSQL="select pickid from tblpickgroups where groupid= '$groupid'";

    indiferent if you have a string or an integer
     
    crivion, Oct 11, 2008 IP