Jump to content

Find insert id for CURRENT insert


bschultz

Recommended Posts

I"m working on importing my existing website (with a custom cms) into a wordpress system.  I'm trying to insert all of my current posts...and need to know what the insert id is for the WP system.

 

I know that mysql_insert_id will get the key of the LAST query...but is there a way to get the id of the CURRENT query?

Link to comment
https://forums.phpfreaks.com/topic/265915-find-insert-id-for-current-insert/
Share on other sites

You cannot get a current insert_id with standard ways.  You could predict it by grabbing the last_id and adding one, but that's not guaranteed either.  The best way to do it is to create a blank record when you're adding something and then updating that when you're finished.  You could set the status of it to -1 or 9 or what-have-you so that abandoned entries are not picked up - and later run a small cron script that will remove all the abandoned posts.

OK...got that working.  Now, I need to fix slashes.

 

The old system (which I wrote a LONG time ago) used addslashes to the posts.  When I import that into the new Wordpress Database...it has slashes echoed in everything. 

 

So, does anyone know where I can add STRIPSLASHES in the WP code (I'm VERY new to WP)...

 

or how can I strip the slashes from my select...before I insert into the WP table?

 

I tried to:

 

$stripslashes= stripslashes($row['story']);

 

But the insert failed at every quote in the original post.

 

Thanks!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.