2012-06-01 40 views
1
//$type has value of "Hello+World" 
$type = $_POST['series']; 

$sql = "select max(id) from TABLE_NAME where type = " . $type; 

$result = sybase_query ($sql, $db_ro_conn) or die(db_error("query failed $sql")); 
$row = sybase_fetch_row($result) 

我得到錯誤「不正確的語法不久 「=」,Y15,在$ SQL行過程N/A。的Sybase SQL + PHP,爲什麼附近有語法錯誤 '='

可能是什麼?原因發生這種情況不知怎的,這是行不通的希望得到任何幫助,感謝你周圍的$ type

+0

'$ type'爲空或空字符串或者包含一些特殊的字符。 – Leri

回答

1

把雙引號是這樣的:!

$type = $_POST['series']; 

$sql = "select max(id) from TABLE_NAME where type = '" . $type. "'"; 

$result = sybase_query ($sql, $db_ro_conn) or die(db_error("query failed $sql")); 
$row = sybase_fetch_row($result) 
0

讓我開始與這個總是逃避POST /在您的查詢中獲取值!

錯誤可能是由$ type是字符串而不是引用引起的。嘗試改變$ SQL來

$sql = "select max(id) from TABLE_NAME where type = '" . $type."'"; 
0

你是不是引用值:

$type = str_replace("'", "''", $_POST['series']); 
$sql = "select max(id) from TABLE_NAME where type = '" . $type . "'";