PDA

Volledige versie bekijken : Verzenden via POST geeft XML fout


FredericCox
%Europe/Berlin %394 %2005, 10:27
Hallo,


In Flash heb ik een mc Prono waarin je de prono voor een wedstrijd kan ingeven.

Inputvelden zijn :

HomeGoals
AwayGoals
Comment

en UserID,LeagueID en Continent worden ook nog meegegeven via

var sendProno:LoadVars = new LoadVars();
sendProno.UserID = _global.UserID
sendProno.HomeGoals = HomeScore
sendProno.AwayGoals = AwayScore
sendProno.Comment = Comment
sendProno.MatchID = _parent.MatchID
sendProno.UserID = _global.UserID
sendProno.LeagueID = _parent.LeagueID
trace("len" + _global.arr_leagueIDs.length)
for(i=0;i<=_global.arr_leagueIDs.length;i++){
if(_global.arr_leagueIDs[i].toString() == _parent.LeagueID.toString()){
sendProno.Continent = _global.arr_continent[i]
}
}
url = "http://www.hattricktoday.org/Demo/prono.php?actionType=addProno"
sendProno.send(url,"_blank","POST")


Maar ik krijg dan deze fout in mijn prono.php:

De XML-pagina kan niet worden weergegeven
Kan XML-invoer niet lezen met opmaakmodel . Herstel de fout en klik vervolgens op de knop Vernieuwen of probeer het later opnieuw.


--------------------------------------------------------------------------------

XML-document moet een element hebben op het hoogste niveau. Fout bij het verwerken van bron http://www.hattricktoday.org/Demo/prono.php?actionType=addProno?Continent=EUR&LeagueID=24&MatchID=5666554&Comment=None&AwayGoals=3&HomeGoals=4&UserID=100856.



Dit is mijn php file:

<?php
// Vul uw Mysql data in !
header('Content-type: text/xml');
@mysql_connect ("localhost", "wfm2002_wfm2002", "******") or die ('I cannot connect to the database because: ' . mysql_error());
@mysql_select_db ("wfm2002_hattricktoday");

$blnUseC = false;
$blnUseCon = false;
$strXmlAdd = "";
if (isset($_GET['countryID']))
{
$intCountryID = (int) $_GET['countryID'];
$blnUseC = true;
$strXmlAdd = " countryID=\"$intCountryID\"";
}
if (isset($_GET['continentID']))
{
$strContinentID = $_GET['continentID'];
$blnUseCon = true;
$strXmlAdd .= " continentID=\"$strContinentID\"";
}
switch ($_GET['actionType'])
{
case 'getProno':
$strQuery = "SELECT * FROM tblProno WHERE matchID=". (int) $_GET['matchID'];
if ($blnUseC) $strQuery .= " AND countryID=$intCountryID";
if ($blnUseCon) $strQuery .= " AND continentID='$strContinentID'";
$recResult = mysql_query($strQuery);
while ($row = mysql_fetch_assoc($recResult))
{
$arrProno[] = $row;
}

echo "<pronoData type=\"singleMatch\" matchID=\"". (int) $_GET['matchID'] ."\"$strXmlAdd>\n";
$i = 0;
foreach ($arrProno as $value)
{
echo " <prono index=\"$i\">\n";
echo " <homeTeam>".$value['homeTeam']."</homeTeam>\n";
echo " <awayTeam>".$value['awayTeam']."</awayTeam>\n";
echo " <comment>".htmlspecialchars($value['comment'])."</Comment>\n";
echo " <userID>".$value['userID']."</UserID>\n";
echo " </prono>\n";
$i++;
}
echo "</pronoData>\n";
break;
case 'top5':
$strQuery = "SELECT DISTINCT(matchID) FROM tblProno";
if ($blnUseC) $strQuery .= " WHERE countryID=$intCountryID";
if ($blnUseCon) $strQuery .= " AND continentID='$strContinentID'";
$strQuery .= " LIMIT 0,5";
$recResult = mysql_query($strQuery);
while ($row = mysql_fetch_assoc($recResult))
{
$arrProno[] = $row;
}
echo "<pronoData type=\"top5\"$strXmlAdd>\n";
$i = 0;
foreach ($arrProno as $value)
{
$arrTop3 = array();
$strQuery = "SELECT COUNT(*) as geraden, homeTeam, awayTeam FROM tblProno WHERE matchID=". (int) $value['matchID'];
if ($blnUseC) $strQuery .= " AND countryID=$intCountryID";
if ($blnUseCon) $strQuery .= " AND continentID='$strContinentID'";
$strQuery .= " GROUP BY homeTeam, awayTeam ORDER BY geraden DESC LIMIT 0,3";
$recResult = mysql_query($strQuery);
while ($row = mysql_fetch_assoc($recResult))
{
$arrTop3[] = $row;
}
echo " <prono index=\"$i\">\n";
echo " <matchID>".$value['matchID']."</matchID>\n";
echo " <mostPredicted>\n";
echo " <first>\n";
echo " <homeTeam>".$arrTop3[0]['homeTeam']."</homeTeam>\n";
echo " <awayTeam>".$arrTop3[0]['awayTeam']."</awayTeam>\n";
echo " </first>\n";
echo " <second>\n";
echo " <homeTeam>".$arrTop3[1]['homeTeam']."</homeTeam>\n";
echo " <awayTeam>".$arrTop3[1]['awayTeam']."</awayTeam>\n";
echo " </second>\n";
echo " <third>\n";
echo " <homeTeam>".$arrTop3[2]['homeTeam']."</homeTeam>\n";
echo " <awayTeam>".$arrTop3[2]['awayTeam']."</awayTeam>\n";
echo " </third>\n";
echo " </mostPredicted>\n";
echo " </prono>\n";
$i++;
}
echo "</pronoData>\n";
break;
case 'top3Prono':
$strQuery = "SELECT COUNT(*) as geraden, homeTeam, awayTeam FROM tblProno WHERE matchID=". (int) $_GET['matchID'];
if ($blnUseC) $strQuery .= " AND countryID=$intCountryID";
if ($blnUseCon) $strQuery .= " AND continentID='$strContinentID'";
$strQuery .= " GROUP BY homeTeam, awayTeam ORDER BY geraden DESC LIMIT 0,3";
$recResult = mysql_query($strQuery);
while ($row = mysql_fetch_assoc($recResult))
{
$arrProno[] = $row;
}
echo "<pronoData type=\"top3Prono\" matchID=\"". (int) $_GET['matchID'] ."\"$strXmlAdd>\n";
$i = 0;
foreach ($arrProno as $value)
{
echo " <prono index=\"$i\">\n";
echo " <homeTeam>".$value['homeTeam']."</homeTeam>\n";
echo " <awayTeam>".$value['awayTeam']."</awayTeam>\n";
echo " <timesPredicted>".$value['geraden']."</timesPredicted>\n";
echo " </prono>\n";
$i++;
}
echo "</pronoData>\n";
break;
case 'addProno':
echo "<pronoData>\n";
echo " <actionSuccesfull>";
foreach ($_POST as $key => $value)
{
$_POST[$key] = mysql_escape_string($value);
}
$intMatchID = (int) $_POST['MatchID'];
$intHomeTeam = (int) $_POST['HomeGoals'];
$intHomeTeam = (int) $_POST['AwayGoals'];
$strComment = $_POST['Comment'];
$intUserID = (int) $_POST['UserID'];
$intLeagueID = (int) $_POST['LeagueID'];
$strContinentID = $_POST['ContinentID'];
if (mysql_query("INSERT INTO tblProno ('', matchID, homeTeam, awayTeam, comment, userID, leagueID, continentID VALUES ('', $intMatchID, $intHomeTeam, $intAwayTeam, '$strComment', $intUserID, $intLeagueID, '$strContinentID')"))
{
echo "True";
}
else
{
echo "False";
}
echo " </actionSuccesfull>\n";
echo "</pronoData>";
break;
}
?>



Ik hoop dat iemand kan helpen

brossiekoppie
%Europe/Berlin %441 %2005, 11:35
Ik weet niet wat de bedoeling is van het naar een php te sturen om dan te outputten in xml-formaat.

Maar de foutmelding spreekt allesizns voor zich, je hebt in xml een allesomsluitende tag nodig (bvb. <pronostieken>blaat</pronostieken>)

Bij rss is dat bijvoorbeeld:

<?php
// header
header("Content-Type: text/xml");
?>
<rss version="2.0">
<channel>
en hier al je tags en inhoud
</channel>
</rss>

FredericCox
%Europe/Berlin %443 %2005, 11:37
Hoe doe ik dat dan in deze php? Zodat het correct werkt