Re: Strange Query Error...

Re: Strange Query Error...

am 27.11.2010 19:08:20 von daniel.brown

On Sat, Nov 27, 2010 at 12:30, Don Wieland wrote:
> Hi gang,
>
> I am executing a query via PHP that gives me a PHP 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 'AND
> m.`Preferred_First_Name` LIKE 'Don' AND m.`Preferred_Last_Name` LIKE
> 'Wielan' at line 1
>
> but when I copy the ECHO of the select query and run it in Sequel Pro Query,
> it returns no error.
>
> Here is the query:
>
> select m.* from Members m inner join Member_Years my on m.aucciim_id =
> my.member_id where now() < DATE_ADD(DATE_SUB(concat(`member_year` +
> 1,'-07-01'), INTERVAL 1 DAY), INTERVAL 30 DAY) AND m.`Preferred_First_Name`
> LIKE 'Don' AND m.`Preferred_Last_Name` LIKE 'Wieland' group by m.AUCCIIM_ID
> order by m.preferred_last_name
>
> What is causing it to choke via PHP?

This is actually better-suited to the DB list (CC'd) than the
General list, but one primary question: are you using the mysql_*
family, mysqli_* family, or another method of interfacing with MySQL?

--

Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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

Re: Strange Query Error...

am 27.11.2010 19:19:37 von Don Wieland

On Nov 27, 2010, at 10:08 AM, Daniel P. Brown wrote:

> one primary question: are you using the mysql_*
> family, mysqli_* family, or another method of interfacing with MySQL?

mysql_

$results = mysql_query($query) or die(mysql_error());

Don

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

Re: Re: [PHP] Strange Query Error...

am 27.11.2010 19:39:58 von Niel Archer

> On Nov 27, 2010, at 10:08 AM, Daniel P. Brown wrote:
>
> > one primary question: are you using the mysql_*
> > family, mysqli_* family, or another method of interfacing with MySQL?
>
> mysql_
>
> $results = mysql_query($query) or die(mysql_error());
>
> Don
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
Could you show the actual code, not just the query. The way you are
setting up the query could be affecting it. i.e. using single quotes when
assigning to a variable would not work with your query.

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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