2011-12-18 100 views
0

我想知道爲什麼我的更新不會填充本地Sqlite數據庫。昨天在數據庫應用程序中使用很少的記錄正常工作。今天插入另外10條記錄之後。兩種發送方法似乎都能正常工作,但它們不返回數據。它僅更新IngredientDB,但不更新配方ID請求。這是我更新的動作腳本代碼,Http send()請求不返回任何值

dishName.addEventListener("Success", dishName_resultHandler); 
dishName.addEventListener("...", faultHandler); 
dishName.send(); 
dishIngs.addEventListener("Success", ingredients_resultHandler); 
dishIngs.addEventListener("...", faultHandler); 
dishIngs.send(); 
protected function dishName_resultHandler(event:ResultEvent):void 
{ 
externalRecipes=event.result.recipes.recipe; 
} 

protected function ingredients_resultHandler(event:ResultEvent):void{ 
externalIngredients=event.result.ingredients.ingredient; 
} 

這是我的PHP腳本我的第一臺

$mysql_host = "..."; 
$mysql_database = "..."; 
$mysql_user = "..."; 
$mysql_password = "...."; 

$conn = mysql_connect("...", "...","...") or  die(mysql_error()); 
mysql_select_db("....", $conn); 

$sql = 'SELECT * FROM `RecipeDB`'; 
$res = mysql_query($sql); 

$xml = new XMLWriter(); 

$xml->openURI("php://output"); 
$xml->startDocument(); 
$xml->setIndent(true); 

$xml->startElement('recipes'); 

while ($row = mysql_fetch_assoc($res)) { 
$xml->startElement("recipe"); 

    $xml->writeElement('RecipeID', $row['RecipeID']); 
    $xml->writeElement('Name', $row['Name']); 
    $xml->writeElement('Category', $row['Category']); 
    $xml->writeElement('Origin', $row['Origin']); 
    $xml->writeElement('Recipe', $row['Recipe']); 
    $xml->writeElement('Favorite', $row['Favorite']); 
    $xml->writeElement('Image', base64_encode($row['Image'])); 



$xml->endElement(); 
} 

$xml->endElement(); 

$xml->flush(); 

和類似的第二

$conn = mysql_connect("...", "..","...") or die(mysql_error()); 
mysql_select_db("....", $conn); 

$sql = 'SELECT * FROM `IngredientDB`'; 
$res = mysql_query($sql); 

$xml = new XMLWriter(); 

$xml->openURI("php://output"); 
$xml->startDocument(); 
$xml->setIndent(true); 

$xml->writeRaw('<?xml version="1.0"?>'); 
$xml->startElement('ingredients'); 

while ($row = mysql_fetch_assoc($res)) { 
$xml->startElement("ingredient"); 

    $xml->writeElement('rowid', $row['rowid']); 
    $xml->writeElement('RecipeID', $row['RecipeID']); 
    $xml->writeElement('Ingredient', $row['Ingredient']); 
    $xml->writeElement('Quantity', $row['Quantity']); 



$xml->endElement(); 
} 

這是我的服務器

電話
<s:HTTPService id="dishName" 
url="http://.../dish.php" 
result="dishName_resultHandler(event)" 
fault="faultHandler(event)"/> 

<s:HTTPService id="dishIngs" 
url="http://.../Ingedient.php" 
result="ingredients_resultHandler(event)" 
fault="faultHandler(event)"/> 

這是struct我的數據庫

CREATE TABLE `RecipeDB` (
`RecipeID` int(5) NOT NULL AUTO_INCREMENT, 
`Name` varchar(20) COLLATE latin1_general_ci NOT NULL, 
`Category` varchar(20) COLLATE latin1_general_ci NOT NULL, 
`Origin` varchar(20) COLLATE latin1_general_ci NOT NULL, 
`Recipe` varchar(2000) COLLATE latin1_general_ci NOT NULL, 
`Favorite` tinyint(1) NOT NULL, 
`Image` blob NOT NULL, 
PRIMARY KEY (`RecipeID`) 
) 

CREATE TABLE `IngredientDB` (
`rowid` int(5) NOT NULL AUTO_INCREMENT, 
`RecipeID` int(5) NOT NULL, 
`Ingredient` varchar(20) COLLATE latin1_general_ci NOT NULL, 
`Quantity` varchar(100) COLLATE latin1_general_ci NOT NULL, 
PRIMARY KEY (`rowid`) 
) 
+0

那麼它是SQLite或MySQL? 「不返回任何值」是什麼意思? – 2011-12-18 12:52:39

+0

您的虛擬主機似乎將谷歌分析代碼添加到php輸出。你使用Flash內容調試器插件嗎?它抱怨格式不正確的XML嗎? – weltraumpirat 2011-12-18 12:56:39

+0

btw。您應該_really_從您的代碼示例中刪除數據庫詳細信息... – weltraumpirat 2011-12-18 12:58:08

回答

0

你如何配置你的網絡服務器?也許這是你的腳本的PHP錯誤,你沒有得到答案,因爲服務器(或mayeb php)配置爲不顯示錯誤。

你檢查了你的錯誤日誌嗎?您也可以嘗試直接執行php文件,而不是通過Flash來執行,只是爲了確保URL是正確的,而且答案是正確的。

希望這會有所幫助!

+0

文檔xml格式正確,問題似乎與複製值從xml文件到ArrayCollection。問題在於將XML解析器發送到diviace或將值複製到ArrayColletion – 2011-12-18 17:49:42