• Hi,
    I am getting this warning message at the top of my WP site Page ” Warning: implode() [function.implode]: Invalid arguments passed in /home/tony452/public_html/wp-content/themes/entrepreneur-2right/includes/custom_functions/seo.php on line 103″ Can anyone tell me how to fix this? I can’t find the error.

    Thank you.
    Tony S.

    Here is Code : ‘function tpk_seo_keywords () {

    global $posts, $wpdb;

    if ( is_single() ) {
    $page_keywords = get_the_tag_list(”, ‘ ‘, ”);
    }
    elseif (is_home() || is_category() || is_tag() || is_date() || is_search() ) {
    foreach ($posts as $post_values) {
    $array_id[] = $post_values->ID;
    }
    $list_id = implode(‘”,”‘, $array_id);
    $sql_query = ‘SELECT DISTINCT name ‘.
    ‘FROM ‘.$wpdb->term_relationships.’ AS rel,’.
    $wpdb->term_taxonomy.’ AS tax,’.
    $wpdb->terms.’ AS ter ‘.
    ‘WHERE tax. taxonomy = “post_tag” ‘.
    ‘AND rel.object_id IN (“‘. $list_id.'”) ‘.
    ‘AND rel.term_taxonomy_id = tax.term_taxonomy_id ‘.
    ‘AND tax.term_id = ter.term_id ORDER BY tax.count’;
    $results = $wpdb->get_results($sql_query);
    $page_keywords = implode(‘ ‘, $results);
    }
    if ($page_keywords != ”) {
    $page_keywords = htmlspecialchars(stripslashes(strip_tags(str_replace(“\n”, ”, $page_keywords))));
    echo ‘<meta name=”keywords” content=”‘.$page_keywords.'”>’.”\n”;’

Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi,
    you have:
    $list_id = implode( '","', $array_id);
    that has an error you can’t close ‘ with ” so you’ll probably have to use:
    $list_id = implode( "","",$array_id); -edit: not valid sorry
    This should do it, let me know if it doesn’t.
    Regards
    or what is your argument? check implode here.

    ok, I double checked your code and from what I understand you need to implode using

    “,”

    right?

    I’m having trouble getting the error also, can you help?can you comment out one by one the 2 “implode” functions to see which one is the one causing the error?

    Thread Starter Tony S.

    (@tony-s)

    jnhghy thank you for trying to figure this out. I have not got a fix yet I am still looking for help. Is there anyone here that knows something about how to fix this warning? Please help.

    Thank You

    well as I said above it will be easier for someone to know which instance of the implode function is causing the error the first or the second one, and for that we need you to tell us this.

    Thread Starter Tony S.

    (@tony-s)

    jnhghy the thing is that looking at the same code online in a .PHP forum my code seems to be correct You can look at it here the second illustration : tell me what you think.

    http://www.emmanuelgeorjon.com/code-your-own-seo-function-with-wordpress-the-keywords-4501/

    Hi Tony,
    I checked the code that you linked to at you are right, the code is correct this means only one thing: the sql query is not returning anything here:

    $sql_query = 'SELECT DISTINCT name	'.
    'FROM '.$wpdb->term_relationships.' AS rel,'.
    $wpdb->term_taxonomy.' AS tax,'.
    $wpdb->terms.' AS ter '.
    'WHERE tax. taxonomy = "post_tag" '.
    'AND rel.object_id IN ("'. $list_id.'") '.
    'AND rel.term_taxonomy_id = tax.term_taxonomy_id '.
    'AND tax.term_id = ter.term_id ORDER BY tax.count';
    $results = $wpdb->get_results($sql_query);

    you can check it with php if you want, with an easy:
    if ($result) echo "Query returns values!"; else echo "Jnhghy is right the variable is empty";
    🙂
    for this code to work you need to have tags already set in your site thing that can be outseen for an in-development site I’m not sure this is the case but the best thing is to check your database run the query against your database in mysql by outputing the query and then run it in mysql. If this doesn’t work let me know and I’ll try the code myself on my site!
    Regards

    Thread Starter Tony S.

    (@tony-s)

    I would do the query that you advise if I knew where to start. My coding abilities are very limited and I would probably only make the problem worse.:)

    Thank you so much for the advice.
    Tony S,

    ok, I’ve modified your code to test if the “$resutls” variable is empty or not.
    what you have to do is to change the code you have now with the one here and run it. if the “$resutls” variable is empty it will give you an alert instead of an error message.
    Regards

    Thread Starter Tony S.

    (@tony-s)

    Hi jnhghy,

    I copy & pasted the modified Raw Paste Data into my code, I don’t get the “Warning: implode() [function.implode]: Invalid arguments passed in” I now get this error:
    “Parse error: syntax error, unexpected ‘:’ in /home/tony452/public_html/wp-content/themes/entrepreneur-2right/includes/custom_functions/seo.php on line 115”
    Did I do something wrong with the copy & paste?

    My mistake sorry try this code.

    Thread Starter Tony S.

    (@tony-s)

    I think the whole code has now been corrupted by changes that have been made. I really appreciate your help very much. I think that I will see if I can contact the creator of this code to see if they can assist.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Warning: implode() [function.implode]: Invalid arguments passed in /home/tony45’ is closed to new replies.