I have this code into my php script that i test:
mysql_query("INSERT INTO te_sales(uid,s_credit,s_price,s_date) VALUES ('$user_info[id]','$cPack[t_credit]','$cPack[t_price]',time())");
but when purchase something, data about buyer are not inserted into te_sales
table into database. What is wrong with that?
This is entire code:
if(isset($_POST['te_package'])){
// Lets get the data....
$sP = intval($_POST['te_package']);
// Lets check in DB either it is there or not.
$chk = mysql_query("SELECT * FROM te_pack WHERE id='$sP' LIMIT 1");
if(mysql_num_rows($chk)== 1){ // Founded go ahead
// Fetch the sP pack
$cPack = mysql_fetch_array($chk);
// Check user balance...
if($user_info['purchase_balance'] >= $cPack['t_price']){ // Proceed as user
have enough balance to make purchase.
// Lets Cut out the user balance... And give the TE Credits
mysql_query("UPDATE members SET purchase_balance = purchase_balance -
'$cPack[t_price]' , te_credit = te_credit + '$cPack[t_credit]'
WHERE id='$user_info[id]'");
// Insert the logs of sales...
//mysql_query("INSERT INTO te_sales(uid,s_credit,s_price,s_date) VALUES
('$user_info[id]','$cPack[t_credit]','$cPack[t_price]',time())");
$result = mysql_real_escape_string("
INSERT INTO te_sales(uid,s_credit,s_price,s_date)
VALUES ('$user_info[id]','$cPack[t_credit]','$cPack[t_price]',time())
");
if (!$result) {
die('Invalid request : ' . mysql_error());
}