square character in textbox

A

Anonymous

Guest
hi!
let me explain..
I'm trying to import database data from a csv file in which I have a record with a text field like this:
aaaaaa
bbbbb
ccccc

I read the file with a php function.
when I write the field in a html page the field is shown this way:
aaaaaa S/Nbbbbb S/Nccccc

and most important: I load value of the field in a field of a mysql db and in phpmydmin everything looks fine, but when I select the modify view of the record the strings of he field are joined by funny square symbols plus S/n. and so if i try to display it in a html text area.

NB: the data come from a filemaker db
the square symbol seems to be a vertical tab (asciii 11)


please help me to clean the string or to prevent the squares to be shown.
sorry for syntax and english
 
Well as swirlee already said, some code would be nice, but i think i somewhat get the question to an extent...
The problem is, when you write some text to a file in php, you need to put certain markings that will for example set a tab or got to the next line. So your normal text looking like this:
hello
hello
(tab here) hello
where the tab here = a tab will really look like this in php's variable
$text="hello /nhello /n/thello";
"s"es dont really matter but they can be inserted in there...
ok now what you need to do in order to display text like that is actually two things:
1) You can break up the text into an array according to s/n (use explode() function)
2) An alternative to that may be going through the string and replacing /n's with <br> tags, /t's with <p> strings and so on... this will be a bit more complicated, but can pay off in the end sisnce what you will come out with is a function to print out a file on a page... you would need to read through str functions.

if i am not mistaken that's what you wanted to know, but if not post some hard evidence(code) so we can really understand you.
 
Your slashes are the wrong way, Alex. Backslash is the escape character: \n, \t.

Unless I misread the question, though, I don't think this is the problem. On an HTML page, tabs and newlines are displayed as tabs and newlines (at least when you view the source), not square blocks, and the character he's mentioned (ASCII 11) is neither, anyway.

He could use str_replace or explode as you describe, but that's really only fixing the symptom and not the illness.
 
Hi again!
I cannot show you the square symbol 'cause when i write the message in the text area it is visible but when I preview the text it is invisible. so I'll use [].
I think if you cut and paste this string you'll see the effect
"H0309088868K0856GFW2950072"

I'll try to explain the problem with more details and some code.
I have a db made with 'filemaker'. I need to import its data in mysql and so I export it with a .csv file.
Opening it with a text editor I see (a row for example): // 4 fields per row

"19580","CDC","24/10/2003","H0309088868[]K0856GFW2950072[]"

The last field holds serial numbers loaded with a code-bar laser reader that adds a new line "symbol" at the end of every number but not the usual \r\n;

I read the file with:

$handle = fopen("inventario.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$nFat = $data[0];
$idFor = $data[1];
$dataFat = $data[2];
$nSerFat = $data[3];
$query = "INSERT INTO hardware (nFat, idFor, dataFat, nSerFat) VALUES ('$nFat', '$idFor', '$dataFat', \"$nSerFat\")"; echo $query;
$res = mysql_query($query, $conn);
}
fclose($handle);

As you can see the code loads the data in the 'hardware' table;
Phpmyqdmin displays the records of the table correctly that is serial number (new line) serial number .
-------------------------------------------------------------
|...nfat....|...id...|..date........|...serial.......................|
-------------------------------------------------------------
| 19580.|.CDC..|.24/10/2003.|.H0309088868........|
|............|..........|....................|.K0856GFW2950072|
---------------------------------------------------------
but if I try to modify the record in the modify page the textarea of the serial field shows again the H0309088868[]K0856GFW8950072[].
As I need to show this field in a text area in my application as well the problem turns to be relevant.

All I know so far:
the square symbol seems to be a vertical tab VT, ascii 11;
if I read a code-bar in my php application all the serial numbers are loaded and displayed
correctly so it seems that the problem doesn't belong to the laser reader setting (but i'm not so sure).

I need a way to replace this character or to delete it at least.
thanks a lot to everybody.
 
Well, I'm a bit stumped. My only guess is that this is some unusual FileMaker behaviour. As a stopgap solution, you can just get rid of it using str_replace(chr(11), '', $oldstring), or you can replace it with a newline by using "\n" for the second parameter.
 
Oh you are right about my slashes swirlee, i always seem to use the wrong ones, i guess that my usage of / slashes comes from html's closing tags...
 
thanks swirlee and alex.
the str_replace function works.
everything is ok now.
 
Back
Top