$wpdb not loading?
-
Am replacing working sql statements with $wpdb methods. I have replaced SELECT statements, but have not been able to UPDATE. I have included all of the code, not knowing what is causing the fail. The error I get is Uncaught Error: Call to a member function show_errors() on null in /home4/hsysgrpc/public_html/wp-content/themes/twentytwelve-child/custom-page_InputMemberID-wpdb.php:17; or if I comment out the show_errors() statement, the same Call to a member function on null points to the UPDATE statement. Thank you for your help.
<?php // custom-page_InputMemberID-wpdb.php 3/13/2022 /** * Template Name: Input Member ID wpdb * * @package WordPress * @subpackage Twenty_Twelve * @since Twenty Twelve 1.0 */ include 'myFuncs.php'; $link = connect(); global $wpdb; $wpdb->show_errors(true); if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } if(isset($_POST['search'])) { $searchf = $_POST['searchf']; $searchf = preg_replace("#[^A-Za-z\' -]#i","",$searchf); //only characters and spaces, - $searchq = $_POST['search']; $searchq = preg_replace("#[^A-Za-z\' -]#i","",$searchq); $searchn = $_POST['memberNumber']; echo "<br>$searchf<br>"; echo "<br>$searchq<br>"; echo "<br>$searchn<br>"; $FirstName = $searchf; echo $FirstName; echo "<br>"; $LastName = $searchq; echo "LastName = " . $LastName; echo "<br>"; $MemberID = $searchn; //New National Number echo $MemberID; echo "<br>"; $tablename = "AAUW_New_Members"; echo "AAUW_New_Members " . $tablename; echo "<br>"; $data = $MemberID; echo $data; echo "<br>"; $wherecondition = $searchq; echo "<br>"; echo "LastName = " . $wherecondition; $updated = $wpdb->update($tablename, array('MemberID' => $searchn ), array('LastName' =>$searchq ) ); echo print_r($updated); "<br>"; } //Close isset search ?> <html> <head> <title>Search for ID by FirstName,Lastname</title> </head> <body> <form id = 1 action = "/wp-content/themes/twentytwelve-child/custom-page_InputMemberID-wpdb.php" method="POST"> <p> Input New Member ID for record to be moved from AAUW_New_Members to AAUW_Members </p> <input type ="text" name = "searchf" placeholder= "Search for First Name..."/> <input type ="text" name = "search" placeholder= "Search for Last Name..."/> <input type ="text" name = "memberNumber" placeholder= "Input MemberNumber..."/> <input type = "submit" value = "search..." /> </form> </body> </html>
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘$wpdb not loading?’ is closed to new replies.