我想知道为什么我的更新不会填充本地Sqlite数据库。昨天,数据库应用程序中的少数记录工作正常。今天又插入了另外10条记录。两种send方法似乎都能正常工作,但它们不会返回数据。它仅更新IngredientDB而不更新RecipeID请求。这是我的更新操作脚本代码,
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)"/>
这是我数据库的结构
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 :(得分:0)
您如何配置您的网络服务器?也许这是你的脚本上的一个PHP错误,你没有得到答案,因为服务器(或mayeb php)配置不显示错误。
您检查错误日志了吗?您也可以尝试直接执行php文件而不是通过Flash执行,只是为了确保URL正确并且答案格式正确。
希望这有帮助!