Jump to content

Recommended Posts

Dear moderator,

 

I have the following test page in our site http://www.guwahatichessassociation.com/wcchap07_anand_wins12345.htm wherein the following php codes are inserted.

 

<a href="download.php?anand01.wsz">Download file</a><br>File Size: <?php echo download_size('anand01.wsz'); ?><br>Download Count: <?php echo download_count('anand01.wsz'); ?>

 

<a href="download.php?anand02.wsz">Download file</a><br>File Size: <?php echo download_size('anand02.wsz'); ?><br>Download Count: <?php echo download_count('anand02.wsz'); ?>

 

<a href="download.php?anand03.wsz">Download file</a><br>File Size: <?php echo download_size('anand03.wsz'); ?><br>Download Count: <?php echo download_count('anand03.wsz'); ?>

 

They show up correctly in the page. But, the file size is not shown and when a file is downloaded, the auto count does not work.

 

On contacting the script writer, the following reply was received.

 

Hi

 

The page you mentioned you were testing on is a HTML page (.htm extension).  PHP scripts will only work inside PHP pages, this would be why the script is not working for you.  However, if you have some sort of htaccess mod_rewrite that makes your PHP pages show up as HTML pages, then you musn't have the files in the right location.

 

That's all the help I can give.

 

Regards

Simon Stenhouse

 

After this, I changed the htm extension to php and uploaded the file. It still does not work. I am a beginner in site making and hence in a fix what to do and how to proceed.

 

Could you please enlighten me with the correct way so that the script works fine?

 

mpksingh

Link to comment
https://forums.phpfreaks.com/topic/72774-solved-php-code-inside-html-file/
Share on other sites

Dear forum helper,

 

The following is the error message which shows up in the page.

 

Fatal error: Call to undefined function: download_size() in /home/guwahati/public_html/wcchap07_anand_wins12345.php on line 212

 

and the worst is that the page height ends with this message.

 

Regards,

 

mpksingh

 

Fatal error: Call to undefined function: download_size() in /home/guwahati/public_html/wcchap07_anand_wins12345.php on line 212

 

Now that's something we can work with and indeed that shows up on http://www.guwahatichessassociation.com/wcchap07_anand_wins12345.php

 

this error means that your calling the function download_size() on line 212 of your file wcchap07_anand_wins12345.php

 

but this function does not exist you need this function included on your php page it would look something like the following

 

<?php
function download_size(){
    //some stuff to get the download size or anyhing
    return $downloadSize;
}
?>

  • 2 weeks later...

Hi everybody,

 

Thanks a lot to you all for your active participation in the topic and trying to help me out. The problem has now been solved at my end. I have been trying for it for all these days and happy to see the solution.

 

First, I added the following line in my .htaccess

 

AddType x-httpd-php .php .htm .html

AddHandler application/x-httpd-php .php .htm .html

 

Second, The following php code was added at the top just before the <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

 

<?php

the related code

?>

 

And third, changed the file extension from htm to php and uploaded it.

 

The result is : see it here : http://www.guwahatichessassociation.com/wcchap07_anand_wins.php

 

You all wanted me to see my success and it is your help that has made it happen.

 

My hearty thanks and gratitude to you all!!!

 

Best regards,

 

mpksingh

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.