GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Question (https://gfy.com/showthread.php?t=1035481)

BSleazy 08-24-2011 02:36 PM

PHP Question
 
I'm trying to use some code I found to add numbers next to post titles in wordpress. I'm getting a unexpected t string error when using it. Any idea what the problem is?

Code:

<?php if ( $paged < 2 ) {
$my_paged = 0;
} else {
$my_paged = ($paged ? 1) * get_option(?posts_per_page?);        <---this is the line thats causing the error it says.
}
$count = 1;
?>


Klen 08-24-2011 02:39 PM

Maybe you puted code to wrong wordpress file ?

grumpy 08-24-2011 02:41 PM

is get_option(‘posts_per_page’) defined?

BSleazy 08-24-2011 02:46 PM

Hell if I know. These are the instructions I followed.

http://blog.dembowski.net/2007/08/02/numbered-titles/

harvey 08-24-2011 02:47 PM

try replacing this
Code:

$my_paged = ($paged ? 1) * get_option(?posts_per_page?);        <---this is the line thats
with this:

Code:

$my_paged = ($paged ? 1) * get_option('posts_per_page');        <---this is the line thats

woj 08-24-2011 03:18 PM

wrong quotes, use single quotes -> '

BSleazy 08-24-2011 03:23 PM

Quote:

Originally Posted by harvey (Post 18377970)
try replacing this
Code:

$my_paged = ($paged ? 1) * get_option(?posts_per_page?);        <---this is the line thats
with this:

Code:

$my_paged = ($paged ? 1) * get_option('posts_per_page');        <---this is the line thats

I'm still getting the same error on the same line.

Brujah 08-24-2011 03:25 PM

Please don't listen to harvey, pete or woj. What you need here is to replace the ` backtick with a single quote character.


lol

woj 08-24-2011 03:26 PM

Quote:

Originally Posted by Brujah (Post 18378062)
Please don't listen to harvey, pete or woj. What you need here is to replace the ` backtick with a single quote character.


lol

hey now, that's exactly what I said :1orglaugh :(

Brujah 08-24-2011 03:31 PM

Quote:

Originally Posted by BCyber (Post 18378055)
I'm still getting the same error on the same line.

It must be something else then. Try: get_option( "posts_per_page" )
just to compare

V_RocKs 08-24-2011 03:43 PM

Aldo 0 * something can generate an error...

BSleazy 08-24-2011 04:05 PM

Nothing seems to work :)

Brujah 08-24-2011 04:07 PM

Quote:

Originally Posted by BCyber (Post 18378150)
Nothing seems to work :)

It's probably something else. Paste the lines before and after that, and or the exact error message.

BSleazy 08-24-2011 04:26 PM

I've moved it around which doesn't seem to help either.

Parse error: syntax error, unexpected T_STRING in *****/index.php on line 43

Code:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php $key="featured_external"; $custom = get_post_meta($post->ID, $key, true); ?>

<?php if ( $paged < 2 ) {
$my_paged = 0;
} else {
$my_paged = ($paged ? 1) * get_option('posts_per_page');
}
$count = 1;
?>
<div class="site clearfix" id="rgmevlsotukficza6158">

<a href="<?php $key="featured_external"; echo get_post_meta($post->ID, $key, true); ?>"title="<?php the_title(); ?>">
<?php if ( has_post_thumbnail()) the_post_thumbnail('featured-thumb', array('class' => 'thumb')); ?>
</a>

<a target="_blank" href="http://www.link-paysite.com" class="join-link">Visit Paysite # 01 NOW !</a>
<h1><?php echo $my_paged + $count . ?. ?; ?> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<p><?php the_content(''); ?></p>
<a target="_blank" href="http://www.link.com" class="tour" id="ukplowdzgxbhtncyeqf7410">Free Preview</a>
<p class="clear"></p>
</div>
<?php $count = $count + 1; ?>
<?php endwhile; endif; ?>


harvey 08-24-2011 04:36 PM

Quote:

Originally Posted by BCyber (Post 18378187)
I've moved it around which doesn't seem to help either.

Parse error: syntax error, unexpected T_STRING in *****/index.php on line 43

Code:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php $key="featured_external"; $custom = get_post_meta($post->ID, $key, true); ?>

<?php if ( $paged < 2 ) {
$my_paged = 0;
} else {
$my_paged = ($paged ? 1) * get_option('posts_per_page');
}
$count = 1;
?>
<div class="site clearfix" id="rgmevlsotukficza6158">

<a href="<?php $key="featured_external"; echo get_post_meta($post->ID, $key, true); ?>"title="<?php the_title(); ?>">
<?php if ( has_post_thumbnail()) the_post_thumbnail('featured-thumb', array('class' => 'thumb')); ?>
</a>

<a target="_blank" href="http://www.link-paysite.com" class="join-link">Visit Paysite # 01 NOW !</a>
<h1><?php echo $my_paged + $count . ?. ?; ?> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<p><?php the_content(''); ?></p>
<a target="_blank" href="http://www.link.com" class="tour" id="ukplowdzgxbhtncyeqf7410">Free Preview</a>
<p class="clear"></p>
</div>
<?php $count = $count + 1; ?>
<?php endwhile; endif; ?>


well, the code is pretty much a mess and it has several things to fix, but related to this function, I'd say your problem is in the formatting AGAIN. Just replace those ?. ?; with ". "; and see if it solves the issue. Also, I don't know why you need those strange id or 2 different clears or class + id for the same element, just clean things up and it will be a lot easier for you to locate errors :2 cents:

Brujah 08-24-2011 04:40 PM

The minus character is not a minus character in this:
($paged – 1)

Fix that and you should be good.

Brujah 08-24-2011 04:41 PM

Quote:

Originally Posted by harvey (Post 18378215)
well, the code is pretty much a mess and it has several things to fix, but related to this function, I'd say your problem is in the formatting AGAIN. Just replace those ?. ?; with ". "; and see if it solves the issue. Also, I don't know why you need those strange id or 2 different clears or class + id for the same element, just clean things up and it will be a lot easier for you to locate errors :2 cents:

I think the copy+paste just does that for a lot of people who copy code from blogs.

BSleazy 08-24-2011 04:49 PM

Quote:

Originally Posted by Brujah (Post 18378232)
The minus character is not a minus character in this:
($paged ? 1)

Fix that and you should be good.

Cool. It had to be ( $paged ? 1 )

That removed the error but fuckin a now it just shows the number 1 next to every post. This is annoying :)

Brujah 08-24-2011 04:55 PM

Quote:

Originally Posted by BCyber (Post 18378248)
Cool. It had to be ( $paged ? 1 )

That removed the error but fuckin a now it just shows the number 1 next to every post. This is annoying :)

You keep resetting $count = 1; at the top of the loop.
change $count = 1; to this
if ( ! isset( $count ) ) $count = 1;

BSleazy 08-24-2011 04:58 PM

Quote:

Originally Posted by Brujah (Post 18378262)
You keep resetting $count = 1; at the top of the loop.
change $count = 1; to this
if ( ! isset( $count ) ) $count = 1;

Alright I just pulled it back out of the loop and it's working right now. Thanks for all the help guys!

Brujah 08-24-2011 05:02 PM

when you see code on a blog like that
http://blog.dembowski.net/2007/08/02/numbered-titles/

Mouseover the code snippet, and look at the icons. mouseover each of those and select either the view source, or copy to clipboard. That'd fix the errors introduced by trying to copy/paste the code from the blog formatting.

BSleazy 08-24-2011 05:24 PM

Alright thanks.

fris 08-24-2011 05:39 PM

that sure is messy code ;)

BSleazy 08-24-2011 05:43 PM

It's from a template I'm changing to a wordpress theme. I haven't edited the html yet. I know there's a bunch of unneeded crap in there. As far as the php goes...I'm not a programmer but it works.


All times are GMT -7. The time now is 12:53 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123