Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. ------------------------------------------------ Twitter? http://twitter.com/terionmiller ------------------------------------------------ Facebook: <a href="http://www.facebook.com/people/Terion-Miller/1542024891" title="Terion Miller's Facebook profile" target=_TOP><img src=" http://badge.facebook.com/badge/1542024891.237.919247960.png" border=0 alt="Terion Miller's Facebook profile"></a> Emo Philips - "I was the kid next door's imaginary friend." On Thu, Feb 19, 2009 at 2:31 PM, Bastien Koert <phpster@xxxxxxxxx> wrote: > > > On Thu, Feb 19, 2009 at 3:21 PM, Terion Miller <webdev.terion@xxxxxxxxx>wrote: > >> Hi all, I seem to be having a problem with getting two fields to insert >> into >> a table, the other fields insert but not these two >> its from a form that is a duplicate, basically I have a workorder that I >> want to make a copy of, I call it from the db, populate a form in case >> changes want to be made, and insert with a new unique ID as a new record, >> it's working great except Two fields will NOT insert and I'm at a loss for >> why ... >> the code is big so I will post snippets that I think may be the trouble >> spots >> >> Here is the insert: >> $sql = "INSERT INTO workorders (CreatedDate, Location, WorkOrderName, >> AdminID, FormName, Status, Notes) VALUES ("; >> $sql .= "Now(), '$Location', '$WorkOrderName', '$AdminID', 'WorkOrder', >> 'New Order', '$Notes')"; >> mysql_query($sql); >> $WorkOrderID = mysql_insert_id(); >> >> Here is the part where it calls the old values: >> >> $sql2 = "SELECT Location, WorkOrderName FROM workorders WHERE >> WorkOrderID='$WorkOrderID'"; >> $result2 = mysql_query ($sql2); >> $row2 = mysql_fetch_array($result2); >> >> >> Here is the form part: >> >> <tr> >> <td align="left" nowrap><div >> class="CaptionReq">Property:</div></td> >> <td align="left"><div><input type="hidden" >> name="Location" value="<?php echo $row2['Location']; ?>"><?php echo >> $row2['Location']; ?> </div></td> >> </tr> >> <tr> >> <td align="left" nowrap><div >> class="CaptionReq">Work >> Order Name: <?php echo $row2['WorkOrderName']; ?></div></td> >> <td align="left"><div><br><input type="hidden" >> name="WorkOrderName" size="35 " value="<?php echo $row2['WorkOrderName']; >> ?>"/></div></td> >> </tr> >> >> I need some clues, everything works except the two fields Location, and >> WorkOrderName..... >> >> Thanks >> Terion >> >> Happy Freecycling >> Free the List !! >> www.freecycle.org >> Over Moderation of Freecycle List Prevents Post Timeliness. >> ------------------------------------------------ >> Twitter? >> http://twitter.com/terionmiller >> ------------------------------------------------ >> Facebook: >> <a href="http://www.facebook.com/people/Terion-Miller/1542024891" >> title="Terion Miller's Facebook profile" target=_TOP><img src=" >> http://badge.facebook.com/badge/1542024891.237.919247960.png" border=0 >> alt="Terion Miller's Facebook profile"></a> >> Bill Watterson - "There is not enough time to do all the nothing we want >> to >> do." >> > > Why not try a > > insert into table select fields from table where id = $id > > -- > > Bastien > > Cat, the other other white meat > I just tried this and now it's not inserting at all where before everything EXCEPT two fields go in... $sql = "INSERT INTO workorders ( CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes) VALUES ("; $sql .= "Now(), "; $sql .= "'". mysql_real_escape_string($Location) ."', "; $sql .= "'". mysql_real_escape_string($WorkOrderName) ."', "; $sql .= "'". mysql_real_escape_string($AdminID) ."', "; $sql .= "'". mysql_real_escape_string("WorkOrder") ."', "; $sql .= "'". mysql_real_escape_string("New Order") ."', "; $sql .= "'". mysql_real_escape_string($Notes) ."', "; $WorkOrderID = mysql_insert_id(); mysql_query($sql);