Well, my problem is quite strange, because it really doesn’t make sense.
1)I have a PHP script that brings a XML with some information stored in my MySQL database;
2)When I use this script (or any other) for the first time it brings me the all the information updated (all registries inserted ’til that moment);
3)When I use this script (or any other) again, no matter how many new registries i have in my database, it brings me only the registries that we’re brought the first time I used the script;
*I have tested this script on my browser, it works fine, always bringing the most updated state of the database.
What can I do?
Thx.
EDIT:
1) How I call the XML parser:
NSString *strURL = @"localhost/scripts/bringmethexml-x5.php";
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
XMLProcessor *processor = [[XMLProcessor alloc]initProcessor];
[processor syncProcessorWithData:dataURL];
NSMutableArray *a = processor.xmlObjects;
2) My PHP script:
<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"LATIN-1\"?>";
echo "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">";
echo "<plist version=\"1.0\">";
function getXML($sql="SELECT user FROM database.Posts"){
$conn = mysql_connect ("localhost", "user", "password");
$db = mysql_select_db("database");
$result = mysql_query($sql, $conn);
$column = "";
echo "<array>";
while($row = mysql_fetch_assoc($result)){
$column .= "<dict>";
foreach ($row as $key => $value){
$column .= "<key>$key</key>";
$column .= "<string>$value</string>";
}
$column .= "</dict>";
}
echo $column;
echo "</array>";
echo "</plist>";
}
getXML("SELECT user as USER, msg as MESSAGE, hashtag_1 as ST1, hashtag_2 as ST2, hashtag_3 as ST3, hashtag_4 as ST4, hashtag_5 as ST5, date as DATEPOSTED, coordinate_lat as COORLAT, coordinate_lon as COORLON FROM database.Posts;");
mysql_close();
?>
3) How my the XML gets out:
<?xml version="1.0" encoding="LATIN-1"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>(key || nome da fileira do db)</key>
<string>(valor||object)</string>
<key>(key || nome da fileira do db)</key>
<string>(valor||object)</string>
</dict>
<dict>
<key>(key || nome da fileira do db)</key>
<string>(valor||object)</string>
<key>(key || nome da fileira do db)</key>
<string>(valor||object)</string>
</dict>
</array>
</plist>
4) XMLProcessor is a parser I made, it gets the NSData from the NSURL and then turns it in to a string and i parse it to fit it in a NSMutableDictionary, here’s a link for the class:
An easy, if slightly hacky way of fixing this is to add a random variable to the url that you don’t really use for anything.
for example http://www.yourwebsite.com/somestuff.xml?random=343453
becasue the url is different each time, it will not use the cache.
you can also do it by adding an anchor: http://www.yourwebsite.com/somestuff.xml#623764527
Here’s a function to automate it, just apply it to your nsstring URLS