Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP的数组中转换日期时间_Php_Arrays_Odbc - Fatal编程技术网

在PHP的数组中转换日期时间

在PHP的数组中转换日期时间,php,arrays,odbc,Php,Arrays,Odbc,上载了包含日期的csv文件,失败。 上载的csv文件没有日期,数据保存在数据库中,但存在另一个错误:- 此结果索引中没有可用的元组 SQL state 22008:我想是因为它无法读取我的日期格式。 我当前的csv格式如下:-2017年2月4日 有没有办法转换数组中的日期格式 我尝试在数组中使用“date('d/m/Y',strotime($dateRecorded))”格式进行转换,但它不起作用 include('../db_conn.php'); $output = ''; $a

上载了包含日期的csv文件,失败。 上载的csv文件没有日期,数据保存在数据库中,但存在另一个错误:- 此结果索引中没有可用的元组

SQL state 22008:我想是因为它无法读取我的日期格式。 我当前的csv格式如下:-2017年2月4日

有没有办法转换数组中的日期格式

我尝试在数组中使用“date('d/m/Y',strotime($dateRecorded))”格式进行转换,但它不起作用

include('../db_conn.php');
  $output = '';  
  $allowed_ext = array("csv");  
  $extension = end(explode(".", $_FILES["employee_file"]["name"]));  
  if(in_array($extension, $allowed_ext))  
  {  
       $file_data = fopen($_FILES["employee_file"]["tmp_name"], 'r');  
       fgetcsv($file_data);  
       while($row = fgetcsv($file_data))  
       {  
           $accnum = addslashes($row[0]);  
           $dedate = addslashes($row[1]); //deposit date  
           $transcode = addslashes($row[2]);  
           $amount = addslashes($row[3]);  
           $reffno = addslashes($row[4]);  
           $remarks = addslashes($row[5]);      
  $query = odbc_exec("INSERT INTO accdetails VALUES(   '0','','".$accnum."','".$dedate."','".$transcode."','".$amount."','".$reffno."','".$remarks."','','','','','')"); 
            $result = odbc_fetch_array($query); 
我收到这个错误:-

SQL错误:[Informix][Informix ODBC驱动程序][Informix]日期时间或间隔中的非数字字符,SQL状态22008


我已经检查了我的insert查询,但是我看不到产生了任何多个结果,这是因为我的while循环吗

以前我使用odbc\u fetch\u数组。。。但当我在谷歌上搜索时,他们说用odbc_next_result替换它。但是做了,但同样的事情发生了

  $select2 = odbc_exec("SELECT * FROM accdetails ORDER BY spiid ASC");  
       $result2 = odbc_fetch_array($select2);  
       $output .= '  
            <table class="table table-bordered">  
                 <tr>  
                           <th>ID</th>  
                           <th>File Name</th>  
                           <th>Acc No</th>  
                           <th>Depo Date </th>
                           <th>Trans Code</th>  
                           <th>Amount</th>  
                           <th>Reff No</th>  
                           <th>Remarks</th> 
                 </tr>  
                    ';  
       while($row =  odbc_next_result($result2))  
       {  
            $output .= '  
                    <tr>  
                           <td>'.$row["spiid"].'</td>  
                           <td>'. $row["spifilename"].'</td>  
                           <td>'.$row["spiaccountno"].'</td>  
                           <td>'.$row["spidepositdate"].'</td>                                
                           <td>'.$row["spitranscode"].'</td>  
                           <td>'. $row["spiamount"].'</td>  
                           <td>'.$row["spireferenceno"].'</td>  
                           <td>'.$row["spiremarks"].'</td>
                 </tr>  
            ';  
       }  
       $output .= '</table>';  
       echo $output;  
  }  
$select2=odbc\u exec(“通过spiid ASC从accdetails订单中选择*);
$result2=odbc\u fetch\u数组($select2);
$output.='
身份证件
文件名
会计科目编号
保存日期
转换码
数量
参考号
评论
';  
while($row=odbc\u next\u result($result2))
{  
$output.='
“.$row[“spiid”]”
“.$row[“spifilename”]”
“.$row[“spiaccountno”]”
“.$row[“spidepositdate”]”
“.$row[“spitranscode”]”
“.$row[“spiamount”]”
“.$row[“spireferenceno”]”
“.$row[“spiremarks”]”
';  
}  
$output.='';
echo$输出;
}  

MySQL日期应为YYYY-mm-dd格式

所以你需要改变

$dedate = addslashes($row[1]);


希望您能在
$row[1]

中找到日期是的,找到了!非常感谢你,但是你知道为什么我在那里提到了另一个错误吗**此结果索引处没有可用的元组。可能有多个结果集。你能检查一下你的插入查询吗?表名后面似乎缺少列。我已使用insert查询编辑问题。你能检查一下它有什么毛病吗?这是因为我的while循环吗?我猜这一行$result=odbc\u fetch\u array($query);$query用于INSERT,您正在获取数据。
$dedate = date( 'Y-m-d H:i:s', $row[1] );