TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   time out issues with this script (http://www.talkphp.com/advanced-php-programming/4824-time-out-issues-script.html)

russellharrower 08-07-2009 10:04 AM

time out issues with this script
 
Code:

$quary = @$_GET['q'];

$query = "SELECT COUNT(id) as num FROM ph WHERE sitename LIKE '%".$quary."%' OR keywords LIKE '%".$quary."%' OR title LIKE '%".$quary."%' OR body LIKE '%".$quary."%' OR writtenby LIKE '%".$quary."%'";

while($row = mysql_fetch_array($result))
                {
       
        $post = substr($row['body'],$position,1); // Find what is the last character displaying. We find it by getting only last one character from your display message.

        if($post !=" "){ // In this step, if last character is not " "(space) do this step .

        // Find until we found that last character is " "(space)
        // by $position+1 (14+1=15, 15+1=16 until we found " "(space) that mean character 20)
        while($post !=" "){
        $i=1;
        $position=$position+$i;

        $post = substr($row['body'],$position,1);
        }

        }

        $post = substr($row['body'],0,$position); // Display your message
       
        print $row['sitename'];
        echo "<br/>";
        echo $post;
        echo "...";
        echo "<br/><br/>";
        }
        ?>

<?=$pagination?>


However for some reason when I type run the following "Development Blog" in q=Development Blog i get this error

Fatal error: Maximum execution time of 90 seconds exceeded in /home/example/public_html/search.php on line 202

In the ph table the column sitename has the word Development Blog, however I am getting that time out error, can any one help?

JaoudeStudios 08-07-2009 10:37 AM

Maximum execution time is set in the php.ini file. But 90sec is quite a long time to display a blog list!

russellharrower 08-07-2009 01:56 PM

I have worked out that there is an error with this part of the script
Code:

$position=11; // Define how many characters you want to display.

$message="Jooria Refresh Your Website";
$post = substr($message,$position,1); // Find what is the last
character displaying.
We find it by getting only last
 one character from your display message.

if($post !=" "){ // In this step,
 if last character is not " "(space) do this step .

// Find until we found that last character is " "(space)
// by $position+1 (14+1=15, 15+1=16 until
 we found " "(space) that mean character 20)
while($post !=" "){
$i=1;
$position=$position+$i;

$message="Jooria Refresh Your Website";
$post = substr($message,$position,1);
}

}

$post = substr($message,0,$position); // Display your message
echo $post;
echo "...";
?>

What it should do, is find if the last character is a space if not it moves one more till it finds that space.

Is there an error with this?
As it works, expect when searching for a sitename for some reason.

russellharrower 08-07-2009 02:44 PM

Fixed the error, however need some help

Code:

<?php

 
                while($row = mysql_fetch_array($result))
                {
                $sitename = $row['sitename'];
                $title = $row['title'];
                $body = $row['body'];
                }
               
                $position=300; // Define how many character you want to display.

        $post = substr($body,$position,1); // Find what is the last character displaying. We find it by getting only last one character from your display message.

        if($post !=" "){ // In this step, if last character is not " "(space) do this step .

        // Find until we found that last character is " "(space)
        // by $position+1 (14+1=15, 15+1=16 until we found " "(space) that mean character 20)
        while($post !=" "){
        $i=1;
        $position=$position+$i;

        $post = substr($body,$position,1);
        }

        }

        $post = substr($body,0,$position); // Display your message
       
        print $sitename;
        echo "<br/>";
        echo $post;
        echo "...";
        echo "<br/><br/>";
       
       
        ?>

Now my issue is this part of the code needs to be duplicated

Code:

        print $sitename;
        echo "<br/>";
        echo $post;
        echo "...";
        echo "<br/><br/>";

Is there any way to do this?

Thanks


All times are GMT. The time now is 09:52 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0