G
gingar

  • Jan 14, 2009
  • Joined Oct 27, 2005
  • Hi guys,

    i've got a site that i did up in english. Sent it over to my client, and she translated a chinese version. The chinese version worked for a while, but it had some layout problem, cause it was run in php5 and i used lazy tags, after i switched the tags over to the normal tags, it displayed ok on my server. Then when she uploaded it to her server, the page refused to load, showing this error.

    Content Encoding Error

    The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.

    the only thing i can think of is the inclusion of ob_start("ob_gzhandler"); in the header include files.

    Does it not support <meta http-equiv="Content-Type" content="text/html; charset=gb2312">?

    please advise!
    Thanks!

    • Hi NogDog,

      thanks for your input, i tried your suggestion, but i still get the same short reply.

      puzzled 😕

      very frustrating.. :mad:

      • im really stuck here.. cannot see the problem.. anybody can help?

        how come when i use a standalone program to submit the exact same xml string to the same url, using post, i get this reply.

        <body><version>3.91</version><opCode>OP_AREAS_LIST</opCode><country ID="27"><item name="Aachen, Germany" ID="13547" coreID="0"/><item name="Augsburg, Germany" ID="4408" coreID="0"/><item name="Bad Homburg, Germany" ID="5867" coreID="0"/><item name="Baden-Baden, Germany" ID="229" coreID="0"/><item name="Bautzen, Germany" ID="5889" coreID="0"/></country></body>

        but when i use the below code, i get this instead?
        <body><version>3.91</version><opCode>OP_OK</opCode></body>

        is there something wrong with the way i'm executing the code?

        • but that's not the response that i'm expecting to get.. strange.. sighz

          • What does it mean when the vendor says 'Can you please confirm that you are sending XML over HTTP?'

            He doesn't know php, and i'm an XML noob. lol

            At present, i'm using curl to do it. I am able to send the xml query over, and get a response. but the response is not what i am expecting. I should receive a list of whatever i requested, but all i'm receiving is this.

            <body><version>2</version><opCode>OP_OK</opCode></body>

            this is the code i'm using to send the xml

            $url = "http://xxx";
            $xml = '<?xml version ="1.0" encoding="UTF-8"?>
            			<root>
            				<header>
            					<protocol>1</protocol>
            					<oem>xx</oem>
            					<agentID>xxx</agentID>
            					<password>xxxx</password>
            				</header>
            				<body>
            					<opCode>XX_AREAS_XX</opCode>
            					<item name=”ANTALYA” ID=”5” />
            					<item name=”JERUSALEM” ID=”1” />
            				</body>
            
            		</root>
            	';
            
            $ch = curl_init();
            
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, 'xml=' . $xml);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $content = curl_exec($ch); #this returns html
            

            anyone can help me?

            • djjjozsi,
              the xml changes are not within my control, from third party, i assume it could be anything between 1 min and 20mins?

              Weedpacket,
              i'm displaying them on the fly.. so adding to temporary database is not feasible?

              oh dear.. any ideas?

              • oh, the xml sources are not under my control.. .

                and i have to pull from the xml sources cause certain info are real time..

                so database would be faster than array?

                • Hi guys.

                  Here's the scenario.

                  I'm pulling info (property details) from 4 different xml sources. The sources may contain the same property, but different details, say for example, source A has got phone numbers of property A, source B has got addresses and emails of property A, source C has got images of property A etc. I need to combine them and display them uniformly on my site.

                  Like
                  property A,
                  address,
                  phone,
                  email,
                  image etc,

                  instead of

                  property A,
                  phone

                  property A,
                  address,
                  email

                  property A,
                  image

                  Besides this combining of details, I also need to be able to sort the list by alphabetical order, as well as value of the property.

                  Would inserting into a temporary table and retrieving the data be faster?
                  Or would assigning everything into a multi-dimensional array, and using array sorting be faster for displaying purposes?

                  The data can be 1 record or up to 300 records..

                  Also, which one will be able to facilitate paging better?

                  Any one able to suggest anything? Or has anything better in mind? Please guide me!

                  Thanks!

                  • could it be..

                    that the xml request i sent.. although i sent once, they returned 3 times, that's why the code ran 3 times?

                    • Hi guys,

                      i've got this file, that takes in form values, called by a form on the previous page.

                      In this file, i collect the form values, and string them together to form a request string for an xml request, which will return me a string of response. After i receive this response, i will insert an entry (response and time inserted) into my database.

                      After which, an email will be sent out, regardless if the response returned and error or a success message. Then redirects the user to a thank you page.

                      This process has been working fine for a couple of months now, until yesterday, i discovered, this page inserted a log into my database 3 times, @ 2008-10-02 14:12:15, 2008-10-02 14:12:16 and 2008-10-02 14:12:17! all 1 ms apart. User claimed she did not refresh the page.

                      It seemed that the xml query was submitted 3 times, i got 3 duplicate entries in my database and emails sent out.

                      The same thing happened again today, with a different user. No codes have been changed. Other than the 2 incidents, the code is still working fine for the other users.

                      This one has got me stumped. Any idea what could have caused this?

                      • thanks guys for the replies/suggestions.

                        its actually a search results for properties, pulled from 4 different xml strings. So its actually easier for users to see all the properties on 1 page rather than having to click next next next to get to the property that they want, and every time they click next, i have to go retrieve all the results from the 4 suppliers and format it all over again, as the information has to be real time.

                        Would paging really be a better idea?

                        Would echoing the results during loop actually display the results to screen before the array has been fully processed? I was under the impression that nothing gets displayed to screen until the info is ready to be displayed! :p

                        • Hi guys,

                          I've a page that will at times display up to hundreds of results on a single page.

                          I've the info stored in an array, so i loop through the array and write it to a $result, and display it after the looping is done.

                          Is there anyway that I can force display the result to the screen before i finish looping through the array?

                          This would be helpful so the user doesn't stare at a blank screen waiting for the page to load!

                          • this is the code that calls the pop up window.

                            <a onclick="NewWindow('product_infonew.php?products_id=5676&type=&ac=2gvs0ewjeuatis2006hoqgf', 'width=500,height=400')" style="cursor: pointer;"><img src="../images/small_view.gif" width="49" height="15" border=0 alt=""></a>

                            this is the code in the popup window.. i removed the display code..

                            <?php
                            
                              ob_start("ob_gzhandler"); 
                              require('inc_database.php');
                              require('inc_settings.php');
                            ?>
                            <html>
                            <head>
                            <link rel="stylesheet" type="text/css" href="style.css">	
                            <script src="functions.js"></script>
                            <script language="javascript"><!--
                            function popupWindow(url) { window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=500,screenX=150,screenY=150,top=150,left=150')
                            }
                            //--></script>
                            
                            </head>
                            <body onload="this.focus();">
                            <table border="0" width="100%" cellspacing="0" cellpadding="0">
                            	<tr>
                            		<td width="100%" valign="top" align="center" bgcolor="#ffffff">
                            			<?
                            				$product_info_query = "select * from products where products_id = '123'";
                            
                            			$rs = mysql_query($product_info_query);
                            			$product_info = mysql_fetch_array($rs);
                            			$numrows = mysql_num_rows($rs);
                            
                            			$to_replace = array('\\', '\'', '\"', '/');
                            			$country = str_replace($to_replace, "-", $product_info['fldNameCountry']);
                            			$city =  str_replace($to_replace, "-", $product_info['fldNameCity']);
                            
                            			if ($numrows < 1) {
                            				echo 'none found';
                            			} else {
                            
                            			mysql_query("update products_description set products_viewed = products_viewed+1 where products_id = '" . (int)$_GET['products_id'] . "'");
                            				//display record info
                            			}
                            		?>
                            	</td>
                            </tr>
                            </table>
                            
                            • I've got this site that displays a list of properties from database using php.

                              Each property has got an 'info' button that pops up a window, that displays the property's info, also retrieved from database using php.

                              Here's the problem, using IE 7, when the listing page is still loading, i click the 'info' button for a property that has already been loaded, the window pops up and gives me an error page! says no internet connection/problem displaying page. Only when i click on the 'info' after the listing page has completed loading, does the 'info' window load.

                              However, when I do the exact same thing, using Firefox, the 'info' window loads just fine, even when the listing page hasn't completely finished loading!

                              Any thoughts on this one?

                              • Hi guys,

                                is it possible to have an array of objects?

                                would an array of objects load faster than an array by itself?

                                it seems like i have this piece code that takes ages to load.
                                It gets info from 2 different xml sources, as well as from my own database, formats the data and displays it onscreen.

                                The 2 xml sources claim their data is gzipped, so i'm thinking, could be my coding problem. I'm looping through the arrays, and access my database (different tables) a few times within the loop.

                                Could this be the problem?

                                • hi guys,

                                  I've got form, that contains a country dropdown list, and a city dropdown list the populates when the country is selected via ajax.

                                  The entire form interface works, meaning when I select the country, the city displays correctly. However, I am not able to retrieve the value from the city drop down list when the form is submitted!

                                  I've got 2 separate forms that require this country-city drop down selection. Both codes are roughly the same. 1 works in ie but not firefox. the other doesn't work in both ie n firefox!

                                  Any idea why?

                                  this is the form code

                                  <tr>
                                  		<td class="main" valign="top">Country</td>
                                  		<td class="main" valign="top">:</td>
                                  		<td>
                                  			<select name="country_id" onChange="showCountry(this.value);">
                                  				<?
                                  					$query1="SELECT id,country_name FROM country order by country_name asc";	
                                  					$rscountry1 = mysql_query($query1);
                                  
                                  				if (@mysql_num_rows($rscountry1) != 0 )
                                  				{
                                  					while($row1 = mysql_fetch_array($rscountry1))
                                  					{
                                  						$country_id = $row1['id'];
                                  						$country_name = $row1['country_name'];
                                  						?>
                                  						<option value="<?=$country_id?>" <? if($country_id==$sel_country_id) { print "selected"; } ?>><?=$country_name?></option>
                                  						<?
                                  					}
                                  				}
                                  			?>
                                  		</select>
                                  	</td>
                                  </tr>
                                  <tr>
                                  	<td class="main" valign="top">City</td>
                                  	<td class="main" valign="top">:</td>
                                  	<td>
                                  		<span id="optionCity">
                                  
                                  			<select name="city_id">
                                  				<?
                                  					$query1="SELECT id, city_name FROM city WHERE country_id = '$sel_country_id' order by city_name asc";	
                                  					$rscountry1 = mysql_query($query1);
                                  
                                  					if (@mysql_num_rows($rscountry1) != 0 )
                                  					{
                                  						while($row1 = mysql_fetch_array($rscountry1))
                                  						{
                                  							$city_id = $row1['id'];
                                  							$city_name = $row1['city_name'];
                                  							?>
                                  							<option value="<?=$city_id?>" <? if($city_id==$sel_city_id) { print "selected"; } ?>><?=$city_name?></option>
                                  							<?
                                  						}
                                  					}
                                  				?>
                                  			</select>
                                  
                                  		</span>
                                  	</td>
                                  </tr>

                                  this is the ajax code

                                  var xmlHttp;
                                  
                                  function showCountry(str)
                                  {
                                  	if (str.length==0)
                                  	{ 
                                  		replace_html("optionCity", "");
                                  		return;
                                  	}
                                  	xmlHttp=GetXmlHttpObject()
                                  	if (xmlHttp==null)
                                  	{
                                  		alert ("Your browser does not support AJAX!");
                                  		return;
                                  	} 
                                  
                                  var url="ajax_get_city.php";
                                  url=url+"?q="+str;
                                  url=url+"&sid="+Math.random();
                                  xmlHttp.onreadystatechange=selectChanged;
                                  xmlHttp.open("GET",url,true);
                                  xmlHttp.send(null);
                                  } 
                                  
                                  function selectChanged() 
                                  { 
                                  	if(xmlHttp.readyState==3)	//The request is in process
                                      {
                                  		show_progressbar("optionCity");
                                  		//replace_html("optionCity", "loading..."); 
                                      }
                                  	if (xmlHttp.readyState==4)	//The request is complete
                                  	{ 
                                  		replace_html("optionCity",""); 
                                  		replace_html("optionCity", xmlHttp.responseText); 
                                  	}
                                  }
                                  
                                  
                                  function GetXmlHttpObject()
                                  {
                                  	var xmlHttp=null;
                                  	try
                                  	  {
                                  	  // Firefox, Opera 8.0+, Safari
                                  	  xmlHttp=new XMLHttpRequest();
                                  	  }
                                  	catch (e)
                                  	  {
                                  	  // Internet Explorer
                                  	  try
                                  		{
                                  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                                  		}
                                  	  catch (e)
                                  		{
                                  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                                  		}
                                  	  }
                                  	return xmlHttp;
                                  }
                                  
                                  function show_progressbar(id) 
                                  {
                                  	replace_html(id, '<img src="4.gif" border="0" alt="Loading, please wait..." />');
                                  }
                                  
                                  function replace_html(id, content) 
                                  {
                                  	document.getElementById(id).innerHTML = content;
                                  }
                                  

                                  this is the getcity.php code. basically just returns a <select>...</select>

                                  $sql_city = "SELECT city_name, id FROM city where $country_id='".$country_id."' order by city_name";
                                  
                                  
                                  echo '<select name="city_id2">';
                                  
                                  $rs_city = mysql_query($sql_city) or die(mysql_error());
                                  while ($row = mysql_fetch_assoc($rs_city))
                                  {
                                  	echo '<option value="'.$row['id'].'">'.$row['city_name'].'</option>';
                                  }
                                  
                                  echo '</select>';
                                  • well.. not exactly a suggestion list.. like in a textbox ..

                                    its more like display search results as and when the server returns it to the browser...

                                    instead of at the end, after the server finishes sending back the results.

                                    • hi guys,

                                      I need to display a search results page, most of the time, many records are returned. How do I make it display records as soon as I have formatted it for display instead of waiting for all the records and displaying it in one short?

                                      not sure if you know what I mean, like skype or msn searching for contacts, once it finds a matching contact, it will display while still searching for other potential contacts.

                                      How do I do this using php?

                                      • hi guys,

                                        I need to display a search results page, most of the time, many records are returned. How do I make it display records as soon as I have formatted it for display instead of waiting for all the records and displaying it in one short?

                                        not sure if you know what I mean, like skype or msn searching for contacts, once it finds a matching contact, it will display while still searching for other potential contacts.

                                        How do I do this using php?

                                        oops posted in wrong thread.. repost in php help thread instead. SORRY!