我有麻煩讓我的PHP腳本通過PHP運行在我的LAMP服務器中。 繼承人我的代碼,我有問題。無法讓我的mysql_query()在我的php腳本中工作
# Insert Statement
$insert ="INSERT INTO ACRC VALUES('','','1C3-4A','$fs','$acrc1c3_4afs');
INSERT INTO ACRC VALUES('','','1C3-4A','$fi','$acrc1c3_4afi');
INSERT INTO ACRC VALUES('','','1C3-4A','$fo','$acrc1c3_4afo');
INSERT INTO ACRC VALUES('','','1C3-4B','$fs','$acrc1c3_4bfs');
INSERT INTO ACRC VALUES('','','1C3-4B','$fi','$acrc1c3_4bfi');
INSERT INTO ACRC VALUES('','','1C3-4B','$fo','$acrc1c3_4bfo');
INSERT INTO ACRC VALUES('','','1C3-12A','$fs','$acrc1c3_12afs');
INSERT INTO ACRC VALUES('','','1C3-12A','$fi','$acrc1c3_12afi');
INSERT INTO ACRC VALUES('','','1C3-12A','$fo','$acrc1c3_12afo');
INSERT INTO ACRC VALUES('','','1C3-12B','$fs','$acrc1c3_12bfs');
INSERT INTO ACRC VALUES('','','1C3-12B','$fi','$acrc1c3_12bfi');
INSERT INTO ACRC VALUES('','','1C3-12B','$fo','$acrc1c3_12bfo');";
echo "$insert";
mysql_query($insert) or die(mysql_error());
echo "$insert";
?>
運行此命令將返回以下結果。
[[email protected] html]# php snmp.php
ACRC Unit 1C3-4A : Fan Speed 73.3 % : Fluid In Temperature 47.2 F : Fluid Out Temperature 55 F
ACRC Unit 1C3-4B : Fan Speed 74 % : Fluid In Temperature 47.8 F : Fluid Out Temperature 53.5 F
ACRC Unit 1C3-12A : Fan Speed 28.9 % : Fluid In Temperature 44.7 F : Fluid Out Temperature 46.4 F
ACRC Unit 1C3-12B : Fan Speed 28.5 % : Fluid In Temperature 47.1 F : Fluid Out Temperature 62.9 F
INSERT INTO ACRC VALUES('','','1C3-4A','Fan Speed','73.3');
INSERT INTO ACRC VALUES('','','1C3-4A','Fluid Temperature In','47.2');
INSERT INTO ACRC VALUES('','','1C3-4A','Fluid Temperature Out','55');
INSERT INTO ACRC VALUES('','','1C3-4B','Fan Speed','74');
INSERT INTO ACRC VALUES('','','1C3-4B','Fluid Temperature In','47.8');
INSERT INTO ACRC VALUES('','','1C3-4B','Fluid Temperature Out','53.5');
INSERT INTO ACRC VALUES('','','1C3-12A','Fan Speed','28.9');
INSERT INTO ACRC VALUES('','','1C3-12A','Fluid Temperature In','44.7');
INSERT INTO ACRC VALUES('','','1C3-12A','Fluid Temperature Out','46.4');
INSERT INTO ACRC VALUES('','','1C3-12B','Fan Speed','28.5');
INSERT INTO ACRC VALUES('','','1C3-12B','Fluid Temperature In','47.1');
INSERT INTO ACRC VALUES('','','1C3-12B','Fluid Temperature Out','62.9');You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO ACRC VALUES('','','1C3-4A','Fluid Temperature In','47.2');INSERT IN' at line 2
現在,我已經採取然後從該結果和手動把它放在我的MySQL和它的工作因爲是雖然它返回2警告每個insert語句。 第一個值是自動增量id值,第二個值是時間戳。
對於後續問題,我的時間戳返回全0。
你們能幫我解答嗎?我已經很長時間潛伏了,這個網站在過去幫了我很多。
[爲什麼不應該使用mysql_ *函數在PHP?](HTTP:// stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) –