Parse error

Parse error

am 24.09.2009 04:58:09 von Ron Piggott

The following code gives me this error message:

Parse error: syntax error, unexpected ':'
in /home/thev4173/public_html/test.php on line 8

It is referencing the : that follows EasterDate (and will eventually get
mad at ChristmasDate)


mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

IF(CURDATE() >= DATE_SUB(CONCAT(@EasterDate :=
DATE(FROM_UNIXTIME(easter_date(date('Y'))), INTERVAL LEAST(14, (SELECT
COUNT(*) FROM `verse_of_the_day_Bible_verses` WHERE seasonal_use = 1))
DAYS) AND CURDATE() <= @EasterDate, 1, 0)

IF(CURDATE() >= DATE_SUB(CONCAT(@ChristmasDate := YEAR(CURDATE()),
'-12-25'), INTERVAL LEAST(14, (SELECT COUNT(*) FROM
`verse_of_the_day_Bible_verses` WHERE seasonal_use = 2)) DAYS) AND
CURDATE() <= @ChristmasDate, 2, 0)

mysql_close();



What is the problem?

And what is the variable that has the value of 0, 1 or 2?

Ron


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

Re: Parse error

am 24.09.2009 05:20:55 von dmagick

Ron Piggott wrote:
> The following code gives me this error message:
>
> Parse error: syntax error, unexpected ':'
> in /home/thev4173/public_html/test.php on line 8
>
> It is referencing the : that follows EasterDate (and will eventually get
> mad at ChristmasDate)
>
>
> mysql_connect('localhost',$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
>
> IF(CURDATE() >= DATE_SUB(CONCAT(@EasterDate :=
> DATE(FROM_UNIXTIME(easter_date(date('Y'))), INTERVAL LEAST(14, (SELECT
> COUNT(*) FROM `verse_of_the_day_Bible_verses` WHERE seasonal_use = 1))
> DAYS) AND CURDATE() <= @EasterDate, 1, 0)
>
> IF(CURDATE() >= DATE_SUB(CONCAT(@ChristmasDate := YEAR(CURDATE()),
> '-12-25'), INTERVAL LEAST(14, (SELECT COUNT(*) FROM
> `verse_of_the_day_Bible_verses` WHERE seasonal_use = 2)) DAYS) AND
> CURDATE() <= @ChristmasDate, 2, 0)
>
> mysql_close();
>
>
>
> What is the problem?

If this is your actual code, the queries aren't in php variables.

$query = "IF(curdate() .... ";

--
Postgresql & php tutorials
http://www.designmagick.com/


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

Re: Parse error

am 24.09.2009 06:03:01 von dmagick

Ron Piggott wrote:
> This is the actual code. What should I have?

Same as when you do a query normally.

$query = "SELECT ... WHERE ....";

$result = mysql_query($query);

......

> On Thu, 2009-09-24 at 13:20 +1000, Chris wrote:
>> Ron Piggott wrote:
>>> The following code gives me this error message:
>>>
>>> Parse error: syntax error, unexpected ':'
>>> in /home/thev4173/public_html/test.php on line 8
>>>
>>> It is referencing the : that follows EasterDate (and will eventually get
>>> mad at ChristmasDate)
>>>
>>>
>>> mysql_connect('localhost',$username,$password);
>>> @mysql_select_db($database) or die( "Unable to select database");
>>>
>>> IF(CURDATE() >= DATE_SUB(CONCAT(@EasterDate :=
>>> DATE(FROM_UNIXTIME(easter_date(date('Y'))), INTERVAL LEAST(14, (SELECT
>>> COUNT(*) FROM `verse_of_the_day_Bible_verses` WHERE seasonal_use = 1))
>>> DAYS) AND CURDATE() <= @EasterDate, 1, 0)
>>>
>>> IF(CURDATE() >= DATE_SUB(CONCAT(@ChristmasDate := YEAR(CURDATE()),
>>> '-12-25'), INTERVAL LEAST(14, (SELECT COUNT(*) FROM
>>> `verse_of_the_day_Bible_verses` WHERE seasonal_use = 2)) DAYS) AND
>>> CURDATE() <= @ChristmasDate, 2, 0)
>>>
>>> mysql_close();
>>>
>>>
>>>
>>> What is the problem?
>> If this is your actual code, the queries aren't in php variables.
>>
>> $query = "IF(curdate() .... ";
>>
>
>


--
Postgresql & php tutorials
http://www.designmagick.com/


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

Re: Parse error

am 24.09.2009 07:39:59 von dmagick

Ron Piggott wrote:
> Let me try this is a different way.
>
> What is the variable which I am able to retrieve? I am expecting the
> result to be a 0, 1 or 2.

Your original problem was getting a parse error.

Your query is not php code - step 1 is to fix that.

Once you've done that, post the new code and new problem you're having.

--
Postgresql & php tutorials
http://www.designmagick.com/


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

Re: Parse error

am 24.09.2009 09:17:15 von Ron Piggott

There are further problems with the mySQL query:

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
CURDATE() <= DATE(FROM_UNIXTIME(1239508800)), 1, 0), IF(CURDATE() >=
DATE'

This is the whole query, what am I missing / doing wrong?

SELECT GREATEST( IF(CURDATE() >=
DATE_SUB(CONCAT(DATE(FROM_UNIXTIME(1239508800)), INTERVAL LEAST(14,
(SELECT COUNT(*) FROM `verse_of_the_day_Bible_verses` WHERE seasonal_use
= 1)) DAY) AND CURDATE() <= DATE(FROM_UNIXTIME(1239508800)), 1, 0),
IF(CURDATE() >= DATE_SUB(CONCAT(YEAR(CURDATE()), '-12-25'), INTERVAL
LEAST(14, (SELECT COUNT(*) FROM `verse_of_the_day_Bible_verses` WHERE
seasonal_use = 2)) DAY) AND CURDATE() <= YEAR(CURDATE()), '-12-25'), 2,
0) ) AS verse_application


On Thu, 2009-09-24 at 15:39 +1000, Chris wrote:
> Ron Piggott wrote:
> > Let me try this is a different way.
> >
> > What is the variable which I am able to retrieve? I am expecting the
> > result to be a 0, 1 or 2.
>
> Your original problem was getting a parse error.
>
> Your query is not php code - step 1 is to fix that.
>
> Once you've done that, post the new code and new problem you're having.
>


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