<div>Thanks Nancy.</div>
<div>Do you mean that in my code I should not put the value for "cid". That means $lastid (in red) should be removed.</div>
<div> </div>
<div> </div>
<div>
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><em>$lastid = 0;<br> for($delta = 0; $delta < $all_companies; $delta++)<br> {<br> $lastid = db_last_insert_id(rs_companies, cid) + 1;<br>
db_query(<br> 'INSERT INTO {rs_companies} ( cid, uid, prevcompany, joindate, releasedate) '<br> ."VALUES (%d, '%d', '%s', '%d', '%d')", <br><font color="#cc0000"> $lastid, </font> </em></div>
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><em>$user->uid</em></div></div>
<div><br> </div>
<div>Regards</div>
<div>Austin<br></div>
<div class="gmail_quote">On Mon, Mar 28, 2011 at 4:20 PM, nan wich <span dir="ltr"><<a href="mailto:nan_wich@bellsouth.net">nan_wich@bellsouth.net</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>
<div style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 12pt">
<div></div>
<div>You don't need to provide the value for an auto increment field. "Db_last_insert_id()" is how you get the value <strong>after</strong> the insert, if you need it at all.<br> </div>
<p><font color="#ff007f" size="4" face="bookman old style, new york, times, serif"><em><strong>Nancy</strong></em></font></p>
<p> </p>
<p><font face="arial, helvetica, sans-serif">Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.</font></p>
<div><br></div>
<div style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 12pt"><br><font size="2" face="Tahoma">
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt">
<hr size="1">
</div>
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><b><span style="FONT-WEIGHT: bold">From:</span></b> Austin Einter</div>
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"></div></font> </div>
<div class="im">
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt">I have a table, where 'cid' field is of type "serial".</div>
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"> </div></div>
<div class="im">
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><em>$lastid = 0;<br> for($delta = 0; $delta < $all_companies; $delta++)<br> {<br> $lastid = db_last_insert_id(rs_companies, cid) + 1;<br>
db_query(<br> 'INSERT INTO {rs_companies} ( cid, uid, prevcompany, joindate, releasedate) '<br> ."VALUES (%d, '%d', '%s', '%d', '%d')", <br> $lastid, </em></div>
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"> </div>
<div style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"> </div></div></div></div></blockquote></div><br>