Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.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
注意:第64行“php文件路径”中的数组到字符串转换_Php_Mysql_Arrays_Oracle - Fatal编程技术网

注意:第64行“php文件路径”中的数组到字符串转换

注意:第64行“php文件路径”中的数组到字符串转换,php,mysql,arrays,oracle,Php,Mysql,Arrays,Oracle,PHP代码-: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/ht

PHP代码-:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php
$rows =0;
$fp = fopen("leave1.csv","r");
if($fp){
    while(!feof($fp)){
          $content = fgets($fp);
      if($content)    $rows++;
    }
}
fclose($fp);
//echo $rows;
$_SESSION['rows'] = $rows;
?>
<?php
$row = 1;
$row1=0;
if (($handle = fopen("leave1.csv", "r")) !== FALSE) 
{
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) 
    {
        $num = count($data);
        $row++;
        for ($c=0; $c < $num; $c++) 
        {
            $array[$row1][$c] = $data[$c];
        }
        $_SESSION['num'] = $num; 
        $row1 = $row1 + 1;
    }
    fclose($handle);
}
?>
<?php

$num = $_SESSION['num'];
$rows = $_SESSION['rows'];

for($rs=0;$rs<$rows;$rs++)
{
    for($cs=0;$cs<$num;$cs++)
    {
        echo $array[$rs][$cs];
        echo " ";
    }
    echo "<br />\n";
}
?>

<?php
$connection = oci_connect("SIEBELT2","SIEBELT2$1","DS2D");
$num = $_SESSION['num'];
$rows = $_SESSION['rows'];
for($rs=0;$rs<$rows;$rs++)
{
    $main_query=oci_parse($connection,"INSERT INTO ROTTAN(NAME,ROLLNO) VALUES('$array[$rs][0]','$array[$rs][1]')");

         if(!$main_query)
         {
            echo "Error in preparing the statement";
            exit;
         }
         oci_execute($main_query);
}
$connection = oci_connect("SIEBELT2","SIEBELT2$1","DS2D");
?>


</body>
</html>
注意:第64行C:\xampp\htdocs\Website\u LMS\bulk1.php中的数组到字符串转换

这样做:

$main_query=oci_parse($connection,"INSERT INTO ROTTAN(NAME,ROLLNO) VALUES('{$array[$rs][0]}','{$array[$rs][1]}')");
请注意每个变量周围的花括号。PHP在字符串中使用时无法计算出复杂的表达式。或者,您可以这样做:

$main_query=oci_parse($connection,"INSERT INTO ROTTAN(NAME,ROLLNO) VALUES('" . $array[$rs][0] . "','" . $array[$rs][1] . "')");

在双引号字符串中插入变量时,花括号是您的朋友:

$main_query=oci_parse($connection,"INSERT INTO ROTTAN(NAME,ROLLNO) VALUES('{$array[$rs][0]}','{$array[$rs][1]}')");

您试图在查询本身中将数组转换为字符串。首先将数组转换为字符串,然后将其放入查询中。
$main_query=oci_parse($connection,"INSERT INTO ROTTAN(NAME,ROLLNO) VALUES('{$array[$rs][0]}','{$array[$rs][1]}')");