close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

mysql_insert_id();

Thread began 5/23/2018 3:04 pm by vernon webb | Last modified 5/24/2018 8:00 am by Ray Borduin | 841 views | 3 replies |

vernon webb

mysql_insert_id();

When I wanted to get the last inserted record from a database I would enter the following:

$_SESSION['svClinetID'] = mysql_insert_id();

I am trying to do that with mysqli and it doesn't seem to work

$_SESSION['svClinetID'] = mysqli_insert_id($connIO_i);

Sign in to reply to this post

Ray BorduinWebAssist

There is a line in the insert code that will automatically save the insert id into the session. Line 47 you have:
$InsertQuery->saveInSession("customersID");

Just update that to:
$InsertQuery->saveInSession("svClinetID");

That will save the insert id into the session as $_SESSION['svClinetID']

You don't have to do this manually. (Delete the code you added on lines 27-30. Even if it had the correct syntax it wouldn't work because it is above the insert code. You can't get the insert id before the insert takes place.

Sign in to reply to this post
Did this help? Tips are appreciated...

vernon webb

I have done this and tried to redirect the the next page with that session as a URL variable (line 46) and tried to echo that variable to the next screen with no success. FYI, the database is setup for testing so submitting test values doesn't not matter.

Sign in to reply to this post

Ray BorduinWebAssist

Since you set the redirect url before the insert, the session variable hasn't been saved yet. To allow for this there is a special placeholder you can use in the redirect. Just set it to:

insert_client_contact.php?ID=[InsertID]

and that should automatically add the insertid to the redirect without having to save it at all.

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...