Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Getting Error for PHP...need help (https://www.warriorforum.com/programming/274995-getting-error-php-need-help.html)

keyconcepts 19th October 2010 12:37 PM

Getting Error for PHP...need help
 
Hi. I am getting an error on a line of php coding. I do not know what is wrong with it.

Can someone tell me how to fix this?

86: elseif ( is_category() ): http://www.meandeviation.com/tutoria...ht-red-tri.gif 87: echo '<meta name="description" content="'.category_description(get_category_by_slug('category-slug')->term_id).'" />'; http://www.meandeviation.com/tutoria...icon/invis.gif 88: endif; http://www.meandeviation.com/tutoria...icon/invis.gif 89: ?>

Line 87 is the one with the error.

THanks.

theIMgeek 19th October 2010 12:49 PM

Re: Getting Error for PHP...need help
 
Can you tell us what the error message is?

It may be something inside the category_description() or get_category_by_slug() functions... and the error message will hopefully point you to a line number inside that code.

-Ryan

keyconcepts 19th October 2010 01:31 PM

Re: Getting Error for PHP...need help
 
Yes...
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/content/l/a/s/las1277/html/MRC/wp-content/themes/refined/seo.php on line 87

Line 87, as I mentioned previously. Sorry, I meant to tell you what the actual error was.

theIMgeek 19th October 2010 01:52 PM

Re: Getting Error for PHP...need help
 
<font color="black">Alright, so it seems to be taking issue with the format of this bit:

PHP Code:

get_category_by_slug('category-slug')->term_id 

If you have not modified this code, it may be that your web host server is running PHP 4.x when this code needs PHP 5.x.

If that's the case, I wonder if a re-format might solve it...

elseif ( is_category() ):
$my_cat_id = get_category_by_slug('category-slug');
echo '<meta name="description" content="'.category_description($my_cat_id->term_id).'" />';
endif;


Maybe!

Or... second thought... it seems odd that it's asking for the id of a category called "category-slug"... you'd think that would be a variable in there.

-Ryan

phpbbxpert 19th October 2010 02:01 PM

Re: Getting Error for PHP...need help
 
Could you paste 10 lines before and after line 87 in a paste
Pastebin.com - #1 paste tool since 2002! and link it in a post here

Don't add any comments or anything to it, just the code so I can see what is going on.

caesargus 19th October 2010 02:45 PM

Re: Getting Error for PHP...need help
 
This would be my guess - wrong server version.

A quick way you can tell what version you are using is to create a page with <? phpinfo(); ?> and run the page in your web browser.

If you are running version 5 or greater then we may need more clues as to Is wrong (surrounding code and what not)

SmartWeb 19th October 2010 07:19 PM

Re: Getting Error for PHP...need help
 
Quote:

Originally Posted by keyconcepts (Post 2746416)
Hi. I am getting an error on a line of php coding. I do not know what is wrong with it.

Can someone tell me how to fix this?

86: elseif ( is_category() ): http://www.meandeviation.com/tutoria...ht-red-tri.gif 87: echo '<meta name="description" content="'.category_description(get_category_by_slug('category-slug')->term_id).'" />'; http://www.meandeviation.com/tutoria...icon/invis.gif 88: endif; http://www.meandeviation.com/tutoria...icon/invis.gif 89: ?>

Line 87 is the one with the error.

THanks.

Why is this ":" there at the end of your line 86 ? If this is present in your php code, then remove it. this seems to be the reason.

caesargus 19th October 2010 10:26 PM

Re: Getting Error for PHP...need help
 
Quote:

Originally Posted by SmartWeb (Post 2747907)
Why is this ":" there at the end of your line 86 ? If this is present in your php code, then remove it. this seems to be the reason.

The ":" is at the end of the line because that is valid syntax for PHP. It is an older style of creating if statements. The first time I saw that I had the same reaction.


All times are GMT -6. The time now is 06:30 AM.