php - 不工作 mysql_fetch_array 也没有显示它的错误

标签 php mysql ajax

获取无法连接 下面给出的是我提出查询部分的问题。我在压力下完全困惑。如果有人知道解决方案,请在这里更新我。谢谢
上面还包括 dp 连接文件
我的 catcode 变量如 SCA1005,SCB1001...

案例 childprdadd: $data = explode('~',$_GET['data']);

//hint:->value = categorie+'~'+childprd+'~'+childqty+'~'+childcolor+'~'+catcode

$category_name = $data[0];
$childprod_name = $data[1];
$child_qty = $data[2];
$child_color = $data[3];
$cat_code = $data[4];
//echo $category_name.'+'.$childprod_name.'+'.$child_qty.'+'.$child_color.'+'.$cat_code;
$split = str_split($cat_code);
$pos = $split[2];

switch($pos)
{
    case 'A':
$child1 = mysql_fetch_array(mysql_query("select * from goldsun_child1_subcategory where code = '".$cat_code."'"))or die('could not connect'.mysql_error());
$des1 = $child1['description'].'->'.$childprd_name;

mysql_query("insert into goldsun_child_product set cat_id = '".$child1['cat_id']."',sub_cat_id = '".$child1['id']."',name = '".$childprd_name."',qty = '".$childprd_qty."', description = '".$des1."',color_id = '".$child_color."',category_name = '".$category_name."',code = '".$cat_code."'");

break;

case 'B':
$child2 = mysql_fetch_array(mysql_query("select * from goldsun_child2_subcategory where code = '".$cat_code."'"));
$des2 = $child1['description'].'->'.$childprd_name;

mysql_query("insert into goldsun_child_product set cat_id = '".$child2['cat_id']."',sub_cat_id = '".$child2['sub_cat_id']."',child1_id = '".$child2['child1_id']."',name = '".$childprd_name."',qty = '".$childprd_qty."', description = '".$des2."',color_id = '".$child_color."',category_name = '".$category_name."',code = '".$cat_code."'");
break;

case 'C':
$child3 = mysql_fetch_array(mysql_query("select * from goldsun_child3_subcategory where code = '".$cat_code."'"));
$des3 = $child3['description'].'->'.$childprd_name;

mysql_query("insert into goldsun_child_product set cat_id = '".$child3['cat_id']."',sub_cat_id = '".$child3['sub_cat_id']."',child1_id = '".$child3['child1_id']."',child2_id = '".$child3['child2_id']."',name = '".$childprd_name."',qty = '".$childprd_qty."', description = '".$des3."',color_id = '".$child_color."',category_name = '".$category_name."',code = '".$cat_code."'");
break;

case 'D':
$child4 = mysql_fetch_array(mysql_query("select * from goldsun_child4_subcategory where code = '".$cat_code."'"));
$des4 = $child4['description'].'->'.$childprd_name;

mysql_query("insert into goldsun_child_product set cat_id = '".$child4['cat_id']."',sub_cat_id = '".$child4['sub_cat_id']."',child1_id = '".$child4['child1_id']."',child2_id = '".$child4['child2_id']."',child3_id = '".$child4['child3_id']."',name = '".$childprd_name."',qty = '".$childprd_qty."', description = '".$des4."',color_id = '".$child_color."',category_name = '".$category_name."',code = '".$cat_code."'");
break;

case 'E':
$child5 = mysql_fetch_array(mysql_query("select * from goldsun_child5_subcategory where code = '".$cat_code."'"));
$des5 = $child5['description'].'->'.$childprd_name;

mysql_query("insert into goldsun_child_product set cat_id = '".$child5['cat_id']."',sub_cat_id = '".$child5['sub_cat_id']."',child1_id = '".$child5['child1_id']."',child2_id = '".$child5['child2_id']."',child3_id = '".$child5['child3_id']."',child4_id = '".$child5['child4_id']."',name = '".$childprd_name."',qty = '".$childprd_qty."', description = '".$des5."',color_id = '".$child_color."',category_name = '".$category_name."',code = '".$cat_code."'");
break;

case 'T':
$cat = mysql_fetch_array(mysql_query("select * from goldsun_child_category where code = '".$cat_code."'"));
$cat_des = $cat['description'].'->'.$childprd_name;

mysql_query("insert into goldsun_child_product set cat_id = '".$cat_des['cat_id']."',name = '".$childprd_name."',qty = '".$childprd_qty."', description = '".$cat_des."',color_id = '".$child_color."',category_name = '".$category_name."',code = '".$cat_code."'");
break;

}
break;  

最佳答案

您使用的是新版 MySQL 还是旧版 MySQL?如果您使用的是旧版 MySQL (which has been deprecated),请检查您的“INSERT”命令。如果您正在使用新的 MySQL(使用 PDOMySQLi ),请尝试学习并使用 prepared statement .

如果您使用的是旧版本的 MySQL,也许您需要:

<?php
$con = mysql_connect(server,username,password);
$bla = mysql_query($con,"INSERT into goldsun_child_product (cat_id, sub_cat_id, name, qty, blablabla) VALUES (".$child1['cat_id'].",".$child1['id'].",".$blablabla."");
$child = mysql_fetch_array($bla);
?>

如果您使用的是新版本,请尝试使用准备好的语句学习 MySQLi 或 PDO。

关于php - 不工作 mysql_fetch_array 也没有显示它的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21360520/

相关文章:

PHP 从类和样式中回显 HTML

mysql - 删除父记录并将子记录保留在评论表中

mysql - 在子查询中动态设置列名

ajax - 异步 AJAX 调用返回什么?

php - 从 ajax 调用中解析 JSON 数据

php - 使用ajax和jquery将数组发送到codeigniter(php) Controller ,并在现有加载页面(在任何div中)上加载页面

php - 时区、夏令时等

python - 通过 python 来自 mariadb 的错误文本

javascript - 如何在 .jsp 文件中接收 Ajax 发送的数组

上传冲突的 PHP 临时文件名