简体   繁体   English

“php 脚本已加载,即使其 MIME 类型(“text/html”)不是有效的 JavaScript MIME 类型”错误

[英]“The php script was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type” error

I'm trying to insert data to oracle database using php from a bootstrap form.我正在尝试使用 php 从引导程序表单将数据插入 oracle 数据库。 Whenever I try to execute the html file in mozilla firefox following error occurs:每当我尝试在 mozilla firefox 中执行 html 文件时,都会发生以下错误:

The script from “http://localhost/CustomerPartInAsma/CUSTOMER%20part%20in%20ASMA/Customer_register.php” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type来自“http://localhost/CustomerPartInAsma/CUSTOMER%20part%20in%20ASMA/Customer_register.php”的脚本已加载,即使其 MIME 类型(“text/html”)不是有效的 JavaScript MIME 类型

My html code and php code is given below:我的 html 代码和 php 代码如下:

HTML code HTML代码

   <!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <title>Business Casual - Start Bootstrap Theme</title>

  <!-- Bootstrap core CSS -->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

  <!-- Custom fonts for this template -->
  <link href="https://fonts.googleapis.com/css?family=Raleway:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Lora:400,400i,700,700i" rel="stylesheet">

  <!-- Custom styles for this template -->
  <link href="css/business-casual.min.css" rel="stylesheet">
  <link href="css/employee.css" rel="stylesheet">
 

</head>

<body>

  
  <!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark py-lg-4" id="mainNav">
    <div class="container">
      <a class="navbar-brand text-uppercase text-expanded font-weight-bold d-lg-none" href="#">Start Bootstrap</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarResponsive">
        <ul class="navbar-nav mx-auto">
           <li class="nav-item px-lg-4">
            <a class="nav-link text-uppercase text-expanded" href="index2.html">Home</a>
          </li>
          <li class="nav-item px-lg-4">
            <a class="nav-link text-uppercase text-expanded" href="about2.html">About</a>
          </li>
          <li class="nav-item px-lg-4">
            <a class="nav-link text-uppercase text-expanded" href="services2.html">Services</a>
          </li>
           <li class="nav-item px-lg-4">
            <a class="nav-link text-uppercase text-expanded" href="gallery2.html">Gallery</a>
          </li>
           
           <li class="nav-item active px-lg-4">
            <a class="nav-link text-uppercase text-expanded" href="logout.html">Login
            </a>
          
          
        </ul>
      </div>
    </div>
  </nav>


    <body>

      
  

  <div class="container">
    <div class="row">
      <div class="col-lg-10 col-xl-9 mx-auto">
        <div class="card card-signin flex-row my-5">
          <div class="card-img-left d-none d-md-flex">
             <!-- Background image for card set in CSS! -->
          </div>
          <div class="card-body">
            <h3 class="card-title text-center">Register</h3>
            <form class="form-signin" role="form" method="post" action="Customer_register.php">
              <div class="form-label-group">
                <input type="text" id="inputUsername" name="inputUsername"class="form-control" placeholder="Username" required autofocus>
                <label for="inputUserame">Full Name</label>
              </div>

              
              <div class="form-label-group">
                <input type="text" id="inputContactNo" name="inputContactNo" class="form-control" placeholder="Contact No" required>
                <label for="inputContactNo">Contact No</label>
              </div>

              <div class="form-label-group">
                <input type="text" id="inputAddress"  name="inputAddress" class="form-control" placeholder="Address" required>
                <label for="inputAddress">Address</label>
              </div>
              
              
              <div class="form-label-group">
                <input type="text" id="inputAllergies"  name="inputAllergies" class="form-control" placeholder="Allergies" required>
                <label for="inputAllergies">Allergies</label>
              </div>
              
              <div class="form-label-group">
                <input type="text" id="inputSkinType" name="inputSkinType" class="form-control" placeholder="Skin Type" required>
                <label for="inputSkinType">Skin Type</label>
              </div>
              
              <div class="form-label-group">
                <input type="text" id="inputHairType"  name="inputHairType" class="form-control" placeholder="Hair Type" required>
                <label for="inputHairType">Hair Type</label>
              </div>
              
              
              <hr>

              <div class="form-label-group">
                <input type="password" id="inputPassword" name="inputPassword" class="form-control" placeholder="Password" required>
                <label for="inputPassword">Password</label>
              </div>
              
              <div class="form-label-group">
                <input type="password" id="inputConfirmPassword" class="form-control" placeholder="Password" required>
                <label for="inputConfirmPassword">Confirm password</label>
              </div>

              <button class="btn btn-lg btn-primary btn-block text-uppercase" type="submit" formaction="index.html" name= "submit">Register</button>
              <a class="d-block text-center mt-2 small" href="login.html">Sign In</a>
              <hr class="my-4">
              
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>






 
  <footer class="footer text-faded text-center py-5">
    <div class="container">
      <p class="m-0 small">Copyright &copy; Your Website 2019</p>
    </div>
  </footer>
  

  <!-- Bootstrap core JavaScript -->
 
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

</body>

</html>

PHP code PHP代码

<?php


    $conn=oci_connect("ASMADB","asmadb","localhost/XE");
    if(!$conn)
        echo 'Failed to connect to Oracle';
    else
        echo 'successful';
    

    $name = $_POST['inputUsername'];
    $phn = $_POST['inputContactno'];
  $add = $_POST['inputAddress'];
  $s_type= $_POST['inputSkinType'];
    $h_type = $_POST['inputHairType'];
      $allergies = $_POST['inputAllergies'];
      $C_pass=  $_POST['inputPassword'];
        
         


    

    $sql="INSERT into customer values('','$name','',0.0,'$s_type','$h_type','$allergies','$phn','$add',1,'$rating','$C_pass')";


    
    $objParse = oci_parse($conn, $sql);

    $objExecute = oci_execute($objParse, OCI_DEFAULT);

    if($objExecute)

    {

        oci_commit($conn); 

        echo "Save completed.";
        

    }

    else

    {
        oci_rollback($conn); 

        $m = oci_error($objParse);

        echo "Error Save [".$m['message']."]";

    }
     
    oci_close($conn);

    ?>

It will be very helpful if someone helps me to resolve this error and insert data to my oracle db.如果有人帮助我解决此错误并将数据插入到我的 oracle 数据库中,这将非常有帮助。

<script src="Customer_register.php"></script>

It looks like you are trying to load a PHP file as JavaScript code.看起来您正在尝试将 PHP 文件加载为 JavaScript 代码。 Is this a mistake?这是一个错误吗?

If not, your browser is rejecting the dynamic JavaScript you are trying to load.如果不是,您的浏览器将拒绝您尝试加载的动态 JavaScript。 You have to give the MIME type of JavaScript to the browser.您必须将 JavaScript 的 MIME 类型提供给浏览器。 Add this to the top of your Customer_register.php file:将此添加到 Customer_register.php 文件的顶部:

header("Content-type: text/javascript");

https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 脚本来自<url>即使其 MIME 类型(“text/html”)不是有效的 JavaScript MIME 类型,也已加载 - The script from <url> was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type 为什么我加载了“df.worker.min.js”,即使它的 MIME 类型(“text/html”)不是有效的 JavaScript MIME 类型” - Why do I get a "df.worker.min.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type" 拒绝从“ file_name.php”执行脚本,因为其MIME类型(“ text / html”)不可执行,并且启用了严格的MIME类型检查 - Refused to execute script from 'file_name.php' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled MIME 类型 (&#39;text/html&#39;) 错误 - MIME type ('text/html') Error ExpressJS 错误:MIME 类型('text/html')不是受支持的样式表 MIME 类型 - ExpressJS error: MIME type ('text/html') is not a supported stylesheet MIME type 资源被解释为脚本,但以MIME类型text / html javascript传输 - Resource interpreted as Script but transferred with MIME type text/html javascript Webpack dev服务器抛出错误 - 拒绝执行脚本,因为它的MIME类型('text / html')不可执行 - Webpack dev server throws error - Refused to execute script because its MIME type ('text/html') is not executable 模拟服务器错误 - 脚本具有不受支持的 MIME 类型 ('text/html') - Mock server error - The script has an unsupported MIME type ('text/html') 拒绝从 &#39;URL&#39; 执行脚本,因为它的 MIME 类型 (&#39;text/html&#39;) 不可执行,并且启用了严格的 MIME 类型检查 - Refused to execute script from 'URL' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled main.css未加载,因为其MIME类型“ text / html”不是“ text / css”吗? - main.css was not loaded because its MIME type, “text/html”, is not “text/css”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM