[英]“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 © 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.