Class 'mysqli' not found?

Tarzan

New Member
Messages
66
Reaction score
0
Points
0
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...
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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.
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
I think you need to use MySQLi Prepared Statements
If you need further Information,follow This
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...
 

Tarzan

New Member
Messages
66
Reaction score
0
Points
0
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:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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:

Tarzan

New Member
Messages
66
Reaction score
0
Points
0
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...
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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.
 

Tarzan

New Member
Messages
66
Reaction score
0
Points
0
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?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Escalating automatically closes the thread. You'll get a response from an admin in the support section of the X10 control panel.
 

Tarzan

New Member
Messages
66
Reaction score
0
Points
0
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.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
It varies, depending on how busy the admins are. There are only a few, and many free users clamoring for attention. Looking at my own requests, it's generally been within a day, though a few were over a week. Try IRC and see if you can get the ball rolling. Just be nice, despite any frustration you may be feeling.
 

Tarzan

New Member
Messages
66
Reaction score
0
Points
0
They're probably pretty busy right now since nothing has happened for over two weeks. Thanks for the IRC tip by the way, even if I've got nothing out of it so far (they haven't been able to help me).

Is there anyone on starka who uses mysqli in a cronjob? Or could try it out?
When I try to create a mysqli object, I just get an error saying that the 'mysqli' class is not found.
(I would also appreciate if someone had the time to try "mb_strtoupper" function, which makes a string uppercase, since it doesn't work for me either - in cron jobs that is)
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I just read a notice from the 5th that one of the (few) people who provides support for the free servers got a day job. I'll post a message for the admins and see if anyone with proper access can take a look.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
The thread "All Free Server Updates" in the News and Announcements sub-forum mentions that some extensions were mistakenly left out of the cli PHP and will be added back, though it doesn't say if the ones you're using are among them. It looks like the admins are aware of the issue, they've just been too busy with administrative tasks.
 

Tarzan

New Member
Messages
66
Reaction score
0
Points
0
Thanks very much for all the help!

I found this in the error_log in my home directory:
Code:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

It's logged every time I try to run the cron job so I guess it has something to do with it. I'll keep my fingers crossed...
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Corey (the head honcho here at X10) posted a follow-up in the All Free Server Updates thread. It turns out the delay is due to the fact the admins can't compile their own copy of php–it's distributed as part of cPanel. They've had their own support request with cPanel, and a fix has just come in. They'll be testing it out tonight. If it works, it will hopefully be in place tomorrow. Check again then. If it still isn't working, it's basically a matter of checking every so often (~ twice a day, at a guess) and monitoring that other thread.
 

Tarzan

New Member
Messages
66
Reaction score
0
Points
0
It's working again! Thanks for all the help, you can deescalate anything escalated.

I don't know how to close my support request since the thread is already closed.
 

Tarzan

New Member
Messages
66
Reaction score
0
Points
0
I didn't find a way to close it from the account panel unfortunately.

What is even more unfortunate is that the problem is back. Since the May 20 I havn't been able to use the mysqli class in my cron job again. I read the free server updates but didn't find anything there. Does someone know what's been happening?
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
mission:
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.
Ahah..
OK.I thought they would help you as knowing them would open better horizons in your working with similar events.
Anyway..hope your problem gets solved.Let me look at that again.
 
Top