abrahamgarcia27 Posted January 17, 2012 Share Posted January 17, 2012 I am trying to perform a search but it doesn't see to pass through i thing its because of this \ does any one know how i can pass this trought to search in mysql table 12\019PB (i cant search this item) $searchlading = mysql_real_escape_string($_GET['searchlading']) ; // get the query for the search engine (if applicable) $trimmed = trim($searchlading); //trim whitespace from the stored variable //query for pedimento $sql_ped = "SELECT order_id, bill_of_lading, pedimento_num FROM `".TABLE_ORDERS."` WHERE bill_of_lading LIKE '%$trimmed%'"; Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted January 17, 2012 Share Posted January 17, 2012 mysql_real_escape_string will take care of the backslash, what error(s) do you actually receive Quote Link to comment Share on other sites More sharing options...
abrahamgarcia27 Posted January 17, 2012 Author Share Posted January 17, 2012 is probably because i have a mess in my code. Well maybe you can spot something or maybe i am doing it wrong i have two tables one order and order_details so i need to get a record from the order table and then bring that record back to order_details so this is how it works Search Bill Of Lading -> (go to order table) Get Order ID -> (go to order details table) -> Get all records for that order so i did this $searchlading = mysql_real_escape_string($_GET['searchlading']) ; // get the query for the search engine (if applicable) $trimmed = trim($searchlading); //trim whitespace from the stored variable //query for pedimento $sql_ped = "SELECT order_id, bill_of_lading, pedimento_num FROM `".TABLE_ORDERS."` WHERE bill_of_lading LIKE '%$trimmed%'"; $record_ped = $db->query_first($sql_ped); //query for item details $sql_order = "SELECT order_details_id, order_id, product_id, po_num, warehouse_num, vendor_id FROM `".TABLE_ORDERDETAILS."` WHERE order_id = $record_ped[order_id] ORDER BY order_details_id DESC LIMIT 150"; $rows_order = $db->fetch_all_array($sql_order); ?> Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted January 17, 2012 Share Posted January 17, 2012 use a mysql JOIN for this, you can google it if you are not sure what it is, and really, you didn't answer my first question, what errors do you receive. Quote Link to comment Share on other sites More sharing options...
abrahamgarcia27 Posted January 17, 2012 Author Share Posted January 17, 2012 I didn't get error the query was not returning any records with backslashes on it Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted January 17, 2012 Share Posted January 17, 2012 dealing with backslashes in a like clause can be a little buggy, this link from mysql dev talks about it: http://dev.mysql.com/doc/refman/5.1/en/string-comparison-functions.html#operator_like Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.