2013-07-20 177 views
0

好吧我一直在搞這個代碼很長一段時間了,它一直說我有一個意想不到的T_VARIABLE線54.任何人都知道它是什麼以及如何解決?錯誤意外T_VARIABLE

// Write the key and activation time to the database as a new row 
**LINE 54** $registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) VALUES("$key","$time")") or die(mysql_error()); 
+1

你能彰顯線54請 – verbumSapienti

+0

這行是54? – Lucas

+0

我把**行54 **放在行54的前面 – Veloncia

回答

0

有語法錯誤。該代碼是通過使用雙引號的近VALUES("$key","$time")

$registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) VALUES('$key','$time')") or die(mysql_error()); 
+0

Lol謝謝,這是一個noob錯誤 – Veloncia

+0

它發生了,這就是爲什麼我們在這裏幫助。 –

0

您插入查詢看起來像它已被" PHP破足夠聰明,可以讀取"報價則沒有必要換你變量裏面的變量打破在"的時候都已經打開

$registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) 
VALUES($key,$time)") or die(mysql_error()); 
0

正確路線54

$ registerid = mysql_query(「INSERT INTO downloadkey (uniqueid,timestamp)VALUES(\」$ key \「,\」$ time \「)」)或 die(mysql_error());

0
**LINE 54** $registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) VALUES(\"$key\",\"$time\")") or die(mysql_error()); 

讓您遠離報價。

0

這條線是罪魁禍首。如果你提出分手的字符串插入你需要將它們串聯變量

解決方案A:

$registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) VALUES('".$key."','".$time."')") or die(mysql_error()); 

溶液B

$registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) VALUES('$key','$time')") or die(mysql_error()); 

請不要使用過時的功能,如mysql_ *

1

您需要用單引號代替雙引號:

$registerid = mysql_query(" 
INSERT INTO downloadkey (uniqueid,timestamp) 
VALUES('$key','$time')") or die(mysql_error()); 

另一個解決辦法是連接你的變量,像這樣:

$registerid = mysql_query(" 
INSERT INTO downloadkey (uniqueid,timestamp) 
VALUES(" . $key . "," . $time . ")") or die(mysql_error()); 

Please, don't use mysql_* functions in new code。他們不再維護and are officially deprecated。請參閱red box?請改爲了解prepared statements,並使用PDOMySQLi - this article將幫助您決定哪個。如果您選擇PDO,here is a good tutorial

0

也許嘗試:

$registerid = mysql_query("INSERT INTO downloadkey (`uniqueid`,`timestamp`) VALUES('$key','$time')") or die(mysql_error()); 
0
$registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) VALUES("$key","$time")") or die(mysql_error()); 

替換:

$registerid = mysql_query("INSERT INTO downloadkey (uniqueid,timestamp) VALUES('" . $key . "','" . $time . "')") or die(mysql_error()); 
相關問題