Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

stripping HEX code out of a string

Posted on 2005-05-10
3
Medium Priority
?
596 Views
Last Modified: 2008-03-17
Hello
Got a need to strip out trailing HEX code '0a0d ' from the end of a string orders.notes. orders.notes is a text field and contains lots of trailing  carage returns and line feeds. I do need to preserve the Carrage returns and line feed that are within the text.
THis file and fields are fixed LENGTH
I would like the orders.notes to be 255 chars in lenghth padded with trailing spaces or 0 but not  hex.
****************
$query_rsOrders = "SELECT CONCAT( LPAD(orders.orderid, 11, '0' ), RPAD(orders.notes,225, ' '), RPAD(orders.company, 100, '0')) FROM orders,
order_details WHERE orders.orderid = order_details.orderid ORDER BY orders.orderid INTO OUTFILE '/home/WEB/ORDERTXT'  FIELDS TERMINATED BY '' LINES TERMINATED BY '' ";

Thanks in advance.
Rob.
0
Comment
Question by:robids
1 Comment
 
LVL 9

Accepted Solution

by:
gtkfreak earned 1000 total points
ID: 13980246
Try select left(orders.notes, length(orders.notes)-2) from orders

0xa0xd are 2 bytes/characters and should get stripped from the end of the string orders.notes.

You can put the above statement in a while loop in your PHP code and strip all the 0a0d from the file till you do not have any more trailing 0a0d
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question