Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://bit.ly/phpmsql" rel="nofollow"><strong>Please, don't use <code>mysql_*</code> functions in new code</strong></a>. They are no longer maintained <a href="http://j.mp/XqV7Lp" rel="nofollow">and are officially deprecated</a>. See the <a href="http://j.mp/Te9zIL" rel="nofollow"><strong>red box</strong></a>? Learn about <a href="http://j.mp/T9hLWi" rel="nofollow"><em>prepared statements</em></a> instead, and use <a href="http://php.net/pdo" rel="nofollow">PDO</a> or <a href="http://php.net/mysqli" rel="nofollow">MySQLi</a> - <a href="http://j.mp/QEx8IB" rel="nofollow">this article</a> will help you decide which. If you choose PDO, <a href="http://j.mp/PoWehJ" rel="nofollow">here is a good tutorial</a>.</p> <hr> <p>You can use the MySQL function <a href="http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_last-insert-id" rel="nofollow"><code>LAST_INSERT_ID()</code></a> to do this.</p> <p>The old ext/mysql extension exposes this functionality through <a href="http://php.net/mysql-insert-id" rel="nofollow"><code>mysql_insert_id()</code></a>, but you can also access it directly, and more cleanly and safely, in a query.</p> <p>So you can do something like this:</p> <pre><code>$result = mysql_query(" UPDATE ptb_users SET ptb_users.user_id = ptb_users.id, ptb_users.account_type = 'Client' WHERE id = LAST_INSERT_ID() "); </code></pre> <hr> <p>I know you say "it's a long story..." but what you are doing makes little-to-no sense. I can only imagine you are doing this because of a trigger - and that demonstrates quite nicely why triggers are generally a bad idea ;-)</p> <p>Please try and re-think your design if at all possible.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload