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
clem_c_rock
Forum Commoner
Posts: 46 Joined: Mon Jun 07, 2004 9:18 am
Post
by clem_c_rock » Tue Jun 08, 2004 9:49 am
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... » Tue Jun 08, 2004 10:01 am
Just so I can read 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>
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... » Tue Jun 08, 2004 10:02 am
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 » Tue Jun 08, 2004 10:11 am
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 » Tue Jun 08, 2004 10:11 am
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... » Tue Jun 08, 2004 10:21 am
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?
launchcode
Forum Contributor
Posts: 401 Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:
Post
by launchcode » Tue Jun 08, 2004 11:59 am
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 » Tue Jun 08, 2004 12:58 pm
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