mysql_insert_id ON mysql_insert
3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 14, 2014 (RSS)
By Djulia - October 14, 2014 - edited: October 14, 2014
Hi,
I would like to use mysql_insert_id after the mysql_insert function.
I tested this, but that does not function.
$colsToValues = array('field' => '...');
mysql_insert($tableName, $colsToValues, true);
$recordNum = mysql_insert_id()
$recordNum give always '0'.
What I would like, it is to be able to use $colsToValues and obtain mysql_insert_id().
Would there be a solution?
Thanks!
Djulia
By claire - October 14, 2014
Hi Djulia
If I recall right, mysql_insert should return the ID of the created record or false if it's not created successfully, so all you'd need to do is this:
$recordNum = mysql_insert($tableName, $colsToValues, true);
Does that help?
Claire Ryan
interactivetools.com
Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/