The only thing that stands out is you are not using quotes corectly on this line:
$data_update = array('MemberID'=>'$MemberID');
It should be without the quotes. Single quotes like you have don’t allow for variable to be substibuted (double quotes will), so it the variable should not be wrapped in quotes at all to keep it easier:
$data_update = array('MemberID'=>$MemberID);
MK
(@mkarimzada)
This is correct. The var_dump should return string type. If you take a look at wpdb::update method, it calls/returns wpdb::prepare which sanitize the SQL query for safe execution.
To properly check the execution:
$result = $wpdb->update($table_name, $data_update, $data_where);
if ($result === false) // Failed
if ($result === true) // Updated
I hope this helps.
Driving me berserk.
$sql = "UPDATE AAUW_New_Members SET MemberID = '$searchn' WHERE FirstName = '$firstName' AND LastName = '$lastName' ";
if(mysqli_query($link,$sql)) {
echo ” New Record Inserted” ;
} else {
{
echo “Error: No record inserted” ;
}`
array(1) { [“MemberID”]=> string(7) “7777777” }
array(2) { [“FirstName”]=> string(5) “Marie” [“LastName”]=> string(5) “Curie” }
$table_name = 'AAUW_New_Members';
echo $table_name;
echo "<br>";
$MemberID = $searchn;
echo $MemberID;
"<br>";
$data_update = array("MemberID"=>$searchn);
$data_where = array("FirstName" => $firstName,
"LastName" => $lastName
);
var_dump($data_update ) ;
echo "<br>";
var_dump($data_where ) ;
echo $MemberID;
echo "<br>";
echo $data_update;
echo "<br>";
echo $data_where;
echo "<br>";
$wpdb->update($table_name, $data_update, $data_where);
MemberID does not update.
The error I get is Call to a member function update() on null in /home4/hsysgrpc/public_html/wp-content/themes/twentytwelve-child/custom-page_InputMemberID-wpdb.php:51
Stack trace:
I have tried without success
require_once(‘../wp-load.php’); // relative path
global $wpdb;
$wpdb->show_errors(true); also
$updated = $wpdb->update($tablename,
array(‘MemberID’ => $searchn
),
array(‘LastName’ =>$searchq
)
);
echo print_r($updated);