macromedia.dreamweaver.appdev
[Top] [All Lists]

Re: PHP/MySQl/Apache

Subject: Re: PHP/MySQl/Apache
From: "Craig"
Date: Fri, 2 Nov 2007 00:04:44 -0000
Newsgroups: macromedia.dreamweaver.appdev

David,
ok, so the code is actually part of a string and thus not executed. Fair 
enough.
So then the obvious question surely is how do you execute a piece of code if 
the 'call' to the function is in a database field?
After-all, html code can be put in a field, but rendered as proper html 
(such as links for example) without the html code (<a href etc) being 
displayed.

FYI: The 'human' function displays either 'kb' or 'm' depending on the file 
size and executes perfectly.

Craig


"David Powers" <david@xxxxxxxxxxx> wrote in message 
news:fgdmad$i55$1@xxxxxxxxxxxxxxxxxxxxxxxx
> Craig wrote:
>> Basically, I would have thought that there is no difference between the 
>> code (<?php getFileSize('cover.pdf') ?>) being embeded in the page or 
>> embeded in the page via the database. Surely its the same thing?
>
> No, it's not. It's part of a string. You're simply displaying the PHP code 
> snippet, not executing it.
>
> Your code is rather convoluted, and the human() function doesn't make any 
> sense to me. I suggest the following:
>
> function getfilesize($file) {
>   $path = 'docs/'.$file;
>   if (file_exists($path) && is_readable($path)) {
>     $size = filesize($path);
>     echo 'The file you wanted is '.number_format($size/1024, 1).' KB.';
>   }
>   else {
>     echo 'No such file exists.';
>   }
> }
>
> -- 
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/ 



<Prev in Thread] Current Thread [Next in Thread>