Results 1 to 3 of 3

Thread: Functions in Included file not being seen by PHP

  1. #1
    Join Date
    Mar 2009
    New York City

    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:


    //*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());
    $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.
    {$sqlstring="select * from component where key1=$key";
    $poo=mysql_query($sqlstring) or die(mysql_error());
    if($action =="delete")

    dbupdate("delete from component where key1=$key");



    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.

  2. #2
    Join Date
    Nov 2008
    Put the include statement at the top.

  3. #3
    Join Date
    Mar 2009
    New York City


    I tried putting the include above the other stuff previously, but it wasn't quite at the top. This worked. Thank you so much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles