代码在服务器1中完美运行,但在服务器2中不运行

时间:2016-10-31 14:31:45

标签: php android

我发布了从前端(android)到后端(php)的某些值,这个web服务代码在服务器1中运行良好,但由于某些未知原因,它在服务器2中无效。

我发现mysql_query无效,数据未输入表格。

$result = mysql_query("INSERT INTO tbl_booking(booking_name,booking_address,booking_date,booking_phno,description)  

这是完整的代码

<?php

$con = $con = mysql_connect("localhost","touchlive","touchlive");

if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("raora", $con);
$response ="FALSE";
$booking_name = $_POST['name'];
$booking_address =$_POST['address'];
$booking_date = $_POST['date'];
$booking_phno =$_POST['phno'];
$description =$_POST['description'];
$result = mysql_query("INSERT INTO tbl_booking(booking_name,booking_address,booking_date,booking_phno,description) 

VALUES ('$booking_name','$booking_address','$booking_date', '$booking_phno', '$description')");

if(result ==0) 
$response ="TRUE";

echo $response;

mysql_close($con);

?>

1 个答案:

答案 0 :(得分:0)

 your code has
 if(result == 0)

 where is ' $ '
 if($result == 0) like this

 and give ur db connection like this

$host="your host";
$port=1234;
$socket="/tmp/mysql.sock";
$user="root";
$password="123456789";
$dbname="dbname";

$con = mysqli_connect($host, $user, $password, $dbname, $port, $socket);

change all above variables as per your details
socket can be empty .