473,800 Members | 2,613 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

variable getting cleared on host, works fine locally

110 New Member
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 1428
ak1dnar
1,584 Recognized Expert Top Contributor
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 New Member
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
9014
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 to connect from a remote location using: mysql -h xxx.xxx.xxx.xxx -P 3306 -u root -p mysql I get: ERROR 2003: Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (10061) When I try:
9
4798
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 with Sablotron 1.0) with the following: Warning: Sablotron error on line 1: XML parser error 4: not well-formed (invalid token) in /...host...path.../page.php on line 28 FAILURE : XML parser error 4: not well-formed (invalid token) ; error
3
6830
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
2243
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 file, reopen it, and then have an error message in task list: "\\xxx\wwwroot$\xxx\xx.aspx.cs(68): The variable 'configurationAppSettings' is either undeclared or was never assigned" I open the code-behind file, and find out the trouble spot at the...
3
3880
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 GridView control, each with its own SqlDataSource. FormView1 talks to my Opportunity table and has an ItemTemplate and an EditItemTemplate. FormView2 talks to my Activities table and has an ItemTemplate, InsertItemTemplate and an...
2
21274
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 the following Connection string var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Data.mdb"; Search of Data.mdb on the desktop. I came to know that this requires absolute path i.e var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data
20
7016
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 = document.getElementById('hometab'); Has anyone ever seen anything like this before, or am I dreaming?
2
1127
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 Python CGIs (non-Zope). Unfortunately, my web host does not have mod_python. They only way I can run a python script is by using the .cgi extension. I'm not sure if I want to stick with my host and just call my apps index.cgi, or if I should move to a...
2
3449
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: http://www.torusdesign.nl/spry/test.php?folder=schilderijen/vrij_werk&navColor=SchilderijenNAV This is the code: <?php echo $folder; ?> <?php echo $navColor; ?>
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10036
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9092
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.