不工作mysql_fetch_array也没有显示错误

时间:2014-01-26 06:33:02

标签: php mysql ajax

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

case 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;  

1 个答案:

答案 0 :(得分:0)

您使用的是新的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。