[SOLVED]Dynamic Link Causing script time out

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
clem_c_rock
Forum Commoner
Posts: 46
Joined: Mon Jun 07, 2004 9:18 am

[SOLVED]Dynamic Link Causing script time out

Post 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
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post 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 ); 
    } 
}
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

For starters, $action_property doesn't equal 'edit', it equals 'edit_property'.
clem_c_rock
Forum Commoner
Posts: 46
Joined: Mon Jun 07, 2004 9:18 am

Post by clem_c_rock »

Yeah that's what I meant 'edit_property'
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post 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>";

?>
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post 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?
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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.
clem_c_rock
Forum Commoner
Posts: 46
Joined: Mon Jun 07, 2004 9:18 am

Post 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
Post Reply