ident_current scope_identity and @@identity need help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drayarms
Forum Contributor
Posts: 134
Joined: Fri Dec 31, 2010 5:11 pm

ident_current scope_identity and @@identity need help

Post by drayarms »

I tried to use the each of the three functions mentioned in the subject line in the following query and kept getting error messages.

Code: Select all

$query = "INSERT INTO blogs (blog_id, member_id, title, entry, blog_date) VALUES (0, @@IDENTITY('members'), '{$_POST['title']}', '{$_POST['entry']}', NOW())";


Here are the error messages I got for each of the 3 respective functions:

Code: Select all

Could not add the entry because: FUNCTION a7522929_dbs.IDENT_CURRENT does not exist. The query was INSERT INTO blogs (blog_id, member_id, title, entry, blog_date) VALUES (0, ident_current('members'), 'We have go so this is your house.', 'Mami Ngeh.', NOW()).


Could not add the entry because: FUNCTION a7522929_dbs.SCOPE_IDENTITY does not exist. The query was INSERT INTO blogs (blog_id, member_id, title, entry, blog_date) VALUES (0, ident_current('members'), 'We have go so this is your house.', 'Mami Ngeh.', NOW()).


Could not add the entry because: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('members'), 'We have go so this is your house.', 'Mami Ngeh.', NOW())' at line 1. The query was INSERT INTO blogs (blog_id, member_id, title, entry, blog_date) VALUES (0, @@IDENTITY('members'), 'We have go so this is your house.', 'Mami Ngeh.', NOW()).
What could possible be going wrong? Seems to me like the functions are deprecated. Any help is appreciated.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: ident_current scope_identity and @@identity need help

Post by Weirdan »

You are trying to use MSSQL functions on a MySQL server. What you need is likely mysql_insert_id() function (it's PHP function though, you shouldn't use in the query itself).
Post Reply