mpksingh Posted October 11, 2007 Share Posted October 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72774-solved-php-code-inside-html-file/ Share on other sites More sharing options...
RichardRotterdam Posted October 11, 2007 Share Posted October 11, 2007 if you changed the file extension to .php and also called the php file you should recieve errors what errors do you recieve? Quote Link to comment https://forums.phpfreaks.com/topic/72774-solved-php-code-inside-html-file/#findComment-367017 Share on other sites More sharing options...
mpksingh Posted October 11, 2007 Author Share Posted October 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72774-solved-php-code-inside-html-file/#findComment-367033 Share on other sites More sharing options...
richardw Posted October 11, 2007 Share Posted October 11, 2007 htaccess can solve the problem. Take a look at this link: http://www.spiderpro.com/bu/buphph001.html Quote Link to comment https://forums.phpfreaks.com/topic/72774-solved-php-code-inside-html-file/#findComment-367067 Share on other sites More sharing options...
RichardRotterdam Posted October 11, 2007 Share Posted October 11, 2007 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; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/72774-solved-php-code-inside-html-file/#findComment-367339 Share on other sites More sharing options...
prime Posted October 11, 2007 Share Posted October 11, 2007 htaccess has nothing to do with this simple fact is your trying to calla function that doesn't exist Dj Kat is correct Quote Link to comment https://forums.phpfreaks.com/topic/72774-solved-php-code-inside-html-file/#findComment-367428 Share on other sites More sharing options...
mpksingh Posted October 24, 2007 Author Share Posted October 24, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72774-solved-php-code-inside-html-file/#findComment-376971 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.