在第8行的\ myform.php中的非对象上调用成员函数escape()

i am making a simple data entry form for wordpress. i have the form submitting to the following bit of php:

//protect your codes from attacks.
 isset($_POST['exporter']) ? $exporter=$wpdb->escape($_POST['exporter']) : $exporter='';
 isset($_POST['importer']) ? $importer=$wpdb->escape($_POST['importer']) : $importer='';
 isset($_POST['conveyance']) ? $conveyance=$wpdb->escape($_POST['conveyance']) : $conveyance='';
 isset($_POST['origin']) ? $origin=$wpdb->escape($_POST['origin']) : $origin='';
 isset($_POST['dpoe']) ? $dpoe=$wpdb->escape($_POST['dpoe']) : $dpoe='';
 isset($_POST['impcon']) ? $impcon=$wpdb->escape($_POST['impcon']) : $impcon='';
 isset($_POST['container']) ? $container=$wpdb->escape($_POST['container']) : $container='';
 isset($_POST['nopk']) ? $nopk=$wpdb->escape($_POST['nopk']) : $nopk='';
 isset($_POST['tyop']) ? $tyop=$wpdb->escape($_POST['tyop']) : $tyop='';
 isset($_POST['name']) ? $name=$wpdb->escape($_POST['name']) : $name='';
 isset($_POST['botname']) ? $botname=$wpdb->escape($_POST['botname']) : $botname='';
 isset($_POST['quantity']) ? $quantity=$wpdb->escape($_POST['quantity']) : $quantity='';
 isset($_POST['certify']) ? $certify=$wpdb->escape($_POST['certify']) : $certify='';
 isset($_POST['declaration']) ? $declaration=$wpdb->escape($_POST['declaration']) : $declaration='';
 isset($_POST['date']) ? $date=$wpdb->escape($_POST['date']) : $date='';
 isset($_POST['treatment']) ? $treatment=$wpdb->escape($_POST['treatment']) : $treatment='';
 isset($_POST['dutemp']) ? $dutemp=$wpdb->escape($_POST['dutemp']) : $dutemp='';
 isset($_POST['concen']) ? $concen=$wpdb->escape($_POST['concen']) : $concen='';
 isset($_POST['adinfo']) ? $adinfo=$wpdb->escape($_POST['adinfo']) : $adinfo='';
 isset($_POST['insname']) ? $insname=$wpdb->escape($_POST['insname']) : $insname='';
 isset($_POST['place']) ? $place=$wpdb->escape($_POST['place']) : $place='';
 isset($_POST['namedesg']) ? $namedesg=$wpdb->escape($_POST['namedesg']) : $namedesg='';
 isset($_POST['dateissue']) ? $dateissue=$wpdb->escape($_POST['dateissue']) : $dateissue='';
if (is_object($wpdb) && is_a($wpdb, 'wpdb')) {
if (!$wpdb->insert('form',

                        array(
                            'consignor'=>$_POST[exporter]
                            ,'consignee'=>$_POST[importer]
                            ,'conveyance'=>$_POST[conveyance]
                .... ?>

any ideas on why i am getting the error?

This is because of $wpdb. either call it or one of it's object before using it.

It looks like your code is inside a function, so $wpdb is out of scope and not accessible. You need to global it to have access. Or pass $wpdb to your function as an argument.

// at the beginning of your function
global $wpdb;