Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 08-24-2011, 02:36 PM   #1
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
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;
?>
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 02:39 PM   #2
Klen
 
Klen's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
Maybe you puted code to wrong wordpress file ?
Klen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 02:41 PM   #3
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
Join Date: Jan 2002
Location: Holland
Posts: 9,870
is get_option(‘posts_per_page’) defined?
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 02:46 PM   #4
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
Hell if I know. These are the instructions I followed.

http://blog.dembowski.net/2007/08/02/numbered-titles/
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 02:47 PM   #5
harvey
Confirmed User
 
harvey's Avatar
 
Industry Role:
Join Date: Jul 2001
Location: 127.0.0.1
Posts: 9,266
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
__________________
This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth
harvey is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 03:18 PM   #6
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
wrong quotes, use single quotes -> '
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 03:23 PM   #7
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
Quote:
Originally Posted by harvey View Post
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.
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 03:25 PM   #8
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Please don't listen to harvey, pete or woj. What you need here is to replace the ` backtick with a single quote character.


lol
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 03:26 PM   #9
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
Quote:
Originally Posted by Brujah View Post
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
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

Last edited by woj; 08-24-2011 at 03:28 PM..
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 03:31 PM   #10
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Quote:
Originally Posted by BCyber View Post
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
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 03:43 PM   #11
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,405
Aldo 0 * something can generate an error...
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 04:05 PM   #12
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
Nothing seems to work
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 04:07 PM   #13
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Quote:
Originally Posted by BCyber View Post
Nothing seems to work
It's probably something else. Paste the lines before and after that, and or the exact error message.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 04:26 PM   #14
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
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; ?>
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 04:36 PM   #15
harvey
Confirmed User
 
harvey's Avatar
 
Industry Role:
Join Date: Jul 2001
Location: 127.0.0.1
Posts: 9,266
Quote:
Originally Posted by BCyber View Post
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
__________________
This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth
harvey is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 04:40 PM   #16
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
The minus character is not a minus character in this:
($paged – 1)

Fix that and you should be good.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 04:41 PM   #17
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Quote:
Originally Posted by harvey View Post
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
I think the copy+paste just does that for a lot of people who copy code from blogs.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 04:49 PM   #18
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
Quote:
Originally Posted by Brujah View Post
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
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 04:55 PM   #19
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Quote:
Originally Posted by BCyber View Post
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;
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 04:58 PM   #20
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
Quote:
Originally Posted by Brujah View Post
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!
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 05:02 PM   #21
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
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.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 05:24 PM   #22
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
Alright thanks.
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 05:39 PM   #23
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,320
that sure is messy code ;)
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-24-2011, 05:43 PM   #24
BSleazy
Confirmed User
 
Industry Role:
Join Date: Aug 2002
Location: USA
Posts: 6,721
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.
__________________
icq 156131086
BSleazy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.