PHP Web Host - Quality Web Hosting For All PHP Applications $35/month $250/year (Unlimited) - $25/month - 200,000 impressions - Your Ad Could be Here - Click For Details
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
pezzer
New Member
New Member


Joined: Nov 28, 2007
Posts: 10

PostPosted: Tue Apr 01, 2008 3:27 pm Reply with quote Back to top

Something like this is surely already mentioned somewhere here, but I can't find it, so...

I'm trying to exclude a specific category (and possible multiple categories) from the "Last 5 Articles" block. I tried to modify the sql query with no luck. I looked at other examples of WHERE statements, but I can't seem to make this one work as those are listed.
Here is the original line in the "block-Last_5_Articles.php" file.

Code:
$sql = 'SELECT sid, title, comments, counter FROM '.$prefix.'_stories '.$querylang.' ORDER BY sid DESC LIMIT 0,5';


I modified it to this:

Code:
$sql = 'SELECT sid, catid, title, comments, counter FROM '.$prefix.'_stories '.$querylang.' WHERE 'catid' !='4' ORDER BY sid DESC LIMIT 0,5';


I tried a few variations as well as trying to add escape characters in front of the ' but nothing worked. Something I didn't try because I don't quite understand it is to turn catid into $catid and do something with that.

Do I need to globally define catid and/or turn it into $catid?

Does anyone have any thoughts on how to make this work?
View user's profile Send private message
Gremmie
Former Moderator in Good Standing


Joined: Apr 06, 2006
Posts: 2401
Location: Iowa, USA

PostPosted: Tue Apr 01, 2008 5:30 pm Reply with quote Back to top

Looks like you got your quotes messed up. Try this:

Code:

$sql = 'SELECT sid, catid, title, comments, counter FROM '.$prefix.'_stories '.$querylang.' WHERE catid != 4 ORDER BY sid DESC LIMIT 0,5';


This will probably fail if you have the $multilingual set to 1 also, because $querylang will already contain a WHERE clause. But if you don't, it should work.
View user's profile Send private message
pezzer
New Member
New Member


Joined: Nov 28, 2007
Posts: 10

PostPosted: Tue Apr 01, 2008 6:40 pm Reply with quote Back to top

Excellent. That worked perfectly. I think leaving the quotes off would have been the last thing I tried (and by far the simplest.)

Thank you - That will help tremendously...

So in 6 months or 2 years if I upgrade to a multilingual site, I am NEVER going to understand why my site is suddenly failing. I better leave myself a note right now. Very Happy
View user's profile Send private message
gregexp
The Mouse Is Extension Of Arm


Joined: Feb 21, 2006
Posts: 1472
Location: In front of a screen....HELP! lol

PostPosted: Tue Apr 01, 2008 6:57 pm Reply with quote Back to top

just remember this, this is how I think of quotes:
$var2='second part of string';
$var='part of string'.$var2.'third part of string';

The dots tell it to add it to the string, I think of it as different parts, first quote begines the quote, the next quote ends it. So to tell php not to take it literally, we backslash it, If I wrote:

$var='don\'t walk the dog today';

The second quote, which is backslashed, isnt the end of the first part, the backslash tells php not to take it literally, but that it is actually a part of the
string.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2008 by Raven
Proud to be listed at Lobo Links Web Directory

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::

:: fisubice Theme Recoded To 100% W3C CSS & HTML 4.01 Transitional Compliance by Raven and 64bitguy ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum