Jump to content

how to view php output?


CyberShot

Recommended Posts

I am working with wordpress. I am using a chunk of code to get the category id's of 2 categories. when I do that, it outputs 1 and 5 which is correct. I then use that to change the query for the database so that it will exclude those categories. But for some reason the code is failing. I can't see why. Is there a way to see what php is generating? Like when you click view source from a web page. Is there a view source for php? This is the code

 

//getting the option tree results
$options = get_option('option_tree');

//looping through my key to get the values, this returns 1 and 5
foreach($options['exc_cat'] as $cat) {

//concatenating my values into one string. I want the string to be -1,-5
$string .= '-' .$cat.",";
}

//trimming the trailing comma from the string, otherwise I would end up with -1,-5,
$string = substr($string, 0, -1); // Delete the last character

query_posts($query_string . '&cat=' . $string); //this is the line that I need to see exactly what it is sending to the database.

Link to comment
https://forums.phpfreaks.com/topic/233172-how-to-view-php-output/
Share on other sites

The code should put out something like this

 

 

query_posts($query_string . '&cat=-1,-5');

 

the line above should be making 5 posts I have on my page disappear, but they are still there. I have gone through the codex for two days now and everything in the documentation says that my code above should work. So I am thinking now that there is a missing ' at the end of the string. But I can't seem to make it work. So I thought that there was a way to view the output. I am trying to echo it right now to see but it looks good. I get -1,-5. I just need to make sure that the quotes are right and I can't see that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.