/    Sign up×
Community /Pin to ProfileBookmark

Functions in Included file not being seen by PHP

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
//*
send the table, the sort order and any extra “where clause;
//*for example, if you’re updateing a table that represents //*subsets of another table (like the photo galleries)
//* 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.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiFeb 15.2010 — Put the include statement at the top.
Copy linkTweet thisAlerts:
@J2NYCauthorFeb 15.2010 — I tried putting the include above the other stuff previously, but it wasn't quite at the top. This worked. Thank you so much.
×

Success!

Help @J2NYC spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...