Results 1 to 4 of 4

Thread: Xml with file_get_contents

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Xml with file_get_contents

    Hi,
    please help me why this $url does not work with file_get_contents

    Code:
    <?php
     
    include("connx.php");
    $id = $_GET['id'];
    $id = (int) $id;
      $sql = "SELECT * FROM tbl_table WHERE id='$id'";
      $res = mysql_query($sql);
     	$row = mysql_fetch_row($res);
     	$url =  $row[2];
     
    
      $cont = file_get_contents($url);  
     echo '<xmp>' . $cont . '</xmp>';
    
     
     
    ?>
    the URL is something like
    Code:
    http://site.com/xml/student_name=name&fathername=father
    and this is very long URL

  2. #2
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: Xml with file_get_contents

    Always read the notes in the PHP manual when you use a function you haven't used before.
    Quote Originally Posted by PHP.net Reference: file_get_contents
    A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the List of Supported Protocols/Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.
    Quote Originally Posted by PHP.net Reference: Runtime Configuration
    allow_url_fopen boolean

    This option enables the URL-aware fopen wrappers that enable accessing URL object like files. Default wrappers are provided for the access of remote files using the ftp or http protocol, some extensions like zlib may register additional wrappers.

    Note: This setting can only be set in php.ini due to security reasons.
    If I'm not mistaken Safe Mode affects this setting. Disabling it should allow the code to execute properly.
    Last edited by TheBigB; Jul 24th, 2010 at 06:13 AM.
    Delete it. They just clutter threads anyway.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: Xml with file_get_contents

    still does not work. i have seen all these values in phpinfo and they all are enable

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Xml with file_get_contents

    post the actual URL you're trying to open.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width