Jump to content

PHP changing an XML file


LifeKills

Recommended Posts

I have a flash vote counter I'm working on. it stores the vote totals in an XML document which gets inputted directly into flash which then increments the vote and uses a php script to change and save the data. my problem is I'm a complete noob to PHP, so I'm not even sure that this code is proper syntax or that my algorithm is even feasible:

 

savedata.php:

<?php

$adam=$_POST[Adam];
$rob=$_POST[Rob];
$page=$_POST[currurl];
$dom = new DOMDocument();
$dom->load('votes.xml');
$xpath = new DOMXpath($dom);

$adamtags = $xpath->query('Adam');
$robtags = $xpath->query('Rob');

$adamtags[$page]->nodeValue = $adam;
$robtags[$page]->nodeValue = $rob;

$dom->save('votes.xml');

?>

 

here's my ActionScript3 code that interacts with the PHP:

var phpFile:URLRequest = new URLRequest("savedata.php");
var variables:URLVariables = new URLVariables();

variables.Adam = adamcount;
variables.Rob = robcount;
variables.currurl = pagenum;

phpFile.data = variables;
phpFile.method = URLRequestMethod.POST;

 

the XML file is formatted like so:

<?xml version="1.0" encoding="utf-8"?>
<Votes>
<Adam>4</Adam>
<Rob>7</Rob>
<Adam>0</Adam>
<Rob>0</Rob>
</Votes>

 

please forgive my complete noobness

 

 

Link to comment
https://forums.phpfreaks.com/topic/180738-php-changing-an-xml-file/
Share on other sites

because I don't know a single thing about mysql or using mysql with flash, but I know how to use php and xml with flash. I know what I'm doing is possible, so I'd like to do it this way if I can find a simple solution. I can learn mysql once I get my site published, but I don't want to do that until I get this vote counter working

 

either way I'd have to use php, and I know more about xml than I do about mysql

 

unless you know of a tutorial that explains it nicely  :P

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.