I'm trying to work with an external db in Wordpress for the first time and can't seem to get it to insert the data into the DB. Here's what I have:
<?php
global $wpdb;
$url = home_url();
require_once($url.'/viper/confff.php'); //contains variable to fill in below
$newdb = new wpdb($username, $password, $db_name, $host);
$newdb->show_errors();
?>
$numrows = $newdb->get_results("SELECT * FROM chi_clients WHERE AccountNum='$acctNum'");
if($numrows!=0)
{
$row = $newdb->get_results("SELECT * FROM chi_clients WHERE AccountNum='$acctNum'",ARRAY_A);
$name= $row['lastName'] . ", " . $row['firstName'];
$phone= $row['phone'];
$phonearea = substr($phone,0,3);
$phonemain = substr($phone,3,10);
$phonenumber = $phonearea ."-". $phonemain;
$email= $row['email'];
$newdb ->insert (
chi_orders, array(
'name' => '$name',
'AccountNum' => '$acctNum',
'email' => '$email',
'OrderDesc' => '$orderDesc',
'product' => '$service',
'quantity' => '$quantity',
'notes' => '$notes',
'status' => 'Order Received',
'dateIne' => '$todayDate',
'dateOut' => '$newDate',
'advert' => '$advert',
'phone' => '$phonenumber'
)
);
}
else {
echo'<span style="color: #000; font-family: Verdana; font-weight: bold; font-size: 12px;">Incorrect Account Number!</span>';
}
I know the data is being posted to page as I have the variables echoed out to display on the page. However it's not connecting to the Database as I'm not getting the information from the get_results SELECT statement and it's not inserting anything into database. For my $host- I'm using 'localhost' which is what I've always used for this particular database. And I know that the username, pass, and database name are correct.
any ideas? thanks.