Page 1 of 1

[SOLVED]Dynamic Link Causing script time out

Posted: Tue Jun 08, 2004 9:49 am
by clem_c_rock
Hello,

I have a reletively straightforward script that is causing a strange script time out. When I use this link:

Code: Select all

<a href="<?=$PHP_SELF ?>?property_id=<?=$property_id ?>&page=<?=$page ?>&action_property=edit_property&menu_action=property_admin" >Edit Property </a>
it is calling a mysql Select in this form

Code: Select all

if( $action_property == 'edit' )
{ 
        $select = "select * from property where property_id= $property_id";
        $result = mysql_query( $select );
        while( $row = mysql_fetch_array )
        {
              extract( $row );
        } 
}
Seems pretty straight forward but I can't seem to figure out why it's timing out.

Thanks for your help,
Clem C

Posted: Tue Jun 08, 2004 10:01 am
by Grim...
Just so I can read it:

Code: Select all

&lt;a href="&lt;?=$PHP_SELF ?&gt;?property_id=&lt;?=$property_id ?&gt;&amp;page=&lt;?=$page ?&gt;&amp;action_property=edit_property&amp;menu_action=property_admin" &gt;Edit Property &lt;/a&gt;

Code: Select all

if( $action_property == 'edit' ) 
{ 
    $select = "select * from property where property_id= $property_id"; 
    $result = mysql_query( $select ); 
    while( $row = mysql_fetch_array ) 
    { 
        extract( $row ); 
    } 
}

Posted: Tue Jun 08, 2004 10:02 am
by Grim...
For starters, $action_property doesn't equal 'edit', it equals 'edit_property'.

Posted: Tue Jun 08, 2004 10:11 am
by clem_c_rock
Yeah that's what I meant 'edit_property'

Posted: Tue Jun 08, 2004 10:11 am
by magicrobotmonkey
i think this is weird let me try to fix it...

Code: Select all

<a href="<?=$PHP_SELF ?>"property_id="<?=$property_id?>" &page=<?=$page?> &action_property=edit_property&menu_action=property_admin" >Edit Property </a>
although i would prefer

Code: Select all

<?php
echo"<a href="$PHP_SELF"&property_id="$property_id"&page="$page"&action_property="edit_property"&menu_action="property_admin" >Edit Property </a>";

?>

Posted: Tue Jun 08, 2004 10:21 am
by Grim...
I don't think that echo code would work. I would use:

Code: Select all

<?php
print "<a href="".$PHP_SELF."&property_id=".$property_id."&page=".$page."&action_property=edit_property&menu_action=property_admin">Edit Property</a>"; 
?>
Anyway... What line of the code does PHP say it's timing out on?

Posted: Tue Jun 08, 2004 11:59 am
by launchcode
It'll time out because of your while loop. You need to tell mysql_fetch_array which resource result to use:

Code: Select all

while( $row = mysql_fetch_array($result) )
        {
              extract( $row );
        }
Otherwise it'll sit in that loop for ever.

Posted: Tue Jun 08, 2004 12:58 pm
by clem_c_rock
I figured it out! It was coming from a eternal while loop in an include file. It was weird because the script was saying it was timeing out before the include. Thanks for your help all.


It's always something that's not obvious until you ask for help!

Cheers,

Mr Rock