Jump to content

Archived

This topic is now archived and is closed to further replies.

stone140

bad PHP/MySQL code or slow server?

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). 

Share this post


Link to post
Share on other sites
unless you've got some heavy sql queries with large databases and joins, it's your host that's slow.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.