Welcome to WebmasterWorld Guest from 18.104.22.168
The field and table names are just codes by the way. They will be translated serverside into the real names. No validation is necessary, so long as we don't end up in quirks mode, hence the custom tags - (won't be for qeneral public use).
The problem is that when I enter carriage returns into the textarea, when the data is saved in the database, it is saved without them.
I found that it looks like they are being removed during the http GET sending the data to the script that performs the INSERT.
in the ajax.js script, immediately before transmission by GET. The data was echoed back in the alert box WITH line breaks at the correct places.
I then told insert.php to echo the the
back as the response and told the waiting ajax.js to
. This time there were no line breaks where there should have been (needless to say, it was not saved in the db with linebreaks either).
Any ideas what could be going wrong?
The trouble is that I want to display the data in html when I retrieve it. I'm using the php function, nl2br() to format the data I pull out of the db, but it's not currently working since the newlines are not getting as far as the database.
Let me know if you need to see the ajax.js or insert.php (since they are quite lengthy and I'm not sure which bit(s) you'd want to look at.
I'm hoping there's a really simple solution :)
I've tried all combinations of double and single quotes, addslashes, stripslashes, mysql_real_escape_string etc but nothing makes any difference.
I have echoed the URL prepared for the GET statement using alert(url); and the alert shows line breaks at the same places I entered them in the textarea.
My suspicion is that somehow, by the time it reaches my insert.php the linebreaks have somehow been removed, since I can't get them into the database and when I echo the data back to request.response the alert then shows the data without the linebreaks.
I've included the relevant bits of code below:
The text area from mypage.php :
echo '<textarea style="width:95%;" rows="6" name="data" id="t_' . $cust_id . '" db_table_name="' . $tbl_cust_pub . '" db_field_name="boa054_cust_notes" where="' . $cust_id . '" onBlur="return update_field(\'t_\',this.value,' . $cust_id . ',\'\');" onClick="return add_note_head(this.value,' . $cust_id . ')"></textarea>';
Extract from ajax.js :
// add my vars to url
url += '&db_table_name=' +db_table_name+ '&db_field_name=' +db_field_name+ '&record_id=' +record_id+ '&data=' +data+ '&where=' +where+ '&action=' +action ;
request.open("GET", url, true);
Relevant part of insert.php :
$query = ' UPDATE `' . $table_name . '` SET `' . $field_name . '` = CONCAT("' . $_GET["data"] . '","\n\n\n",' . $field_name . ') ';
// save the info to the database
$result = mysql_query($query) or die(sql_failure_handler($query, mysql_error()));
echo $_GET['data'] ;
get_magic_quotes_runtime == 0
Any help would be greatly appreciated since I've wasted the best part of two days now trying to resolve this little issue :(
Thanks in advance.