Jump to content

bad PHP/MySQL code or slow server?


stone140

Recommended Posts

Hi - You all really helped me out last time but I have a question that hopefully someone can help me out with.

Which is the most likely case for my problem.

When going to my site it takes forever to load.  Once you are able to finally get in you can roam around the site without too much of a problem but its still slow.  When traffic is low you can get in but again, its slow.  I wrote the php / mysql code myself (i'm no professional) and i subcribe to DreamHost and have their basic plan.  It says i get 80 gigs of bandwidth a month.  Is it possible that they limit the amount able to be transfered at once or just that my coding sucks.  In my site I pull images from a server and pull items from my mysql database.  (usually only 1 or 2 queries a page). 
Link to comment
Share on other sites

Are the images on a remote server to the site? Not clear in your explaination.

Slow-downs can be a number of things. The best way to test is to see who long your script takes to execute. Do this like so (stolen from [url=http://www.php.net/microtime]www.php.net/microtime[/url]):

Put this at the beginning of your code:
[code]
<?php

// If you have PHP 5
$start = microtime(true);

// else
function microtime_float() {
  list($usec, $sec) = explode(" ", microtime());
  return ((float)$usec + (float)$sec);
}

$start = microtime_float();

?>
[/code]

Put this at the end of your code:
[code]
<?php

// If you have PHP 5
$time_taken = microtime(true) - $start;

// else
$time_taken = microtime_float() - $start;

echo "Time to execute script: ". $time_taken;

?>
[/code]


You'll probably find that the server is slow in delivering the page if the time it takes to execute the page is less than 0.2 seconds.
Link to comment
Share on other sites

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.