Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.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 如何使用选定的文本文件并将其上载到solaris?_Php_Html_Mysql_Solaris - Fatal编程技术网

Php 如何使用选定的文本文件并将其上载到solaris?

Php 如何使用选定的文本文件并将其上载到solaris?,php,html,mysql,solaris,Php,Html,Mysql,Solaris,我目前使用的是HTML、MySql和PHP的组合,使用Solaris作为服务器。我已经在MySql上创建了这些表,需要使用Html将一个文件从我的PC桌面上传到服务器的文件夹中 第一个按钮用于选择文件 第二个按钮用于将数据加载到HQ数据库 第三个按钮用于跳转到另一个php文件 我得到了两个查询,首先,使用所选文本文件中的数据加载到数据库的代码是什么。其次,如何使用第三个按钮跳转到另一个目录 <h2> Upload HQ WareHouse</h2> //upload f

我目前使用的是HTML、MySql和PHP的组合,使用Solaris作为服务器。我已经在MySql上创建了这些表,需要使用Html将一个文件从我的PC桌面上传到服务器的文件夹中

第一个按钮用于选择文件 第二个按钮用于将数据加载到HQ数据库 第三个按钮用于跳转到另一个php文件

我得到了两个查询,首先,使用所选文本文件中的数据加载到数据库的代码是什么。其次,如何使用第三个按钮跳转到另一个目录

<h2> Upload HQ WareHouse</h2>

//upload file function
<form method ="post" action="checkTransaction.php" enctype="multipart/form-data">
    <input type="file" name ="datatxtfile" id ="datatxtfile">
    <input type="submit" value= "Click here to Upload The Transaction's File into the Database">
</form>

<br>

<input type="button" name="a" value= "Click here to return " onclick ="hist()">
</body>


//PHP code to explode
<?php


 $file = file_get_contents("Inventory_1000.txt");
 //var_dump($file);

 $lines = explode("\n",$file);

 print_r($lines); print line

 foreach($lines as $index => $line) {
  $data = explode(":", $line);

  mysql_query("INSERT INTO wareHouse (
        productName, categoty, manufacturer, barcode, buyingPrice, currentStock, minimumStock) 
        VALUES 
        '". $data[0] ."',
        '". $data[1] . "',
        '". $data[2] ."',
        '". $data[3] . "',
        '". $data[4] ."',
        '". $data[5] . "',
        '". $data[6] . "'
       )") or die(mysql_error());

 }

?>
上传总部仓库
//上传文件功能

//要爆炸的PHP代码
  • 使用所选文本文件中的数据加载到数据库的代码是什么

    为什么不直接使用

    将数据填充“Inventory_1000.txt”加载到表仓库中
    以“:”结尾的字段
    以“\n”结尾的行
    (
    产品名称,
    教条,
    制造商
    条形码,
    买价,
    流通股,
    最小库存
    )
    
  • 如何使用第三个按钮跳转到另一个目录

    <h2> Upload HQ WareHouse</h2>
    
    //upload file function
    <form method ="post" action="checkTransaction.php" enctype="multipart/form-data">
        <input type="file" name ="datatxtfile" id ="datatxtfile">
        <input type="submit" value= "Click here to Upload The Transaction's File into the Database">
    </form>
    
    <br>
    
    <input type="button" name="a" value= "Click here to return " onclick ="hist()">
    </body>
    
    
    //PHP code to explode
    <?php
    
    
     $file = file_get_contents("Inventory_1000.txt");
     //var_dump($file);
    
     $lines = explode("\n",$file);
    
     print_r($lines); print line
    
     foreach($lines as $index => $line) {
      $data = explode(":", $line);
    
      mysql_query("INSERT INTO wareHouse (
            productName, categoty, manufacturer, barcode, buyingPrice, currentStock, minimumStock) 
            VALUES 
            '". $data[0] ."',
            '". $data[1] . "',
            '". $data[2] ."',
            '". $data[3] . "',
            '". $data[4] ."',
            '". $data[5] . "',
            '". $data[6] . "'
           )") or die(mysql_error());
    
     }
    
    ?>
    
    请改用超链接(推荐),否则,
    onclick
    事件应使用要加载的资源的URI设置
    location.href

  • 正如PHP手册中关于mysql函数的章节所述:不建议在编写新代码时使用此扩展。相反,应该使用或扩展名。在选择MySQL API时,请参阅以获取更多帮助。