Page 1 of 1

$line=fgets($info,1024);

Posted: Thu Dec 02, 2004 6:37 am
by giaCo
Hi there, i am attempting to manipulate a string. However, when i use the line:

$line=fgets($info,1024);

I am getting the error:
Warning: Supplied argument is not a valid File-Handle resource in /home/public_html/test.php on line 37

Any ideas why this might be happening? the syntax looks right to me!

Any help would be greatly appreciated!!!!

Posted: Thu Dec 02, 2004 6:39 am
by []InTeR[]
What are you try'ing to do?

fgets reads chars from a file, that you first must open with fopen (or something else).

What's in info? And what do you want to have in $line?

Posted: Thu Dec 02, 2004 6:46 am
by giaCo
Basically its a parser, it takes a BibTex format from a text box and passes it into my function, but i am passing it as a variable not a file- do you know how to turn the contents of a text box box into a file to pass? or is there a version of fgets() for vairables?

AS you can tell I am extremely new to this and trying to adapt someone elses code!

thanks for ur help!

Posted: Thu Dec 02, 2004 6:50 am
by []InTeR[]
Please referer to the PHP-Manual first.

I think you want to have $line = $info; or something?

Posted: Thu Dec 02, 2004 7:22 am
by giaCo
Ok, thanks for your help and for pointing me in the right direction, I really appreciate it!! :)

Posted: Thu Dec 02, 2004 3:26 pm
by rehfeld
do you NEED to parse line by line?

if so, heres how to split the data up into lines

Code: Select all

$data = $_POST['data'];

$lines = explode("\r\n", $data);

foreach ($lines as $line) {
     // parse 1 line at a time
}