Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-06-26 13:20:17

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,659
GitHub Twitter

Something is wrong...

Someone can help me with this request? :

$cat = gps(c);
$now = date('Y-m-d H:i:s');
// extract categories from published articles where date < now
$test = safe_rows('Posted, Category1, Category2, Status', 'textpattern', 'Status = "4" and (Posted < "'.$now.'" and Category1 = "'.$cat.'" or Category2 = "'.$cat.'")');

which retrieves nothing (note that some articles are published in the future)

Very obligingly

Last edited by Pat64 (2011-06-26 13:24:40)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#2 2011-06-26 13:39:47

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Something is wrong...

If you put the site in debug mode, does the resulting MySQL query (which is visible in the HTML source in debug mode) look correct?

Btw, your code is vulnerable to SQL injection, the () grouping is probably not what you want and the date stuff can be done completely in SQL:

$cat = doSlash(gps('c'));
$test = safe_rows('Posted, Category1, Category2, Status', 'textpattern', 'Status = "4" and Posted < NOW() and (Category1 = "'.$cat.'" or Category2 = "'.$cat.'")');

Last edited by ruud (2011-06-26 17:15:55)

Offline

#3 2011-06-26 13:48:38

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Something is wrong...

In addition to what Ruud said, if the c isn’t actually a constant, surround it with quotes, ie. $cat = doSlash(gps('c'));.

Offline

#4 2011-06-26 15:10:57

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,659
GitHub Twitter

Re: Something is wrong...

Ruud & Gocom : Nope

I’m very sorry but it’s seems don’t work as espected. Try it here (your code added) : http://txp-fr.net/?c=css#cat-lister

All categories except “Hack” one got articles. Blank category list correspond to articles post in past (article list had to show here). Only “Thème” cat display a message to say there is nothing (for the moment).

I apologize for my demand, but it could be work.

Lot of Tks

Last edited by Pat64 (2011-06-26 15:17:52)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#5 2011-06-26 16:04:48

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,659
GitHub Twitter

Re: Something is wrong...

Ruud @ Gocom: you are the best :)

Works fine. Just adapted my default empty cat message.

Tanks lot again. YOU ARE REALY BEST.


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB