我正在尝试使用会话中的数据更新我的事务表中的列。我将会话数据存储如下
$session_mem_id = $_SESSION['mem_id'];
$member_data = member_data($session_mem_id, 'mem_id', 'mem_email', 'mem_password', 'mem_address', 'mem_city', 'mem_postcode', 'mem_county', 'mem_country', 'mem_first_name', 'mem_last_name', 'password_recover', 'allow_email', 'admin', 'mem_tel');
我使用这些数据来更新我的表,如下所示
function createTransaction($member_data){
// Insert into the transactions table
$query1 = mysql_query("INSERT INTO `transactions` (mem_id, OrderDate, ship_phone, ship_address, ship_city, ship_county, ship_postcode, ship_country) VALUES('{$_SESSION['mem_id']}', NOW(), '{$member_data['mem_tel']}', '{$member_data['mem_address']}', '{$member_data['mem_city']}', '{$member_data['mem_county']}', '{$member_data['mem_postcode']}', '{$member_data['mem_country']}')") or die(mysql_error());
}
我没有收到错误,但是在我的表上更新的唯一列是mem_id、orderdate和OrderId作为它的auto_increment。没有数据解析存储在我的$member_data
If I var_dump($member_data) 我得到以下
array(14) { ["mem_id"]=> string(2) "11" ["mem_email"]=> string(26) "j.hfbgb92@gmail.com" ["mem_password"]=> string(8) "password" ["mem_address"]=> string(16) "54 bvcbv drive" ["mem_city"]=> string(9) "Mggbone" ["mem_postcode"]=> string(8) "gb14 4gb" ["mem_county"]=> string(4) "Kent" ["mem_country"]=> string(14) "United Kingdom" ["mem_first_name"]=> string(4) "Bob" ["mem_last_name"]=> string(12) "Smith" ["password_recover"]=> string(1) "0" ["allow_email"]=> string(1) "1" ["admin"]=> string(1) "1" ["mem_tel"]=> string(11) "07900186785" }
我的 member_data 函数是 function member_data($mem_id) { $data = array(); $mem_id = (int)$mem_id;
$func_num_args = func_num_args();
$func_get_args = func_get_args();
if($func_num_args > 1) {
unset ($func_get_args[0]);
$fields = '`' . implode('`, `', $func_get_args) . '`';
$data = mysql_fetch_assoc(mysql_query("SELECT $fields FROM members WHERE mem_id = '$mem_id'"));
return $data;
}
}