473,395 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

variable getting cleared on host, works fine locally

110 100+
I've got a php page which is outputing xml to a file.

The code has been working without a hitch for weeks when running as localhost, but a few days ago I uploaded it to my ec2 instance, and it doesn't seem to work.

the data is stored in $xml_output, and I've added the "echo xml_output" at the bottom of the page to see what the page is holding.

I can see that both servers are accessing the correct data from the
echo $name, $genre, etc. that I have put throughout the page.

On local host, echo $xml_output spits out the full page stream. on ec2, that is empty, even though the other variables along the way have not been.

File opens fine, sql connection isn't the issue, it seems that the xml_output is either being cleared or never adding the elements. VERY STRANGE

anybody seen this issue before with variable values not working? or disappearing?

Here is a subsection of the code.
Expand|Select|Wrap|Line Numbers
  1. $fh = fopen($m3xmlFile, 'w') or die("can't open file");
  2.  
  3. $xml_output = "";
  4. $xml_output .= "<cache>\n";
  5.  
  6.      while (list($key, $value) = each($y)) {
  7.       //Output the array key/value
  8.     $genreName = htmlentities($key, ENT_NOQUOTES);
  9. $xml_output .= "\t<genre>\n";
  10. $xml_output .= "\t\t<id>$value</id>\n";
  11. $xml_output .= "\t\t<name>$genreName</name>\n";
  12. $xml_output .= "\t</genre>\n";
  13.    }
  14.  
  15.  
  16. while($rowa = mysql_fetch_array($resulta, MYSQL_ASSOC))
  17. {
  18.  
  19. $name = htmlentities($rowa['name'], ENT_NOQUOTES);
  20. $specialCharReplace = array("&acute;", "&sect;", "&plusmn;", "—", "&laquo;", "„", "‚", "&cedil;", "&circ;", "&ring;", "…", ",,", "Š", "&acirc;", "‰", "ˆ", "‡", "Œ", "&tilde;", "&uml;", "&heart;", "&cent;", "&sup2;", "&cedil;", "&para;", "&copy;", "&trade;", "&not;", "&middot;", "&frac34;", "&macr;", "&iexcl;", "&curren;", "&sup3;", "&yen;");
  21. $name = str_ireplace($specialCharReplace, "", $name);
  22. $name = str_replace("ƒ", "", $name);
  23. $name = str_replace ("&Atilde;", "A", $name);
  24.  
  25. $xml_output .= "\t<artist>\n";
  26. $xml_output .= "\t\t<id>". $rowa['bid'] . "</id>\n"; 
  27.  $xml_output .= "\t\t<name>". $name . "</name>\n";
  28.     echo $name.'<br />';
  29. // do genre math
  30.  
  31. $genre = str_replace("/", "|", $rowa['genre']);
  32. echo $genre.'<br />';
  33. $gSplit = array();
  34. $gSplit = explode("|", $genre);
  35. $gSplit = array_unique($gSplit);
  36. print_r (array_unique($gSplit));
  37. $numarray = array();
  38.     foreach($gSplit as $gString) {
  39.  $genrenum = @$y[trim($gString)];
  40.     echo $genrenum.'<br />';
  41.  
  42.         array_push($numarray, $genrenum);
  43.     $numarray = array_unique($numarray);
  44.     $genreTotal = array_sum($numarray);
  45.  
  46. echo $genreTotal.'<br />';
  47. }
  48.  $xml_output .= "\t\t<genre>". $genreTotal ."</genre>\n";
  49.  
  50.    $xml_output .= "\t</artist>\n";
  51. }
  52. while($row = mysql_fetch_array($result, MYSQL_ASSOC))
  53. {
  54.  
  55.     $xml_output .= "\t<song>\n";
  56.     $xml_output .= "\t\t<id>". $row['sid'] . "</id>\n"; 
  57.     $xml_output .= "\t\t<data>". $row['mipid'] . "</data>\n"; 
  58.     $xml_output .= "\t\t<artist>". $row['bid'] . "</artist>\n"; 
  59.     $xml_output .= "\t\t<popularity>".$row['plays']."</popularity>\n";
  60. //    if ($row['genrenum'] != "0"){
  61. // $xml_output .= "\t\t<genre>". $row['genrenum'] ."</genre>\n";
  62. //    } else {
  63. //    $xml_output .= "\t\t<genre></genre>\n";
  64.  // }
  65.    $xml_output .= "\t</song>\n";
  66. }
  67.  
  68. $xml_output .= "</cache>";
  69.  
  70. echo $xml_output;
  71.  
  72. fwrite($fh, $xml_output);
  73. fclose($fh);
  74.  
  75.  
Nov 5 '07 #1
2 1398
ak1dnar
1,584 Expert 1GB
What is the operating system on your hosting server? is it same as your local server OS? I think this problem is occurs because of the line breaks. waiting for your response.
Nov 6 '07 #2
pedalpete
110 100+
The host is linux and my os is windows,
but this ended up being a configuration limiting the available file size that php can create on the host.

I added
Expand|Select|Wrap|Line Numbers
  1.  
  2. ini_set("memory_limit","100M");
  3.  
to the top of the page to get over the memory limit.

Hope fully somebody can find this useful in the future.
Nov 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ryan Stewart | last post by:
I'm running MySQL server on a WinXP box at home. I have a cable modem/router. I've set up port forwarding on port 3306 to the machine running MySQL. I can connect locally just fine, but when I try...
9
by: Martin Plantec | last post by:
Hello, I have managed (with your help!) to make a working XSLT stylesheet; it works fine locally (Windows Apache + PHP with Sablotron 1.0), but it fails on the remote host (FreeBSD Apache + PHP...
3
by: claus.hirth | last post by:
Does the term 'host variable' cover a variable locally declared in a SQL-PL stored procedure? I am asking this question in the context of the SELECT INTO statement.
2
by: hui | last post by:
Here is a problem I am having with web form designer. I have a database control in the form, and setup the connection string as a dynamic property. It compiles and runs fine. I close the aspx...
3
by: Michael Glass | last post by:
I'm working on an ASP.Net web app using VS2005 and the .Net 2.0 framework, and I have a serious problem with the page I'm currently working on. The page has, among other things, two FormViews and a...
2
by: mhadi | last post by:
Hi All, I am developing a solutions for clients to run some webpages. Since there is no webserver the ASP route is a No Go. So I am using Javascript to connect to my database. The Problem is that...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
2
by: Ben Wilson | last post by:
I've had the same web host (imhosted.com) for the past three years, and have had decent service. However, I'm also trying to learn Python the hard way--by doing. So, I figured I'd write a few...
2
by: Bob Bruyn | last post by:
I've recently installed Apache 2 and php 5.2 on my WIndows XP machine. Everything is up and running. I'm passing some vars via the URL. It works fine online:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.