fread fails to read...

Discussion in 'PHP' started by ignas2526, Jan 20, 2009.

  1. #1
    Hello,
    for unknown reason fread fails to read content from another php file on the same server...
    Code of reading script:
    
    $url='website.com/script.php';
    $v='1.1';
    if($handle=fopen($url."?s=s&v=$v[0]$v[2]","r")){
    	$new=fread($handle,2);
    	fclose($handle);
    }
    PHP:
    Wan i visit from browser
    website.com/script.php?s=s&v=11
    Code (markup):
    i get '13' in content, but reading script outputs me '3'.
    Any ideas what i did wrong?
    Thanks.
     
    ignas2526, Jan 20, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Make sure fopen/fread are enabled.

    Maybe try: if($handle=fopen($url."?s=s&v={$v[0]}{$v[2]}","r")){

    You could also try file_get_contents($url.'?s=s&v='.$v[0].$v[2]);
     
    jestep, Jan 20, 2009 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Try prepending http:// to the URL.
     
    Danltn, Jan 20, 2009 IP