Hello every body,

I created some pages for downloading files directly from my website
But i have problem with adding download link in php tags so is there any body to tell me how i can make download link inside the php tags.

i wrote some things like this :

$sql=mysql_query("select * from ebook where id='$id' ");
$row=mysql_fetch_array($sql);
$file=$row;
<a href="files/<? $file ?>.rar" onclick="someJSfunction()">Download here</a> but i doesn't work correctly...

please help me with this problem !

Member Avatar

diafol

<a href="files/<?php echo $file; ?>.rar" onclick="someJSfunction()">Download here</a>

<a href="files/<?php echo $file; ?>.rar" onclick="someJSfunction()">Download here</a>

My,dear
as i said it doesn't work correctly...

Member Avatar

diafol

Well you don't state what exactly doesn't work correctly, so it's difficult to know what to do. Do you get any error messages? What does the browser's view source give you? You've been using short php tags (<? ...?>) which is never a good idea and you haven't been echoing anything inside them.

<?php echo ...;?>

Is what you need. If you insist on using short tags, this is the syntax you need:

<?= ... ?>

<a href="files/<?php echo $file; ?>.rar" onclick="someJSfunction()">Download here</a>
i was put this code
so there is the result :

Not Found

The requested URL /New www/4.3.2011/Project/mynewworld/admin/ebook/files/394123 Flash Menu.rar.rar was not found on this server.

i do not know what to do ...

Member Avatar

diafol

You've got space characters in your filename. You also don't need to append .rar to the end of the file. Sort out your filenames.