2012-01-27 153 views
0

我有一些鏈接,顯示在iframe中的數據與數據庫 我正在獲取這個數據與查詢字符串的幫助下臨時數據的幫助下全局臨時表創建失敗

與鏈接的頁面是

<style type="text/css"> 
a 
{ 
    text-decoration:none; 
} 
.Menu 
{ 
    width:150px; 
    float:left; 
} 
.fr 
{ 
    width:800px; 
    height:800px; 
    float:right 
} 

</style> 
<div class="Menu"> 
<?php 
mysql_connect("localhost","dbname","password"); 
mysql_select_db("dbname"); 
$sql="select * from NSEIndices_latest"; 
$result=mysql_query($sql); 
while($row=mysql_fetch_array($result)) 
{ 
$tpnt=$row['TickerPlantCode']; //nse indice code 
$indexname=$row['IndexName']; //nse indice index name 
?> 
    <tr> 
    <td><a href="http://mastertrade.in/master/wpfiles/gtnsegainers.php?tpnt=<?php echo $tpnt;?>&indexname=<?php echo $indexname;?>" target="fr"><?php echo $indexname;?></a><br></td> 
    </tr> 
    <?php }?> 
    </div> 
    <div class="fr"> 
    <iframe height="780" width="780" scrolling="no" name="fr"></iframe> 
    </div> 

現在從上述頁面鏈接中獲取數據與查詢字符串在該網頁的collectiong從各種表 數據創建的臨時表的幫助,但我得到的錯誤,而從該臨時表中檢索數據

與臨時表的頁面是

<table class="table" cellspacing="0" width="100%"> 
    <tr> 
    <td align="left" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9;">Company Name 
     </th> 
    <td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">High 
     </th> 
    <td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Low 
     </th> 
    <td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Last Price 
     </th> 
    <td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Prv Close 
     </th> 
    <td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Change 
     </th> 
    <td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">%Gain 
     </th> 
    </tr> 
<?php 
mysql_connect("localhost","dbname","password"); 
mysql_select_db("dbname"); 
$tpnt=$_GET['tpnt']; 
$indexname=$_GET['indexname']; 
echo "1".$indexname. "<br>"; 
$query="SELECT nsepricequotes_latest.Symbol, nsepricequotes_latest.CompanyName, nsepricequotes_latest.HighPrice, nsepricequotes_latest.LowPrice, nsepricequotes_latest.LastTradedPrice, nsepricequotes_latest.ClosePrice, nsepricequotes_latest.NetChange, nsepricequotes_latest.PercentChange, nse_index_constituents.Tickerplant_index_code,nse_index_constituents.NSE_Index_Name 
FROM nsepricequotes_latest, nse_index_constituents 
WHERE nsepricequotes_latest.TickerPlantCode = nse_index_constituents.TickerPlant_scrip 
AND PercentChange >0 
ORDER BY PercentChange DESC "; 
$result=mysql_query($query); 
echo "2".$indexname. "<br>"; 
while($row1=mysql_fetch_array($result)) 
{ 
$Symbol1=$row1['Symbol']; 
$CompanyName1=$row1['CompanyName']; 
$HighPrice1=$row1['HighPrice']; 
$LowPrice1=$row1['LowPrice']; 
$LastTradedPrice1=$row1['LastTradedPrice']; 
$ClosePrice1=$row1['ClosePrice']; 
$NetChange1=$row1['NetChange']; 
$PercentChange1=$row1['PercentChange']; 
$Tickerplant_index_code1=$row1['Tockerplant_index_code1']; 
$NSE_Index_Name1=$row1['NSE_Index_Name']; 
} 
echo "3".$indexname. "<br>"; 
$tbl="create GLOBAL TEMPORARY TABLE temppice(Symbol varchar(100),CompanyName varchar(200),HighPrice float(50),LowPrice float(50),LastTradedPrice float(50),ClosePrice float(50),NetChange float(50),PercentChange float(50),Tickerplant_index_code varchar(100),NSe_Index_Name varchar(100)) ON COMMIT DELETE ROWS;"; 
$res=mysql_query($tbl); 
if (!$res) { die('Temporary table creation failed: ' . mysql_error()); } 
if(mysql_error())die(mysql_error()); 
$intbl="Insert into temppice values('$Symbol1','$CompanyName1','$HighPrice1','$LowPrice1','$LastTradedPrice','$ClosePrice1','$NetChange1','$PercentChange1','$Tockerplant_index_code1','$NSE_Index_Name1')"; 
mysql_query($intbl); 
if(mysql_error())die(mysql_error()); 
echo "4".$indexname. "<br>"; 
$query1="Select * from temppice where NSE_Index_Name=$indexname"; 
$result1=mysql_query($query1); 
//if(mysql_error())die(mysql_error()); 
mysql_connect("localhost","dbname","password"); 
mysql_select_db("dbname"); 
while($row=mysql_fetch_array($result1, MYSQL_BOTH)) 
{ 
$symbol=$row['Symbol']; 
$CompanyName=$row['CompanyName']; 
$HighPrice=$row['HighPrice']; 
$LowPrice=$row['LowPrice']; 
$previousclose=$row['LastTradedPrice']; 
$ClosePrice=$row['ClosePrice']; 
$netChange=$row['NetChange']; 
$percentagechange=$row['PercentChange']; 
?> 

    <tr> 
    <td align="left" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $CompanyName;?></td> 
    <td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $HighPrice;?></td> 
    <td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $LowPrice;?></td> 
    <td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $previousclose; ?></td> 
    <td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $ClosePrice;?></td> 
    <td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $netChange;?></td> 
    <td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $percentagechange;?></td> 
    </tr> 
    <?php } ?> 
</table> 

錯誤我得到是

臨時表創建失敗:你在你的SQL語法 有一個錯誤;檢查對應於你的MySQL服務器版本 爲正確的語法在1號線

回答

0

According to the manual的使用近 'GLOBAL TEMPORARY TABLE temppice(符號爲varchar(100),公司名稱爲varchar(200),幾點措施' 手冊MySQL的CREATE TABLE語法不支持global關鍵字的appears to be an Oracle thing同樣我相信,ON COMMIT DELETE ROWS條款是Oracle語法,不會在MySQL的工作,要麼部分

如果除去這兩部分,它可能會工作:。

$tbl=<<<SQL 
create TEMPORARY TABLE temppice (
    Symbol     varchar(100), 
    CompanyName   varchar(200), 
    HighPrice    float(50), 
    LowPrice    float(50), 
    LastTradedPrice  float(50), 
    ClosePrice    float(50), 
    NetChange    float(50), 
    PercentChange   float(50), 
    Tickerplant_index_code varchar(100), 
    NSe_Index_Name   varchar(100) 
); 
SQL; 
+0

得到相同的錯誤 – Manoj 2012-01-27 06:26:19

+0

我不認爲我看到任何其他問題的語句的語法。你確定你得到_exact same_error?它還在說'靠近'全球時間表'嗎?如果是這樣,你確定你刪除了該部分的聲明?它是否會在代碼的其他地方再次碰到不受支持的語法的另一個實例? – 2012-01-27 23:11:12