stripping HEX code out of a string

Posted on 2005-05-10
Last Modified: 2008-03-17
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(, 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.
Question by:robids
    1 Comment
    LVL 9

    Accepted Solution

    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

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
    I have been using r1soft Continuous Data Protection ( for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now