我正在尝试运行此php文件,但它给了我一个错误
<?php
include ('json.php');
if(isset($_POST['location_name']) && isset($_POST['location_details
']) && ($_POST['Item_name']) && ($_POST['Item_price'])){
$location_name = $_POST['location_name'];
$location_details = $_POST['location_details'];
$Item_name = $_POST['Item_name'];
$Item_price = $_POST['Item_price'];
$query = "INSERT INTO GPSNear(location_name, location_details, Item_name, Item_price) "
. "VALUES('$location_name', '$location_details', '$Item_name', '$Item_price')";
$data = mysqli_query($conn, $query);
$GPSNear = array();
if($data){
$id = mysqli_insert_id($conn);
$q = "SELECT * FROM GPSNear WHERE id = $id";
$r = mysqli_query($conn, $q);
$row - mysqli_fetch_assoc($r);
$GPSNear['location_name'] = $row['location_name'];
$GPSNear['location_details'] = $row['location_details'];
$GPSNear['Item_name'] = $row['Item_name'];
$GPSNear['Item_price'] = $row['Item_price'];
echo json_encode($GPSNear);
} else {
echo "ERROR!";
}
exit();
}
?>
因为我正在解析JSON FIle,因为我需要将这个php文件作为Json Oject读取但是它给了我这样的错误
Fatal error: Uncaught Error: Call to undefined function mssql_connect() in C:\xampp\htdocs\apiforandroid\json.php:14 Stack trace: #0 C:\xampp\htdocs\apiforandroid\GPSNear.php(2): include() #1 {main} thrown in C:\xampp\htdocs\apiforandroid\json.php on line 14
对不起,如果有任何事情不够清楚,并且有什么东西丢失
这是我的json.php
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$myServer = "localhost";
$myUser = "root";
$myPass = "testroot";
$myDB = "YourNeeds";
$conn = mssql_connect($myServer,$myUser,$myPass);
if (!$conn)
{
die('Not connected');
}
?>
............................................... ........
答案 0 :(得分:2)
正在使用PHP 7,并且在PHP 7中删除了mssql_connect,因此无法找到并使用该函数。
您应该切换到其他方法,例如PDO
答案 1 :(得分:0)
我认为json.php正在创建与数据库的连接。
首先检查您的php版本,因为mssql_connect()已在PHP 7.0.0中删除。 该功能的替代方案包括:
http://php.net/manual/en/function.mssql-connect.php
或者您需要安装:
在php.ini文件中,查找extension_dir行。
检查php_mssql.dll文件是否在该目录中,并确保添加该行: 延长= php_mssql.dll