Forums

curly brackets fields within php error

ahmedsheeraz 29 May, 2009
Hi all, have a question here. I am trying to run a code in CC body. what i am trying is just to get the file size of a file which name is stored in database table within field file_name.

<?php $a="images/stories/{file_name}"; $b=filesize($a) ?>

later in the code i am showing $b

<?php echo $b ?>

...and its a failure.

...but if i hardcode the file name in $a lets say "images/stories/myfile.zip" then its echo the file size correctly.

why is it not working with field name.
ahmedsheeraz 29 May, 2009

<?php $a="images/stories/{file_name}"; $b=filesize($a) ?>



ah...i got the answer..... $a should b "images/stories/$row->file_name"

thanx anywayzzzzz....chrono products are awesome....I promise to buy these products if i get something from my website.
ahmedsheeraz 29 May, 2009
...now i am looking to convert the result into mb as it is in bytes right now.
This topic is locked and no more replies can be posted.