Error using mysql_insert_id( ) - call to undefined function
Moderator: General Moderators
Error using mysql_insert_id( ) - call to undefined function
I get this error when trying to use the mysql_insert_id( ) function:
Fatal error: Call to undefined function mysql_insert_id() in D:\\XXXXX\abc.php on line 127
Ok.....so in the php.ini file; yes i have extension=php_mysql.dll commented out using ";". BUT...when I uncomment this, I get the following error:
PHP Warning: PHP Startup: Unable to load dynamic library './php_mysql.dll' - The specified module could not be found. in Unknown on line 0
THEN....if I use the mysqli function: $id=$db_connection->insert_id( ), I get the following error:
Fatal error: Call to undefined method mysqli::insert_id() in D:\Splash_Solutions\Web_Pages\hb_info.php on line 127
(This has been asked by me in a seperate unrelated thread (something about php redirect) so please ignore the question in that thread. Cheers.
Fatal error: Call to undefined function mysql_insert_id() in D:\\XXXXX\abc.php on line 127
Ok.....so in the php.ini file; yes i have extension=php_mysql.dll commented out using ";". BUT...when I uncomment this, I get the following error:
PHP Warning: PHP Startup: Unable to load dynamic library './php_mysql.dll' - The specified module could not be found. in Unknown on line 0
THEN....if I use the mysqli function: $id=$db_connection->insert_id( ), I get the following error:
Fatal error: Call to undefined method mysqli::insert_id() in D:\Splash_Solutions\Web_Pages\hb_info.php on line 127
(This has been asked by me in a seperate unrelated thread (something about php redirect) so please ignore the question in that thread. Cheers.
- ambivalent
- Forum Contributor
- Posts: 173
- Joined: Thu Apr 14, 2005 8:58 pm
- Location: Toronto, ON
I believe your issue is addressed in the manual. Specifically, the installation notes.
In your php.ini file, make sure you uncomment the line marked 'extension=php_mysql.dll' (as you mentioned), as well as create a line 'extension=php_mysqli.dll'.
More importantly, make sure the extension_dir directive points to the actual extensions directory in your php install, e.g. 'c:/php/ext'
Restart your HTTPD server (Apache, most likely) and test it out.
More importantly, make sure the extension_dir directive points to the actual extensions directory in your php install, e.g. 'c:/php/ext'
Code: Select all
extension_dir=C:/php/ext ; or wherever you've installed php
; uncomment / create these lines
extension=php_mysql.dll
extension=php_mysqli.dll- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
in the directory that i originally installed php i have the following:
php5ts.dll;
libmysql.dll and;
php_mysqli.dll;
(plus of course a few empty folders and a few *.txt files and the *.exe file).
libmysql.dll and php_mysqli.dll are the things I got form either the php or mysql website which was supposed to fix all of the errors i seem to continuously encounter.
If I need this php_mysql.dll file where can I find it??
And do I simply put it into the same folder as the above *.dll files and uncomment it in the php.ini file??
Appreciate your help. Thanks
php5ts.dll;
libmysql.dll and;
php_mysqli.dll;
(plus of course a few empty folders and a few *.txt files and the *.exe file).
libmysql.dll and php_mysqli.dll are the things I got form either the php or mysql website which was supposed to fix all of the errors i seem to continuously encounter.
If I need this php_mysql.dll file where can I find it??
And do I simply put it into the same folder as the above *.dll files and uncomment it in the php.ini file??
Appreciate your help. Thanks
You don't have an 'ext' subdirectory? I'd be carefull downloading and arbitrarily sticking .dll files in your PHP install directory. What installation method did you choose?
This is how I install PHP5 under Windows..
This is how I install PHP5 under Windows..
- Download the .zip package
- Unzip to C:\php5
- Add C:\php5 to the PATH (see Google for 'set Windows PATH')
- Copy the C:\php5\php.ini-recommended file to C:\php5\php.ini
- Edit the php.ini file:
Code: Select all
;; extension directives extension_dir="C:/php5/ext" extension=php_mysql.dll extension=php_mysqli.dll ;; find other 'Windows' directives and set properly - Configure your HTTPD installation, if necessary, and restart
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
If you don't have php_mysql.dll then you cannot use the mysql_* functions. But it appears that you have the php_mysqli.dll, so I would use the mysqli_* functions instead. They are very similar to the mysql_* functions, but you have the option of using an object oriented approach as well.mcccy005 wrote:in the directory that i originally installed php i have the following:
php5ts.dll;
libmysql.dll and;
php_mysqli.dll;
(plus of course a few empty folders and a few *.txt files and the *.exe file).
libmysql.dll and php_mysqli.dll are the things I got form either the php or mysql website which was supposed to fix all of the errors i seem to continuously encounter.
If I need this php_mysql.dll file where can I find it??
And do I simply put it into the same folder as the above *.dll files and uncomment it in the php.ini file??
Appreciate your help. Thanks
The mysqli functions and a description of them can be found in the PHP Manual section on MySQLi.
hmm....for some strange reason; I've just mucked around with what you guys have said but haven't actually modified anything and now its all of a sudden working!!!
Guess if it 'aint broke, dont fix it'....thanks again.
One quick thing though....is it worth my while attemptint to install the mysql stuff or just stick with mysqli or is there some things the original mysql has that hasn't yet been implemmented into mysqli??
Cheers.
Guess if it 'aint broke, dont fix it'....thanks again.
One quick thing though....is it worth my while attemptint to install the mysql stuff or just stick with mysqli or is there some things the original mysql has that hasn't yet been implemmented into mysqli??
Cheers.
both work good, but in my testing I have found mysql is always faster than mysqli in straight query performance. But the added features in mysqli makes it nice, ya no more mysql_real_escape_string(). But to spend time converting code that works fine in mysql to get the added features is not really worth it for all cases. But if you have base class structure, then adding mysqli is very simple. I use mysqli for some projects where I need to use more of MySQL features, like triggers and prepared statements, when you use those features correctly you free up resources and make your whole application much faster, because you don't have to use direct execution, where MySQL has to rebuild the query every time you run it. But like I said, mysql is still much faster when doing a straight query, including JOINS, UNIONS, REGEXP and FULL TEXT searching as compared to mysqli!
pif!
pif!
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
There's no reason why you can't use both. mysqli is kinda the format of the future, offering both built-in OOP functionality and procedural flexibility. And I believe for PHP6 the speed/resource issues are going to be resolved. But either way, they both work fine. Right now if your apps are designed using a procedural style mysql_* interaction, I would load the php_mysql.dll and use that rather recoding your app. I would, however, seriously look into DB abstraction or the use of a DB class interface so in the future, if you are facing something like this, it will be as easy as changing an included file when it comes to getting the app back online.mcccy005 wrote:hmm....for some strange reason; I've just mucked around with what you guys have said but haven't actually modified anything and now its all of a sudden working!!!
Guess if it 'aint broke, dont fix it'....thanks again.
One quick thing though....is it worth my while attemptint to install the mysql stuff or just stick with mysqli or is there some things the original mysql has that hasn't yet been implemmented into mysqli??
Cheers.