WPDB scope issue?
-
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 ??
- The topic ‘WPDB scope issue?’ is closed to new replies.