|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Good day all,
I recently imported a text file into a database and although I specified that the lines ended with 'n', this was picked up in the last row as a value. So now I have 8000 rows with this as a value in the last field. In code, as I scan the rows, I say: if(($i == 7) && (htmlspecialchars($row[$i])!="")){echo "<a href="".htmlspecialchars($row[$i]).""Click Here</a>";} else{echo" ";} It always shows up as a value. This puts a link on an empty field. Looks terrible on the html page. The source of the created html page reflects a 'newline' at this point. Question: How to get rid of this 'newline'('n') in the field values. When I search for this, it always comes up with 'empty set'. I must be searching wrong?? Thanks for any help. Jim |
|
#2
|
|||
|
|||
|
Try this:
update table set problem_field=trim(trailing 'n' from problem_field); |
|
#3
|
|||
|
|||
|
Howdy,
I tried your suggestion but it did not work. I even tried variations of the code (ie: left out the word 'trailing') but still no good. Problem might be that as before, mysql sees an empty field. Any other suggestions are greatly appreciated. Thanks, Jim |
|
#4
|
|||
|
|||
|
Well, the only other suggestion I can come up with is processor intensive but if you only have to do it once....
$result=mysql_query("select id,prob_field from table"); // where id is your unique id for the table while (list($id,$probfield)=mysql_fetch_row($result)) { $probfield=chop($probfield); $result2=mysql_query("update table set prob_field='$probfield' where id=$id"); } That'll do it. |
|
#5
|
|||
|
|||
|
howdy again,
I was going to try your code but then I got to thinking. If the fields should be empty but they contain a 'n', then why not just update the field value to "". So I did this: update table set problem_field="" where problem_field = ""; and it worked. This cleared all of the problem_fields that did not contain a valid value. Thanks for your time. I appreciate it. Jim |
|
#6
|
|||
|
|||
|
Ahhh, I misunderstood. I thought you meant the newline was included as part of the data you DID want, not the ONLY data in the field.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > \n in field value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|