+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Class 'mysqli' not found?

  1. #1
    Tarzan is offline x10Hosting Member Tarzan is an unknown quantity at this point
    Join Date
    Jun 2008
    Location
    Sweden
    Posts
    65

    Class 'mysqli' not found?

    I've experienced a strange error the last weeks.
    When I try to use the mysqli class in a cron job (located outside of the public_html folder) I get an error message.

    First, the log file says
    "PHP: Error parsing /usr/local/lib/php.ini on line 786"
    then, later where I try to instantiate a mysqli object an error
    "Fatal error: Class 'mysqli' not found in /home/tarzan/public_html/(database class I use).php on line X" where X = the line where I use "new mysqli".

    The strange thing is that I works perfectly when I use the database class on the public web page.
    Does anyone know what the problem is or have any idea of what I can do? It seems like I've had it since around 7th of April so it has been working before...

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Class 'mysqli' not found?

    The PHP processor used for cron jobs is the command line PHP processor, which is separate from that used by Apache. It's possible that the cli PHP wasn't built with the mysqli extension. You can run a cron job making use of extension_loaded get_loaded_extensions to check this.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    vv.bbcc19's Avatar
    vv.bbcc19 is offline Community Advocate vv.bbcc19 is just really nice
    Join Date
    Jun 2010
    Location
    India
    Posts
    1,505

    Re: Class 'mysqli' not found?

    I think you need to use MySQLi Prepared Statements
    If you need further Information,follow This
    Quote Originally Posted by Tarzan View Post
    I've experienced a strange error the last weeks.
    When I try to use the mysqli class in a cron job (located outside of the public_html folder) I get an error message.

    First, the log file says
    "PHP: Error parsing /usr/local/lib/php.ini on line 786"
    then, later where I try to instantiate a mysqli object an error
    "Fatal error: Class 'mysqli' not found in /home/tarzan/public_html/(database class I use).php on line X" where X = the line where I use "new mysqli".

    The strange thing is that I works perfectly when I use the database class on the public web page.
    Does anyone know what the problem is or have any idea of what I can do? It seems like I've had it since around 7th of April so it has been working before...
    BCV | Community Support Representative
    █ x10Hosting - Giving Away Hosting Since 2004
    Premium Hosting | VPS Services

  4. #4
    Tarzan is offline x10Hosting Member Tarzan is an unknown quantity at this point
    Join Date
    Jun 2008
    Location
    Sweden
    Posts
    65

    Re: Class 'mysqli' not found?

    mission:
    That sounds reasonable. Thanks! They did some configuration and didn't include mysqli in the command line php. I'm thinking of actually writting my "own" mysqli class for the cron job, with the methods I need. Not nice but at least a workaround until a better solution comes along

    vv.bbcc19:
    I can't unfortunatly see how prepared statements would help me? I followed the link you gave me and read about it. It still seems that you need to start off by creating a mysqli object tho', and that's where my code fails in the cron job.
    Last edited by Tarzan; 04-22-2011 at 10:55 AM.

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Class 'mysqli' not found?

    If you're not unafraid of coding and PDO is available, I'd recommend using it instead of mysqli. It's supposed to replace mysqli, and is a little nicer to use, due to some additional features (such as supporting the Traversable interface, prepared statement results don't need to be bound, and it supports keyword parameters in addition to positional parameters in prepared statements).
    Last edited by misson; 04-22-2011 at 07:47 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  6. #6
    Tarzan is offline x10Hosting Member Tarzan is an unknown quantity at this point
    Join Date
    Jun 2008
    Location
    Sweden
    Posts
    65

    Re: Class 'mysqli' not found?

    Haven't heard about that one, thanks for the tip!
    I'm actually thinking that the error is something bigger. I've noticed a few other things:
    - I'm not able to use the "mb_strtoupper" function.
    - No GD library seems to be loaded (e.g., can't use "imagecreate" as before).

    So I suspect that "PHP: Error parsing /usr/local/lib/php.ini on line 786" has something to do with it. But I guess I can't edit the php.ini file myself can I? I've posted in the support forum, but still no response at all there...

  7. #7
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Class 'mysqli' not found?

    That is indeed a worrisome error. I'll escalate the other thread so an admin will take notice. If you haven't tried it yet, this is something that might be good to bring to IRC.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  8. #8
    Tarzan is offline x10Hosting Member Tarzan is an unknown quantity at this point
    Join Date
    Jun 2008
    Location
    Sweden
    Posts
    65

    Re: Class 'mysqli' not found?

    Thanks man! That's probably the thing that's been bugging me the whole time.

    I saw you closed the thread, so they'll probably contact me when they're done, right?

  9. #9
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Class 'mysqli' not found?

    Escalating automatically closes the thread. You'll get a response from an admin in the support section of the X10 control panel.

  10. #10
    Tarzan is offline x10Hosting Member Tarzan is an unknown quantity at this point
    Join Date
    Jun 2008
    Location
    Sweden
    Posts
    65

    Re: Class 'mysqli' not found?

    Since this is the newest thread in this forum (otherwise I hate bumping) and others may be interested I might as well ask here:
    Do you know how long it normally takes to get an answer on a low priority escalation?
    It's been a week now since you escelated my thread without any reply.

+ Reply to Thread
Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 04-18-2011, 02:01 PM
  2. Fatal error: Class 'ZipArchive' not found
    By jkotni6 in forum Programming Help
    Replies: 6
    Last Post: 10-02-2009, 12:01 PM
  3. NetMenu.class not found?
    By gh0st75 in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 07-08-2009, 03:43 PM
  4. Class 'PDO' not found
    By crazy4records in forum Free Hosting
    Replies: 2
    Last Post: 05-18-2009, 06:11 AM
  5. Class 'SoapClient' not found
    By bobby77 in forum Free Hosting
    Replies: 2
    Last Post: 09-30-2008, 11:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers