Jump to content

major_domo

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

major_domo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've not tried spreading { } across multiple documents. I keep them in the same file, so anyone reading my work can pick it up more easily, and bugs are simpler to track-down. If I have a dynamic header and footer file, but I'm not using a template class (usually don't, hate em all), I'll usually have a "mother" file specifying details for all of them. You might try something more like:[code]<?php // file name: motherfile.php, created by me when I made it. // specify which header & footer if ( foo ) {   $headerFile = 'header01.inc';   $footerfile = 'footer01.inc'; } else {   $headerFile = 'header02.inc';   $footerfile = 'footer02.inc'; } // specify which content $contentFile = 'about_us.inc'; $title = 'About Us'; // specify which content include_once('doctype_html_strict.inc'); ?>[/code] Then in the document doctype_html_strict.inc:[code]<?php // file name: doctype_html_strict.inc, created by me after I made the other one. ?> <DOCTYPE blah blah (real strict, I know)> <html>   <head><title><?=$title;?><title></head>   <body> <?php include_once( $headerFile ); ?> <?php include_once( $contentFile ); ?> <?php include_once( $footerfile ); ?>   </body> </html>[/code]
  2. Well, I figgured this out...and I'm answering my own question for anyone else searching for this problem. The example url I wrote didn't say everything there was to this. Here's a better example of what's happening:[code]$getstring = '?bar=words with spaces'; $action  = 'http://foo.com/12345/file.xml' . $getstring; $xml = simplexml_load_file( $action );[/code] Now obviously the spaces in $getstring need to be urlencode()ed, but newer versions of simplexml_load_file() handle that automatically, so the server response was coming back with the proper %20 in place of spaces:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http%3A//foo.com/12345/file.xml?bar=words%20with%20spaces" in /var/www/project/compare.inc on line 122[/quote] The problem is that the automatic urlencode() was also encoding the rest of $action, including the "http://" part. The new, working PHP looks like this:[code]$getstring = urlencode( '?bar=words with spaces' ); $action  = 'http://foo.com/12345/file.xml' . $getstring; $xml = simplexml_load_file( $action );[/code] Problem solved. I hope this helps someone else.
  3. [b]My problem:[/b] I'm having problems loading XML data from remote server. I don't think I can give away the exact XML url, because of the paperwork behind it, but suffice it to know that all this code works PERFECTLY on my workstation's development environment (Win 2k, Apache 1.3.x, PHP 5.1.2). I just can't get it to work on the live server (CentOS Linux, Apache 2.x, PHP 5.1.2) [b]Code:[/b] [code]$importantNumber = '12345'; $action  = 'http://foo.com/' . $importantNumber . '/file.xml';, $xml = simplexml_load_file( $action ); [/code] [b]Results:[/b] [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: simplexml_load_file(http://foo.com/12345/file.xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /var/www/project/compare.inc on line 122 Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http%3A//foo.com/12345/file.xml" in /var/www/project/compare.inc on line 122[/quote] In summary, the URL gets esccaped as 'http%3A//...', which results in the 400 error. And, yes, allow_url_fopen = On, and yes, I RTFM already Any one encounter this before?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.