问题代码如下:error_reporting(E_ALL ^ E_NOTICE);
//包含excel读取类文件
require_once 'excel_reader2.php';
$data = new Spreadsheet_Excel_Reader();
//设置文本输出编码
$data->setOutputEncoding('GBK');
//读取Excel文件 $tmp_name为服务器存储的临时文件
$data->read($tmp_name);
//把文件内容存放到bhhn数据库的reports表格中
//屏蔽报错机制
error_reporting(E_ALL ^ E_DEPRECATED);
//连接sql数据库
$link=mysql_connect("127.0.0.1","root","");
mysql_select_db('bhhn');
//设置文本输出编码
mysql_query("set names 'GBK'");
//向reports数据表插入数据
$arr=array($data->sheets[0]['cells'][2][3],$data->sheets[0]['cells'][2][5],$data->sheets[0]['cells'][2][8],$data->sheets[0]['cells'][2][10],$data->sheets[0]['cells'][5][2],$data->sheets[0]['cells'][5][3],$data->sheets[0]['cells'][5][4],$data->sheets[0]['cells'][5][5],$data->sheets[0]['cells'][5][6],$data->sheets[0]['cells'][5][7],$data->sheets[0]['cells'][5][8],$data->sheets[0]['cells'][5][9],$data->sheets[0]['cells'][5][10],$data->sheets[0]['cells'][5][11],$data->sheets[0]['cells'][7][2],$data->sheets[0]['cells'][7][4],$data->sheets[0]['cells'][7][5],$data->sheets[0]['cells'][7][6],$data->sheets[0]['cells'][7][7],$data->sheets[0]['cells'][8][3],$data->sheets[0]['cells'][8][8],$data->sheets[0]['cells'][10][2],$data->sheets[0]['cells'][10][3],$data->sheets[0]['cells'][10][4],$data->sheets[0]['cells'][10][5],$data->sheets[0]['cells'][10][6],$data->sheets[0]['cells'][10][7],$data->sheets[0]['cells'][10][8],$data->sheets[0]['cells'][10][9],$data->sheets[0]['cells'][13][2],$data->sheets[0]['cells'][13][3],$data->sheets[0]['cells'][13][4],$data->sheets[0]['cells'][13][5],$data->sheets[0]['cells'][13][6],$data->sheets[0]['cells'][13][7],$data->sheets[0]['cells'][13][8],$data->sheets[0]['cells'][13][9],$data->sheets[0]['cells'][13][10],$data->sheets[0]['cells'][13][11],$data->sheets[0]['cells'][14][2],$data->sheets[0]['cells'][15][2],$data->sheets[0]['cells'][16][2]);
//在这个位置插入print_r($arr);可以看到arr数组中的数据是正确的
$sql="insert into reports(wellName,reportTime,DDName,tellNum,bigginDate,wellDepth,dateDrilling,bitTime,position,lithology,casingPipeDiameter,casingPipeDepth,KOPDepth,pipeDiameter,bitData,weightOnBit,rateOfFlow,RPM,pressure,deviceType,troubleAnalysis,density,viscosity,fluidLoss,mudCake,initialGelStrength,10-minutoGelStrength,PH,sandContent,MD,Inc,Azi,TVD,CloD,CloAz,forecastTargetDepth,targetTVD,forecastTargetCloD,forecastTargetCloAz,drillingToolStructure,projectPrograss,troubles) values('$arr[0]','$arr[1]','$arr[2]','$arr[3]','$arr[4]','$arr[5]','$arr[6]','$arr[7]','$arr[8]','$arr[9]','$arr[10]','$arr[11]','$arr[12]','$arr[13]','$arr[14]','$arr[15]','$arr[16]','$arr[17]','$arr[18]','$arr[19]','$arr[20]','$arr[21]','$arr[22]','$arr[23]','$arr[24]','$arr[25]','$arr[26]','$arr[27]','$arr[28]','$arr[29]','$arr[30]','$arr[31]','$arr[32]','$arr[33]','$arr[34]','$arr[35]','$arr[36]','$arr[37]','$arr[38]','$arr[39]','$arr[40]','$arr[41]')";
mysql_query($sql);运行的结果没有报错,但是刷新Mysql数据库没有接到数据。尝试了只对前边5个字段插入,可以成功是插入语句对values值有个数限制呢,还是有其他错误?初学,望不吝赐教
添加回答
举报
0/150
提交
取消