.htm and .php extension


some pages of my website have .php extension and other have .htm

Will this affect the downloading speed for visitors ?

No, but if you can work with PHP, do it. It will be much easier for templating

If your pages are just plain html there is no reason to work with PHP. It can’t provide anything for you but slow down your web site due to the extra resources it takes due to the php interpreter.

No there is no difference.

Yes, but the difference won’t be noticeable. By default, PHP parses all files with an .php extension before it sends the output to the browser. That means it checks for <?php tags and parses the content of them. (If any).

While .html files won’t be parsed by default. So they’re served directly.

You shouldn’t notice any difference in speed.

There is a big difference between php and html. It’s not the same type, so you can’t actualy ask .htm or .php.

make a website fast


I’m new to PHP and trying to make my website as fast as possible.

Is there any real difference in speed between including, say, an 9K file rather than a 60k file?

I’m precalculating database queries and wondering if I should save the results of each query in a separate file or whether they would be ok all in the same file.

Just to add to what krt said there is some overhead when doing includes opposed to having the code already there. Now is the overhead noticable? No not in most people’s cases. You’ll start to notice it when you’re including 50 files on one page.

No, the script is not downloading the pages, it is being done on the server and accessing files on the local filesystem is quick enough that the difference in cases like your one will be negligible.

As for what you are trying to do, I would suggest separate files to save processing when parsing through the larger file to get the data needed.

transaction support for mySQL.


I could not find any functions in PHP that provide transaction support for mySQL. So, are there any such functions available??

you can use the PEAR DB package: this includes interfaces for most common database.

he following PHP libraries & PEAR packages can fulfill your requirements.
mysqli, PDO, ADODB, PEAR DB & PEAR MDB2.

A site translator


Hi,

I am trying to use a site translator but i am having problems as my server does not accept the function file_get_contents.

Advance help for any help

If file_get_contents() is not supported/enabled, then neither is file(), it is most likely due to file handling functions being disabled for security reasons. Unless it is PHP4 < 4.3…

u can use direct links to the Google translator

Code:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=$lang&u=" . urlencode($_GET["u"]) . "&prev=/language_tools");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch);
curl_close($ch);
?>

encrypt the password


i need to encrypt the password and want to submit in the database so that whenever i am seeing the password it wants should be in the encrypted manner.
How can i do it?

In PHP use md5($password)

Depending on the database you’re using you could use the built in encryption.

if you’re using MySQL try this

Code:

UPDATE users SET password=md5('thepassword') WHERE user='theuser';

when your checking against a database to md5 the input aswell.

I would recommend using PHP md5() function .

You can also use base64_encode and base64_decode functions.

new password for forgotten password


while the user entering the username and password if he forget password
he wants to click the forget password link and he wants to get the new password by entering his emailid and username, so that he receive the new password in his mailid, if any body knows coding for this send me.

u can make classes for that purpose.

that would be very long coding, so use classes

Rather use phpBB/vbulletin.

error message below the text box


I want to display the error message below the text box in which
If I didnt enter any thing means the message Enter the Username and Enter the password wants to display below the Username and password textbox respectively

can anybody knows the script for this.

for that You will probably have to stick the error message in a session or in the url when you redirect.

for that You will probably have to stick the error message in a session or in the url when you redirect.

even then all you would need is a simple $_GET[] to determine if the user has showd up here in error. they goto the processing page after logging in, on an invalid pass they get sent back to login.php?q=e or something and voila, error.

slide show script


Hi,

Does anyone know of a simply slide show script that just have the image and then a previous and next button. Also it needs to run from a folder that i specify.

plz. help me

Try this, this will fulfill your requirement

Code:

<?php
$my_folder = "my_images";
$files = array();

if ($handle = opendir($my_folder))
{
    while (false !== ($file = readdir($handle)))
    {
        if ($file != "." && $file != "..")
            array_push($files,$file);
    }
    closedir($handle);
}
if ( isset($_GET['id']) )
    $id = $_GET['id'];
else
    $id = 0;

?>

<img src="<?=$my_folder."/".$files[$id];?>" alt="" /><br />

<?php
if ($id > 0)
    echo "<p style="width:200px; float:left;"><a href="".$_SERVER['PHP_SELF']."?id=".($id-1)."">Previous</a></p>";
else
    echo "<p style="width:200px; float:left;">Previous</p>";

if ($id <= count($files) - 2)
    echo "<p style="float:left;"><a href="".$_SERVER['PHP_SELF']."?id=".($id+1)."">Next</a></p>";
else
    echo "<p style="float:left;">Next</p>";