Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 3 of 3

Thread: [PHP CLI] Including files

  1. #1
    jw06's Avatar
    657
    posts
    Registered User

    [PHP CLI] MySQL Functions

    I'm making some scripts to do some basic mysql database updates and I was wondering if I can use include and require in them. I'm including in this case, a class file. Here is the code I have so far.

    PHP Code:
    #!/usr/bin/php4 -q 
    <?php
    $dbc 
    mysql_connect('localhost''****''****');
    $select mysql_select_db('omniboggle');
    require(
    '../class/harvestclass.php');
    if (
    $dbc){
        if (!
    $select){
            
    print_r(Error);
            
    #exit();
        
    }
    } else {
        
    print_r(Error);
        
    #exit();
    }

    $query "SELECT * FROM urls";
    if (
    $r mysql_query($query)) {
        while (
    $row mysql_fetch_array ($r)) {
            
    $url $row['url'];
            
    $gather = new Harvest_Keywords($url);
            
    $gather->process();
            
    print_r(Success$url);
        }
    } else {
        
    print_r(Error);
        exit();
    }

    mysql_close()
    ?>
    The Error:
    Parse Error: parse error in /home/omniboggle/www/spider/supdatespider.php on line 21.

    Line 21 is: $gather->process();

    Again, this script is being run from command line and not through a web page. I'm curious if this problem could have anythign to do with maybe I cant use mysql functions in the PHP CLI? Is there a way to check if its enabled or i need to add it or something of the sort.

    Thanks for the help!
    Last edited by jw06; February 26th, 2005 at 07:48 PM.

  2. #2
    jw06's Avatar
    657
    posts
    Registered User

    **UPDATE**

    It seems to be the mysql functions. I fixed the parse error. Now its giving me the error: Fatal Error: Call to undefined function: mysql_connect() in /home/omniboggle/www/spider/updatespider.php on line 2.

    How can I fix this? I have the php4-mysql module loaded.

  3. #3
    jw06's Avatar
    657
    posts
    Registered User
    bump?

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
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012