Jump to content

Novice@PHP

Members
  • Posts

    39
  • Joined

  • Last visited

Posts posted by Novice@PHP

  1. It's quite simple, actually.

     

    You need a script that writes the article title and user ID to the database, after setting a unique index on the title. If the query fails, you need to check why it failed. If it was because of an already existing title, then you tell the user that the title is already taken.

    For any other reason, give the user a message telling him that there was some other error, and log it for yourself. (Remember to log it to someone you check often.)

     

    That's part 1, for part 2 you just check if the user ID for the title is the same as the user ID that's saved to the title in the DB. If they aren't, then the user does not have the proper access to write/edit it.

     

    The last part is even simpler, and basic database interaction stuff. I suggest that you start with a basic PHP & MySQL tutorial, to get to grips with the basics. Then sit down and plan the specifics, and then I'm talking about the specifics, of your application. Once you've got it all down in a simple step-by-step list, and feel confident that you've solved all of the logic, then it's time to actually write the code.

     

    Wew I don't want to build it. No time for that.

     

    I guess something already exists, I just don't know what to look for.

     

    Thanks for the detailed reply though.

  2. I have a website but managing writers is HARD.

     

    I need a project management script that assigns articles to a list, that the writers then claim from and submit.

     

    I have no idea what kind of script I'm looking for. Quick process:

     

    1. Add a bunch of article titles across a number of categories.

    2. Registered writers can claim which titles they want to write but are only allowed to claim in their own topic.

    3. Writers write articles, mark as done and submit for review.

     

    No idea what to look for but any help hugely appreciated.

     

    Thanks.

  3. I'm moving this to third party apps.

     

    Did you write the get_posts function? I assume not, that sounds like a basic WP function.

    You probably just want to pass it the array, not a string of php code trying to echo an array. Which wouldn't even be valid PHP anyway.

     

    I'm trying to put the value of the custom field into the array 'include' which is a series of post IDs. The biggest issue is I didn't make all of the query, just some of it. The Post IDs part I made but need those IDs to be passed from a custom field.

     

    Thanks for your help, hopefully someone can help.

     

    Other than that is there somewhere where I can pay for quick help with small snippets like this? I don't like to be a vampire.

  4. The query above queries posts on a page that already has a post. It's basically a query to query posts inside posts.

     

    So I need to pass the post IDS into the include array using custom fields. But No idea how to do it other than what I've got below.

     

    Thanks

     

    <?php
    /*
    Template Name Posts: List More Posts
    */
    ?>
    <?php get_header(); ?>
    
    <!-- BEGIN COL LEFT -->
    <div id="colLeft">
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="postItem">
    
    <!-- google_ad_section_start -->
    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    <div class="categs"><?php the_category(', ') ?></div>
    <div class="meta">
    <div>Last Edited: <?php the_time('M j, Y') ?></div>
    <div class="icoAuthor">Expert Author: <?php the_author_link(); ?></div>
    <div class="icoComments"><?php comments_popup_link('No Comments', '1 Comment ', '% Comments'); ?></div>
    </div>
    <?php
    &listids = get_post_meta($post->ID, 'list_array', true);
    $query_args = array('post_type'=>'post', 'post_status'=>'publish', 'include' => 'echo $listids;', 'orderby' => 'date', 'order' => 'ASC');
    $query_posts = get_posts($query_args);
    $last_query = end($query_posts);
    foreach ($query_posts as $post) : setup_postdata($post); ?>
    
    
    <?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '" style="float:left;margin-bottom:35px;"'); ?><h3><?php echo get_post_meta($post->ID, 'list_number', true); ?>. <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3><?php the_excerpt(45); ?><a href="<?php the_permalink(); ?>" class="more">Read More..</a><div style="clear:both;"></div><hr />
    <?php endforeach; ?>
    
    
    
    <span class='st_facebook_hcount' displayText='Facebook'></span>
    <span class='st_twitter_hcount' displayText='Tweet'></span>
    <span class='st_pinterest_hcount' displayText='Pinterest'></span>
    <span class='st_linkedin_hcount' displayText='LinkedIn'></span>
    <span class='st_sharethis_hcount' displayText='ShareThis'></span><br /> <?php the_tags('<p class="tags">Tags: ', ', ', '</p>'); ?>
    <div id="howback">IGNORE THIS</div>
    <?php comments_template(); ?>
    
    <?php endwhile; ?>
    
    <?php else : ?>
    
    <p>Sorry, but you are looking for something that isn't here.</p>
    
    <?php endif; ?>
    
    
    </div>
    <!-- END COL LEFT -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

  5. I've made a working query to query Wordpress posts by ID but hit a roadblock.

     

    I can't pass the custom field value into the post ID array as that is where I will eneter the values to be used in the array.

     

    As seen here: listids being the custom field value.

     

     

    <?php
    &listids = get_post_meta($post->ID, 'list_array', true);
    $query_args = array('post_type'=>'post', 'post_status'=>'publish', 'include' => 'echo $listids;', 'orderby' => 'date', 'order' => 'ASC');
    $query_posts = get_posts($query_args);
    $last_query = end($query_posts);
    foreach ($query_posts as $post) : setup_postdata($post); ?> 

  6. I have this code which checks for the word "Big Ben" and if it's not there it outputs some html. I want t be able to make another statement to also check for the word "London Tower" and if it's not there then to check for the word "Canary Wharf",

     

    So far I've only managed one statement without the code breaking, how do I add the others in as well.

     

    <?php $astacker=get_post_meta($post->ID, 'thesite', true); if ( $astacker == [b]'Big Ben'[/b]) { ?>
    <?php include(TEMPLATEPATH."/feedsgrabstack.php");?>
    <?php }else { ?>
    <div id="splitter"><div class="clear">
    <a href="<?php echo get_post_meta($post->ID, "linktosource", true);?>">Click Here To View Answers</a> <span style="float:right;"><a href="#related">See Related Questions</a></div></div>
    <?php } ?>

  7.  

    The code you pasted still had it.

     

    This code has worked fine for months:

     

    $ret = @preg_replace('«'.stripslashes($pattern).'«i', $this->current_feed['replace'][$i], $this->postinfo[$postfield]);

     

    Then the error was saying that this character '�' found in the code (even in notepad) like this:

     

    $ret = @preg_replace(''�'.stripslashes($pattern).''�i', $this->current_feed['replace'][$i], $this->postinfo[$postfield]); (had to leave off php tags to show it properly).

     

    So I replaced the broken code with the code that has been working for months, but it still keeps saying that the '� is on that line and casuing an unknown modifier?? Thanks

  8. You can't use multibyte unicode characters (« is \u00AB) as delimiters for your pattern. See http://php.net/regexp.reference.delimiters

     

    This worked fine up until an hour ago when  the "«" was replaced with '�'  and it created the error.

     

    I then fixed the line but it still keeps saying that the '�'  is causing an "Unknown modifier" even though the '�'  doesn't even exist in the code any more... ?

     

     

  9. I think you're using a character set that's not supported.  Why are you using that character as a delimiter anyway? («)

     

    Also, remove the '@' symbol.  Suppressing errors isn't healthy, if you have errors you should handle them appropriately.

     

    The weird part is this script worked fine, then where the («) are was replaced with those weird question marks so I replaced with the backed up file but still get those errors saying they still exist when they don't any more?

     

    Could the script possibly have cached an old version of the way it runs?

  10. I keep getting an "Unknown modifier" error with this line of code in my script:

     

    $ret = @preg_replace('«'.stripslashes($pattern).'«i', $this->current_feed['replace'][$i], $this->postinfo[$postfield]);

     

    The error says there is a '�' character but when I check the file there are none of them present in the code, though first time I chekced there were then I removed them but error still occurs.

     

    preg_replace() [function.preg-replace]: Unknown modifier '�'

     

    Is there a case that it is not refreshing the script and I need to delete and replace? (tried this though)

    Is there an issue with the initial line of code I've shown? (it has worked for weeks up until I changed memory size scripts are allowed to use).

    The weird issue is that no matter how many times I change the line to the previously working line - the script will still encounter the issue...?

     

    All replies thanked in advance and I'll pop back soon to see any suggestions. Thanks.

  11. I can't believe WP is in it's 3rd version and still is really awkward to make a custom post loop by using certain ID's stored in a table.

     

    I have 10 id's that dynamically change which are stored in a table outside of wp_posts. It seems even if I do manage to get these Id's Wordpress is pretty useless at being able to make a loop to display the data from them.

     

    I've even tried paying someone to do it for me and they said they couldn't do it.

     

    Basically all I want is for silly WP to create a loop of 10 posts ID's which are selected from a separate table then let me display them using while have_posts or something similar.

     

    I guess WP really is still crap if it can't do this?

     

    Here's what they provide for a custom select loops. You'll see that you can't loop by post id. grrr.

     

    http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query

  12. possible, because in the SQL-statement is:

    'post_date'

    which should read:

    `post_date`

     

    The first one (between '') is a string, the second one (with the back-quotes), is a reference to the field named post_date....

     

    and 'post_date' is always >  '2010-10-02.....'..

     

    Nice thanks for that. I did figure that out eventually.

     

    This works perfectly too but (cont below)

     

    <?php echo $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND `post_date` > ' 2010-01-01 13:24:53'");
    if (0 < $numposts) $numposts = number_format($numposts); ?>
    

     

    If I try to use the date("Y") or date("m") like so

     

    ' ".date("Y") . "-01-01 13:24:53'");

     

    or

     

    ' 2010-".date("m") . "-01 13:24:53'");

     

    It doesn't work.

     

    I guess maybe I misunderstand how to add ".date("m") . " in to make sure it is added correctly and ths it won't work unless I do.

     

    If I'm not making sense shout at me hehe.

     

    Thanks dude.

     

     

  13. I have made a bit of code that queries the database for articles published within the last year.

     

    <?php echo $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND 'post_date' > '" . date("Y") . "-01-01-01 00:00:00'");
    if (0 < $numposts) $numposts = number_format($numposts); ?>

     

    I really don't even know how it works and need to because I want to figure out how to make it also get articles published within the last day, month and week.

     

    I suppose if I understood what needs changing I might be able to work with it but so far everything I've tried either returns the exact same number or nothing at all.

     

    It's for Wordpress just to note.

     

    Any ideas?

  14. I thinks that is what you want to do.

    echo '<li>'. 
                dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '" class="footer-thumb" width="40px" height="40px"').
                '<a href="' . get_permalink($id) . '">' . get_the_title($id) . '</a>'.
          '</li>';

     

    Tjis works much better than anything I tried.

     

    Though one issue is that it doesn't echo both inside the <li> but rather image outside and url inside. I tweaked it a little and got it  to display them in separate <li>'s but this isn't what i need.

     

    Any ideas why they aren't inside the same <li> tags? (by they I mean the .dp_attatchment_image and the permalink fucntion.

     

    Thanks.

  15. I'm no expert but don't you need to escape the quotes so the echo doesn't end before you want it to?

    Also you're trying to target your link to a PHP value, but the code isn't in PHP, at least from the code provided, if that's the case you would need the link to be like this

    <a href="<?PHP echo get_permalink($id); ?>"> <?PHP echo get_the_title($id) . '</a></li>';?>

     

    The whole thing would look something like this, let me know how it goes...

     

    <?PHP echo "<li><?php dp_attachment_image($post->ID, \'thumbnail\', \'alt=\'" . $post->post_title . "\' class=\"footer-thumb\" width=\"40px\" height=\"40px\""); ?><a href="<?PHP echo get_permalink($id); ?>"> <?PHP echo get_the_title($id) . '</a></li>'; ?>

     

    Doesn't work but thanks for the advice. Still trying to do it lol.

  16. I don't think I'm grasping this concept one little bit. can take me months too unfortunately.

     

    What I have today is this line of code

    echo '<li><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '" class="footer-thumb" width="40px" height="40px"'); ?><a href="' . get_permalink($id) . '">' . get_the_title($id) . '</a></li>';

     

    It doesn't work because it creates a syntax error.

     

    I know it's simple too but still can't get my head round this kind of coding.

     

    Thanks to everyone who takes their time to reply.

  17. All you have to do is put the PHP code in the "if" block:

    <?php
    if ( is_user_logged_in() ) {
        if(function_exists('twit_connect')){twit_connect()};
    } else {
        echo 'Welcome, visitor!';
    }
    ?>

     

    Ken

     

    Wow. That makes much more sense. Should have thought about that one.

     

    Hopefully this post ranks in the Google beast so others can benefit from it too.  :D

     

    Thank you thank you thank you.

×
×
  • 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.