PDA

Click to See Complete Forum and Search --> : Xml with file_get_contents


chunk
Jul 24th, 2010, 12:41 AM
Hi,
please help me why this $url does not work with file_get_contents


<?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

http://site.com/xml/student_name=name&fathername=father


and this is very long URL

TheBigB
Jul 24th, 2010, 06:09 AM
Always read the notes in the PHP manual when you use a function you haven't used before.
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.

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.

chunk
Jul 25th, 2010, 02:52 PM
still does not work. i have seen all these values in phpinfo and they all are enable

kows
Jul 25th, 2010, 04:07 PM
post the actual URL you're trying to open.