Jump to content

file not reading nor outputing?


$php_mysql$

Recommended Posts

hi i tried to add this to my php file

 

<?php

$xfile = @file('banners.txt', "r");
$random_num = rand (0,count($xfile)-1);
$data = explode("::",$xfile[$random_num]); 
echo $data[1];

?>

 

i get no output

 

i then tried just including the txt file like

 

include 'banners.txt';

 

then everything in the txt file opens.

 

and if i use fopen like this

<?php

$xfile = fopen ('banners.txt', "r");
$random_num = rand (0,count($xfile)-1);
$udata = explode("::",$xfile[$random_num]); 
echo $udata[1];

?>

 

i get this error

 

Warning: fopen(banners.txt) [function.fopen]: failed to open stream: No such file or directory in /home/www/public_html/template/folder1/main.php on line 72

 

where as the txt file exist there

 

 

anyone could help solve my issue?

 

 

Link to comment
Share on other sites

try...

<?php
$file = "banners.txt";
$lines = file($file);
$random_num = rand (0,count($lines)-1);
$data = explode("::",$lines[$random_num]); 
echo $data[0] . "<br>";
echo $data[1];
?>

 

hey mate, tried u bit of codes but neh same thing i get this error message

 

Warning: file(banners.txt) [function.file]: failed to open stream: No such file or directory in /home/www/public_html/template/file1.php on line 74

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.