MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old June 8th, 2000, 07:31 AM
JStan JStan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 9 JStan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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"&nbsp;";}

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

Reply With Quote
  #2  
Old June 8th, 2000, 03:28 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Try this:

update table set problem_field=trim(trailing 'n' from problem_field);

Reply With Quote
  #3  
Old June 8th, 2000, 04:52 PM
JStan JStan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 9 JStan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old June 8th, 2000, 05:36 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
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.

Reply With Quote
  #5  
Old June 8th, 2000, 06:12 PM
JStan JStan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 9 JStan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #6  
Old June 8th, 2000, 07:10 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > \n in field value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway