PHP 不插入 mysql [英] PHP does not insert into mysql

查看:41
本文介绍了PHP 不插入 mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试插入 mysql 但它给了我一个错误,这里是我的代码:

I'm trying to insert into mysql but it giving me an error, here my code :

$result = mysql_query("INSERT INTO property( Pname, P_Price,P_Desc,P_City, P_Size,P_Rooms, P_garage, P_Address, P_Long, P_Lat, P_Sold, Provinces_idProvinces)
    VALUES('http://10.0.2.2/images/pic3.jpg',98000,'beautifull house','Durban','7m',1,2,'L-377 Umlazi','30.863226','-29.971518',0,'1'");

 if ($result) {
        // successfully inserted into database
        $response["success"] = 1;
        $response["message"] = $result ;

        // echoing JSON response
        echo json_encode($response);
    } else {
        // failed to insert row
        $response["success"] = 0;
        $response["message"] = "Oops! An error occurred.";

        echo $response["success"];

        // echoing JSON response
        echo json_encode($response);
    }

 mysql_close();

它返回消息糟糕!发生错误"我不明白它是怎么发生的

And it returning the message "Oop! An error occured" Which i dont get how it happen

和我的 mysql

CREATE TABLE property (
  idProperty int(11) NOT NULL AUTO_INCREMENT,
  Pname varchar(45) DEFAULT NULL,
  P_Price double DEFAULT NULL,
  P_Desc varchar(45) DEFAULT NULL,
  P_City varchar(45) DEFAULT NULL,
  P_Siz varchar(45) DEFAULT NULL,
  P_Rooms varchar(45) DEFAULT NULL,
  P_garage int(11) DEFAULT NULL,
  P_Address varchar(45) DEFAULT NULL,
  P_Long float (10,6) DEFAULT NULL,
  P_Lat float (10,6) DEFAULT NULL,
  P_Sold tinyint(1) DEFAULT '0',
  Provinces_idProvinces int(11) NOT NULL,
  PRIMARY KEY (idProperty),
  KEY fk_Property_Provinces (Provinces_idProvinces),
  CONSTRAINT fk_Property_Provinces FOREIGN KEY (Provinces_idProvinces) REFERENCES provinces (idProvinces) ON DELETE NO ACTION ON UPDATE NO ACTION
);

推荐答案

我认为您没有用括号结束值.

I think you didn't close out the Values with an end parentheses.

$result = mysql_query(
"INSERT INTO property( Pname, P_Price,P_Desc,P_City, P_Size,P_Rooms, P_garage, P_Address, P_Long, P_Lat, P_Sold, Provinces_idProvinces)
VALUES('http://10.0.2.2/images/pic3.jpg',98000,'beautifull house','Durban','7m',1,2,'L-377 Umlazi','30.863226','-29.971518',0,'1')");

这篇关于PHP 不插入 mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆