Announcement

Collapse
No announcement yet.

adding a include

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jalit
    replied
    It was a typo and I didn't catch it. Sorry.

    Leave a comment:


  • JP Stones
    replied
    guys top5.php is in the same dir as global.php and index.php etc.

    I have a bad feeling no one knows the problem....uh oh
    JP

    Leave a comment:


  • Dennis Wrenn
    replied
    Just to clear things up,

    Jalit:

    I don't think this will work:
    Code:
    require('filenamehere.php';)
    perhaps it was a typo?

    Code:
    require('filenamehere.php');
    Dennis

    Leave a comment:


  • MattR
    replied
    JP,

    You have to put the path to global.php if it is not in the same directory as your calling php file.

    Leave a comment:


  • JP Stones
    replied
    mrogish,
    I did require global PHP like so

    <?php
    $noheader=1;

    require("global.php");

    require("top5.php");

    and got:

    Fatal error: Failed opening required 'global.php' in global.php on line 4
    Dennis,
    global $DB_site; is already in global so that is not the fix.

    jalit,
    you mean I should try
    require('filenamehere.php' ? it is not done anywhere else on the page...?

    Thanks again, please keep te help coming.........
    JP


    [Edited by JP Stones on 09-26-2000 at 02:50 PM]

    Leave a comment:


  • MattR
    replied
    Actually Jalit, it works either way.

    Leave a comment:


  • Jalit
    replied
    -----
    require("filenamehere.php");
    -----
    should be
    -----
    require('filenamehere.php'
    -----

    and you can't use require in any string. you u want to put in and a string or something else, just use include.

    I hope that this helps.

    Leave a comment:


  • Dennis Wrenn
    replied
    I think I see your problem,
    is $DB_site declared in global.php??
    if so...
    add this

    Code:
    global $DB_site;
    That will make it global, I had this problem when trying to get an IP address using a require file...


    BTW:
    I tried using multi includes, what I mean is
    I have 3 files
    test.php - calls he() and hello(), has inc1 as a require.
    inc1.php - has he(), has inc2 as a require.
    inc2.php - has hello(), has no require.

    Leave a comment:


  • MattR
    replied
    You need to require( "global.php" ); because VB creates its' own database class. That is why you're getting the errors for each line that uses $DB_site. So keep global.php in there and life will be ok.

    If you don't want to do that, then you have to convert all of VB's nice packaging up into its' component parts.

    Leave a comment:


  • JP Stones
    replied
    I do this on index.php


    require("global.php");

    require("top5.php");
    and that works, but it did not when I added

    require("top5.php");
    I got the previous error.

    Whenn you say add the function into the page do you ean the contents of the top5.php page into global.php? If so I would rather not. Why is the inclde not working?

    What do you mean the code I use to access the db? This is the contents of top5.php.

    <?php
    $num = 5;

    $sql = "SELECT userid,username FROM user ORDER BY posts DESC LIMIT $num";

    $results = $DB_site->query($sql);

    while ($result = $DB_site->fetch_array($results))

    {

    $top5 .= "<FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <A HREF=\"member.php?action=getinfo&userid=$result[userid]\">$result[username]</A></FONT><BR>";
    }
    ?>
    Thanks a lot for your time Dennis, much apreciated!
    JP

    Leave a comment:


  • Dennis Wrenn
    replied
    Try adding the function into the page you want to use it in.

    does it work then?

    and if that doesn't work, then try adding

    Code:
    require("top5.php");
    if that doesn't work, post the code you have to access the DB. That might be the problem.

    Leave a comment:


  • JP Stones
    replied
    sorry should have specified.

    warning: object_db site not found in top5.php on line 5

    fatal error: member functions used on a non object in top5.php on line 5

    any idea?
    JP

    Leave a comment:


  • Dennis Wrenn
    replied
    What code are you using to access the DB, and what was the error that you got?

    Leave a comment:


  • JP Stones
    started a topic adding a include

    adding a include

    Hi all, I have a file called top5.php and I want it to work on all the templates. I was told putting require("top5.php"); in the global.php would solve this, I did this though and got a DB error. What am I doing wrong?

    cheers
    JP

Related Topics

Collapse

  • cymode
    Fatal Error method.php on line 170
    by cymode
    Code:
    Fatal error: Uncaught exception 'Exception' with message 'invalid_query_parameters for getHelpLength' in /...../htdocs/forum/core/vb/db/query/method.php:170 Stack trace: #0 /....../htdocs/forum/core/vb/db/assertor.php(263):
    ...
    Sat 6 Oct '12, 12:25am
Working...
X