This is driving me crazy.
I’ve put a couple of functions in an include file for a utility program that I’m writing for myself. If the functions are just written straight into the program they work like a charm. I remove them from the program and use include() or require() the script can’t find them.
I know that they’re included because I put an echo (which has been removed from the script below) into one of them and the text appeared, but the script bombed when it tried to access them.
I include them in the exact same spot they would have resided had I just left the code in the script.
Here’s the code:
<?php
//*This function resets the sort order in any table
//
//*for example, if you’re updateing a table that represents //
//* you would put “where parentkey=num”
function sortorderUpdate($table,$sort_order,$wherec)
{
$sqlstring=”select key1, sort_order from $table where sort_order>=$sort_order $wherec order by sort_order”;
$poo = mysql_query($sqlstring) or die(mysql_error());
$w=$sort_order;
while($row=mysql_fetch_array($poo))
{if((int)$row[‘sort_order’]==$w)
{$w++;
$sting=”update $table set sort_order=”.$w.” where key1=”.(int)$row[‘key1’];
mysql_query($sting) or die(mysql_error());
} }
}
//*this function just sends an sqlstring to a mysql query.
function dbupdate($sqlstring)
{ $upit=mysql_query($sqlstring) or die(mysql_error());
}
?>
And, here’s the snipped of code which includes the file.
<?php
if($action==”update”)
{$sqlstring=”select * from component where key1=$key”;
$poo=mysql_query($sqlstring) or die(mysql_error());
$row=mysql_fetch_array($poo);
$name=$row[‘name’];
$description=$row[‘description’];
$sortorder=$row[‘sort_order’];
$dothis=”action=modify&key=$key”;
$action=”Modify”;
}
if($action ==”delete”)
{
dbupdate(“delete from component where key1=$key”);
$action=”Add”;
$dothis=”action=insert&key=”;
}
include(“fileupdate.php”);
?>
That’s not all of the code, by the way. It’s just the area in which the file has been included.
I’ve also used “require()” to do this and it didn’t pop an error.
Mind you, I have other include files that I use and they work just fine.
I’m doing this on my windows machine which runs ISS.
Thanks for any help. I’m sure it’s something stupid that I’m just missing.