Tuesday, 15 June 2010

php condition not working -



php condition not working -

i trying hide url on site based on status result of query either blank or equal upload/ can't seem create work.

i have mysql table has field called file, 1 user submit form, file field not required save "upload/" on database. example, if submit form twice, 1 file attachment , 2nd 1 without attachment, table this:

fileid | filename 1 | upload/file1.txt 2 | upload/

now, on page, want display result if there file uploaded can't seem create work. here i've tried:

if ($filename = "upload/" ) { echo "no file uploaded"; } else { echo "<div class='span2' style='padding-left:10px;'><a href='".$filename."'>download attachment</a></div>"; }

but echo'es out "no file uploaded" regardless if have file uploaded or not.

use equality operator == instead of =

if ($filename == "upload/" ) { echo "no file uploaded"; }else { echo "<div class='span2' style='padding-left:10px;'><a href='".$filename."'>download attachment</a></div>"; }

php

No comments:

Post a Comment