Two troublesome fields not inserting

Two troublesome fields not inserting

am 19.02.2009 21:17:19 von Terion Miller

--0016e644cc6029802c04634b3938
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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:


class="CaptionReq">Property:

name="Location" value=""> $row2['Location']; ?>



Work
Order Name:


name="WorkOrderName" size="35 " value=" ?>"/>



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:
title="Terion Miller's Facebook profile" target=_TOP> alt="Terion Miller's Facebook profile">
Katharine Hepburn - "Life is hard. After all, it kills you."

--0016e644cc6029802c04634b3938--

Re: Two troublesome fields not inserting

am 19.02.2009 22:36:46 von dmagick

Terion Miller 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();

My immediate guess is either a single quote or a new line is causing the
problem.

You need to escape your data (use mysql_real_escape_string).

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Two troublesome fields not inserting

am 20.02.2009 12:59:40 von David Robley

Chris wrote:

> Terion Miller 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();
>
> My immediate guess is either a single quote or a new line is causing the
> problem.
>
> You need to escape your data (use mysql_real_escape_string).
>
And don't forget debugging tools: echo the query and use mysql_error()



Cheers
--
David Robley

"I love hot dogs," said Tom with relish.
Today is Sweetmorn, the 51st day of Chaos in the YOLD 3175.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Two troublesome fields not inserting

am 20.02.2009 14:12:24 von Terion Miller

--0016e644c7c261f0e804635967c5
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Yep I've echo'd the fields because I populate the form with them and they
echo fine they are there they just won't go back into the db, and just those
two...the others go in as a new order no problem. I would attach the whole
page but I don't think the list allows it, but if anyone is interested in
seeing it I'm MORE than happy to send it, I've been stumped on it for two
days now, two days, two fields..argh.


Thanks
Terion

--0016e644c7c261f0e804635967c5--