Re: SQL syntax?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2008-12-05 at 16:51 -0600, Terion Miller wrote:
> Excellent Allan thanks so much, sometimes I think php is causing me
> blindness!!
> Terion
> 
> On Fri, Dec 5, 2008 at 4:26 PM, Allan Arguelles <allan@xxxxxxxxxxxxxxxx>wrote:
> 
> >  Try this:
> >
> >  $sql = "SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
> > %e, %Y %l:%i %p') AS Start_Date,
> >     DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ";
> >     $sql .= "Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
> > Impressions AS Ad_Impressions, ";
> >     $sql .= "AdSize AS Ad_Size, CPM AS CPM_Rate ";
> >     $sql.= "FROM workorderform ";
> >     $sql .= " WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC";
> >
> >
> > I just removed extra commas from CPM_Rate and workorderform
> >
> >
> > Terion Miller wrote:
> >
> > ah...I also though it was because I didn't have a statement like where
> > adsize = adsize or something but I tried that and got the same error I have
> > been getting ...
> >
> > 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 'FROM
> > workorderform, WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC' at
> > line 2
> >
> > and why does it keep saying line 2...
> > here is the snippet as it is now:
> >
> >  $sql = "SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
> > %e, %Y %l:%i %p') AS Start_Date,
> >     DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ";
> >     $sql .= "Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
> > Impressions AS Ad_Impressions, ";
> >     $sql .= "AdSize AS Ad_Size, CPM AS CPM_Rate, ";
> >     $sql.= "FROM workorderform, ";
> >     $sql .= " WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC";
> >
> >
> > On Fri, Dec 5, 2008 at 4:14 PM, Allan Arguelles <allan@xxxxxxxxxxxxxxxx> <allan@xxxxxxxxxxxxxxxx>wrote:
> >
> >
> >
> >   Umm.. I meant you need to put
> >
> > $sql .= "FROM workorderform ";
> >
> > between these:
> >
> > $sql .= "AdSize AS Ad_Size,  CPM AS CPM_Rate, ";
> > $sql .= "ORDER BY StartDate DESC";
> >
> >
> > :)
> >
> >
> > Terion Miller wrote:
> >
> > On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles <allan@xxxxxxxxxxxxxxxx> <allan@xxxxxxxxxxxxxxxx> <allan@xxxxxxxxxxxxxxxx> <allan@xxxxxxxxxxxxxxxx>wrote:
> >
> >
> >
> >      $sql = "SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate,
> >
> >
> >  '%b.
> >
> >
> >  %e, %Y %l:%i %p') AS Start_Date,
> >     DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ";
> >     $sql .= "Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
> > Impressions AS Ad_Impressions, ";
> >     $sql .= "AdSize AS Ad_Size,  CPM AS CPM_Rate, ";
> >     $sql .= "ORDER BY StartDate DESC";
> >
> >
> >
> >  You forgot the tables, plus you have an extra comma after CPM_Rate.
> >
> > well I changed it to:
> >
> >  $sql = "SELECT workorderform.WorkOrderID AS Work_Order_ID,
> > DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date,
> >     DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date,
> > ";
> >     $sql .= "workorderform.Advertiser AS
> > Advertiser_Name,workorderform.AccountNum AS Account_Number,
> > workorderform.Impressions AS Ad_Impressions, ";
> >     $sql .= "workorderform.AdSize AS Ad_Size,  workorderform.CPM AS
> > CPM_Rate ";
> >     $sql .= "ORDER BY StartDate DESC";
> >
> > and got the same error....
> >
> >
If I run into troubles with SQL (specifically MySQL) I run the query in
phpMyAdmin, which is so helpful. If you're using another SQL variant
like that god-forsaken M$ SQL, then you have to use the appropriate tool
to interface with the database there. It sure helps remove the SQL
problems from PHP, which was your problem in this case.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux