PDA

View Full Version : Quick Variable Question



Colin-Roberts
11-02-2009, 09:27 PM
How would i make it so it inserts the data into the text file that matches $category.

like so:
$read = fopen("$category.txt", "r");
$contents = fread($read, filesize('$category.txt'));

but clearly proper way..

Joe!
11-02-2009, 09:48 PM
I think putting {} around the variable should make it work. so like fopen("{$category}.txt", "r") if that doesn't work, try fopen("".$category.".txt", "r")

Colin-Roberts
11-02-2009, 09:57 PM
Warning: filesize() [function.filesize (http://www.mini-roberts.com/tim/function.filesize)]: stat failed for ".$category.".txt in /home/chong08/public_html/mini-roberts.com/tim/adddef.php on line 53

Warning: fread() [function.fread (http://www.mini-roberts.com/tim/function.fread)]: Length parameter must be greater than 0 in /home/chong08/public_html/mini-roberts.com/tim/adddef.php on line 53

Joe!
11-02-2009, 10:01 PM
You changed the second line as well yeah?

Colin-Roberts
11-02-2009, 10:02 PM
yep, changed all 3 of them

Invent
11-02-2009, 10:05 PM
How would i make it so it inserts the data into the text file that matches $category.

like so:
$read = fopen("$category.txt", "r");
$contents = fread($read, filesize('$category.txt'));

but clearly proper way..



$read = fopen( $category . '.txt', 'r' );
$contents = fread( $read, filesize( $category . '.txt' ) );

Joe!
11-02-2009, 10:06 PM
well
$read = fopen("".$category.".txt", "r");
$contents = fread($read, filesize("".$category.".txt")); looks like it should work to me.. i'm not really sure how else to do it..

Colin-Roberts
11-02-2009, 10:16 PM
i'm just going do it all in mysql instead..

Joe!
11-02-2009, 10:22 PM
i'm just going do it all in mysql instead..
Much easier, nice choice.

Want to hide these adverts? Register an account for free!