Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

What am i missing it's driving me crazy

Posted on 2012-09-02
3
Medium Priority
?
461 Views
Last Modified: 2012-09-02
What i am trying to do is read the xml files and check the ver numbers and see if the user need to update.


<?php
$checkfile = "settings.xml";
$updatefile = "updates.xml";
$xmlcheck = simplexml_load_file($checkfile);
$xmlupdate = simplexml_load_file($updatefile);

$cnum = $xmlcheck->title->ver;


foreach($xmlupdate->title as $title)
{
	if($title->attributes()->name == "ACTIVE-extras-blue")
	
	{
		
		
		if($cnum >= $title->ver )
			{
				echo "yes you need to update";
				
			} else 
			
			{
				echo "no you don't need to update";
				
			}
		
	}
	
	
}

?>

Open in new window


every time i run it it always goes to no updates. I tryed >= and <=
settings.xml
updates.xml
0
Comment
Question by:armasmike
3 Comments
 
LVL 32

Expert Comment

by:DrDamnit
ID: 38359738
Right at the point where you are checking the version, what does var_dump () show you? I suspect that out may be treating the values add a string not a number.
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 38359750
Try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
$checkfile = "settings.xml";
$updatefile = "updates.xml";
$xmlcheck = simplexml_load_file($checkfile);
$xmlupdate = simplexml_load_file($updatefile);
$cnum = $xmlcheck->title->ver;
echo $cnum."<br>";
foreach($xmlupdate->title as $title)
{
	if($title->attributes()->name == "ACTIVE-extras-blue") {
		echo $title->ver."<br>";
		if((int)$cnum < (int)$title->ver)	{
				echo "yes you need to update";
			} else 	{
				echo "no you don't need to update";
			}
	}
}
?>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:armasmike
ID: 38359764
that worked thank you
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question