• Resolved christopherharte

    (@christopherharte)


    Hello, and thank you for even taking a look! I am integrating a ‘favorite post’ system into the wordpress installation i am working on which allows users to choose their favorite videos to be posted to their profile. I have created a form buttun with hidden values which passes the users data as well as the id of the video to a form via POST in a separate php file. I have a little Javascript running on the page to prevent a refresh while the page is being viewed and just sends the info without causing any page disruption.

    I have tested the wpdb query i am trying to execute on a different page, and it seems to work fine. the problem arises in the query when the query is executed from a separate php page called through submission of the form.

    <?php 
    
    if(isset($_POST['favvid'])){
    
    $the_vid = ($_POST['favvid']);
    $user_id = ($_POST['userid']);
    $favs_array = ($_POST['favs']);
    
    $_favs_array = explode(",",$favs_array);
    $_favs_array[] = $the_vid;
    $new_favs = implode(",", $_favs_array);
    
    //------ Everything up to this point functions fine ------- //
    global $wpdb;
    $wpdb->query("UPDATE $wpdb->users SET favorite_vids = '$new_favs' WHERE $wpdb->users.ID = '$user_id' LIMIT 1");?>
    
    ?>

    The page which this from is on is located in the theme directory along with the rest of the theme files.

    Any ideas or suggestions as to where to start tackling this issue would be greatly appreciated 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter christopherharte

    (@christopherharte)

    Whoops, under the code, i meant to say is that the code above is in getfav.php where the form submitting the POST to getfav.php is on a separate page also in the theme directory, thx!

    Thread Starter christopherharte

    (@christopherharte)

    Never mind, education is a funny and exciting thing, i figure ill just check out the wp-comments-post.php in the root and see whats going on there

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WPDB scope issue?’ is closed to new replies.