gpt4 book ai didi

php - 数据未插入数据库,未显示错误

转载 作者:行者123 更新时间:2023-11-29 06:57:58 26 4
gpt4 key购买 nike

我将此代码放入我测试的 php 脚本中:

mysql_query("INSERT INTO te_sales(uid,s_credit,s_price,s_date) VALUES ('$user_info[id]','$cPack[t_credit]','$cPack[t_price]',time())");

但是当购买商品时,有关买家的数据不会插入到数据库的 te_sales 表中。这有什么问题吗?

这是完整的代码:

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());
}

enter image description here

最佳答案

你看看有没有错误?

<?php
$result_data = mysql_query('
INSERT INTO te_sales(uid,s_credit,s_price,s_date)
VALUES (
"'.mysql_real_escape_string($user_info['id']).'",
"'.mysql_real_escape_string($cPack['t_credit']).'",
"'.mysql_real_escape_string($cPack['t_price']).'",
now()
)
');

if (!$result_data) {
die('Invalid query request: ' . mysql_error());
}
?>

关于php - 数据未插入数据库,未显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44862832/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com