Jump to content


Corporate Sponsors


Latest News: (loading..)

mysql_insert_id()


  • You cannot reply to this topic
2 replies to this topic

#1 BenCox

  • Community Member
  • 8 posts
  • Real Name:Ben Cox

Posted 05 April 2011, 08:18

Hello everyone,

I am in the process of developing a addon for oscommerce and i have come across a little problem, i need to use mysql_insert_id() and am having trouble doing so, i'm guessings its because of the new OO system and me not being 100% confident with it all yet. Anyway in my code i perform an insert into one table using the new database class then i tried to assign mysql_insert_id() to a var like this
$temp_box_id = mysql_insert_id();
and get the following error
Warning: mysql_insert_id() [function.mysql-insert-id]: A link to the server could not be established in

Could someone point in the direction to the proper way to get the id of the newly inserted row with the new database class please?

Many Thanks for reading.

#2 BenCox

  • Community Member
  • 8 posts
  • Real Name:Ben Cox

Posted 05 April 2011, 08:23

I also have another question, for my addon i need to manual insert records in the table_templates_boxes_to_pages table, how do i go about aquiring the relevant template_ids?

#3 BenCox

  • Community Member
  • 8 posts
  • Real Name:Ben Cox

Posted 05 April 2011, 10:13

ok, instead of mysql_insert_id() we can now use $osC_Database->nextID();

However i am still unsure how to handle the template id? Has anybody got any suggestions?