As if you are already working with WordPress, you should think of using $wpdb class as it does everything SQL more securely.. :
global $wpdb;
$table = $wpdb->prefix . "app";
$wpdb->insert(
$table,
array(
'appid' => '',
'insert_keys' => $insert_values,
)
);
// your insert ID: $wpdb->insert_id
$app_row = $wpdb->get_results( "SELECT MAX(appid) FROM $table AS appid" );
var_dump( $app_row ) // it should be an array, so use foreach loop to store your data in variables e.g $app_id = '';foreach($app_row as $row) {$app_id = $row->appid;}
//$query = "INSERT INTO ..._app (appid,$insert_keys) VALUES ('',$insert_values)";
//mysql_query($query)
//or die(mysql_error());
//$app_query = mysql_query("SELECT MAX(appid) AS appid FROM ..._app")
//or die(mysql_error());
//$app_row = mysql_fetch_array($app_query);
//extract($app_row);
// I don't know what to do here..
$agent_msg = "...
\n
Application ID: $appid\n
Borrower Information\n
First Name: $fname\r
Middle: $mname\r
Last Name: $lname\r
You could also use $wpdb->prepare for direct queries, such as:
$wpdb->query($wpdb->prepare("DELETE FROM $table WHERE id = %d LIMIT 1",$id));
Or even
$sql = "DELETE FROM $table WHERE id = '$id' LIMIT 1";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
Take your time and look at $wpdb class in the codex.