close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

insert single record having problems

Thread began 6/09/2010 9:39 pm by JBWebWorks | Last modified 6/18/2010 6:52 pm by Jimmy Wu | 1166 views | 6 replies |

JBWebWorks

insert single record having problems

Using data assist inserting into data base.
MYSQL 4.1.20

In the form is a textarea and also a hidden field and included in some of the text of these fields is the character, |

It seems that the character | is being received as a field seperator and dividing up the text from the single textarea and putting into several fields in the database.

What can i do to get the insert code to recognize the character | as text?

thanks,
Jim Balthrop

Sign in to reply to this post

Miguel

Can you give us a bit of more info or the file affected to check out where is the problem?

Sign in to reply to this post

JBWebWorks

The php code for the insert
<?php
// WA Application Builder Insert
if (isset($_POST["submit1"])) // Trigger
{
$WA_connection = $connauto;
$WA_table = "unclassified";
$WA_sessionName = "unclassified_ad_ID";
$WA_redirectURL = "ucp02.php";
$WA_keepQueryString = true;
$WA_indexField = "ad_ID";
$WA_fieldNamesStr = "client_ID|ad_header|ad_title|ad_price|ad_city_state|ad_description|pic1|pic2|pic3|pic4";
$WA_fieldValuesStr = "".((isset($_POST["hiddenField"]))?$_POST["hiddenField"]:"") ."" . "|" . "".((isset($_POST["Cad03"]))?$_POST["Cad03"]:"") ."" . "|" . "".((isset($_POST["postingtitlediv01"]))?$_POST["postingtitlediv01"]:"") ."" . "|" . "".((isset($_POST["postingtitlediv02"]))?$_POST["postingtitlediv02"]:"") ."" . "|" . "".((isset($_POST["divbox01"]))?$_POST["divbox01"]:"") ."" . "|" . "".((isset($_POST["userdescription"]))?$_POST["userdescription"]:"") ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["clientFileName"] ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult2"]["clientFileName"] ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult3"]["clientFileName"] ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult4"]["clientFileName"] ."";
$WA_columnTypesStr = "none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_connauto;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>

this field
"".((isset($_POST["Cad03"]))?$_POST["Cad03"]:"")

contains text and the character '|' (this is used as a divider for appearance)

my thinking is that character is a field seperator when used in the php insert code, so when it sees that character in the "Cad03" field, it reads it as a database field seperator.

I could not use the character in the "Cad03" text field and that would solve the problem, but i was wondering how to get the php code to see that character as text only?

Sign in to reply to this post

Jimmy Wu

You could url encode that text field before storing it in the database. You would also have to decode the data when you're getting it out of the database as well though.

Here is a reference to the url encode:
ref_urlencode.asp

Sign in to reply to this post

neo314

I think the extension should encode that character before using the character as a separator and decode it in the sql statement. It is a standard keyboard character that should be anticipated as input.

In the meantime, I suggest encoding any input server side as easiest. No other input should be using the bar character, so I add this:

<?php
// encode vertical bars
foreach ($_POST as $key => $value) {
$_POST[$key] = str_replace("|", "&#38;#124;",$value);
}
?>

I am having that problem with HTMLEditor and when I tried to get HTML editor to encode it I lost all the input which came out NaN.

Sign in to reply to this post

JBWebWorks

Jimmy,

thanks for your help; worked perfectly.
The input field that contained the character '|' many times was on the insert page from a previous page that had a form action taking it to the insert page.

So i used the urlencode this way
<input name="hiddenCad03" id="hiddenCado3" type="hidden" value="<?php echo urlencode((isset($_POST["heading02"]))?$_POST["heading02"]:"") ?>" />

That field was inserted into the database encoded and then when i wanted to pull that information from the database and display it on another page i used a recordset this way
<?php echo urldecode($row_rs_unclassified['ad_header']); ?>

Regards,
Jim Balthrop

Sign in to reply to this post

Jimmy Wu

Thanks for getting back that you were able to get it working. If you run into any additional issues, feel free to open a new thread.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...