gordo2dope Posted July 31, 2007 Share Posted July 31, 2007 In my SQL Table, I have the main primary key row that has Part Numbers for Items. Everything is related to these part #'s. The problem is then im submitting my variables (which are these Part #'s) they have dashes in them (ex. 96054-05V). so during the query its thinking the dash is a - minus sign and is including that in the WHERE CLAUSE. Here is the query line. this line is just a smalle part of a much bigger shopping cart were working on. Syntax is all perfect I just need to figure out the Variable $PartNum can have a ( - ) in it without it treating that as a Minus - $sql = "SELECT * FROM mczippo1 WHERE PartNum =".$PartNum; the error im getting shows this Notice: Query failed: Unknown column '04V' in 'where clause' SQL: SELECT * FROM partsitems WHERE PartNum=96981-04V in C:\Program Files\Apache2\htdocs\inc\mysql.class.php on line 109 As you can see the Partnum is 96981-04V but its having trouble with everything after the - . I need to have it treat the - DASH as a literal instead of an logical operator. ANYBODY GOT ANY IDEAS? THANKS! - Gilbert Quote Link to comment https://forums.phpfreaks.com/topic/62742-how-can-i-included-a-dash-as-part-of-variabled-sql-query/ Share on other sites More sharing options...
calabiyau Posted July 31, 2007 Share Posted July 31, 2007 $sql = "SELECT * FROM mczippo1 WHERE PartNum ='".$PartNum."'" Hopefully that column is VARCHAR? Quote Link to comment https://forums.phpfreaks.com/topic/62742-how-can-i-included-a-dash-as-part-of-variabled-sql-query/#findComment-312260 Share on other sites More sharing options...
gordo2dope Posted July 31, 2007 Author Share Posted July 31, 2007 yes it is VARCHAR, if it is working i dont know because I'm still getting an error on the EXTRACT, but either way im still getting the error. Notice: Query failed: Unknown column '06V' in 'where clause' SQL: SELECT * FROM partsitems WHERE PartNum=96828-06V in C:\Program Files\Apache2\htdocs\inc\mysql.class.php on line 109 THANKS FOR THE TRY THOUGH. Quote Link to comment https://forums.phpfreaks.com/topic/62742-how-can-i-included-a-dash-as-part-of-variabled-sql-query/#findComment-312281 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Share Posted July 31, 2007 Try this $sql = "SELECT * FROM mczippo1 WHERE PartNum ='{$PartNum}'"; Quote Link to comment https://forums.phpfreaks.com/topic/62742-how-can-i-included-a-dash-as-part-of-variabled-sql-query/#findComment-312284 Share on other sites More sharing options...
gordo2dope Posted July 31, 2007 Author Share Posted July 31, 2007 ??? nope. - I know it has to be the - because it works fine on products without dashes in the PartNum. Quote Link to comment https://forums.phpfreaks.com/topic/62742-how-can-i-included-a-dash-as-part-of-variabled-sql-query/#findComment-312301 Share on other sites More sharing options...
almightyegg Posted July 31, 2007 Share Posted July 31, 2007 I think I had a similar problem with this, it turned out to be simply resolved... Try: $sql = "SELECT * FROM mczippo1 WHERE PartNum = '{$PartNum}' "; Noticed it is more spaced out Quote Link to comment https://forums.phpfreaks.com/topic/62742-how-can-i-included-a-dash-as-part-of-variabled-sql-query/#findComment-312303 Share on other sites More sharing options...
gordo2dope Posted July 31, 2007 Author Share Posted July 31, 2007 cool, this works, but im having other problems now. THANKS ALOT EVERYBODY!! now I need to debug this damn cart and figure out how to include 2 tables on in the functions.inc, OR how to require two seperate CARTS at the same time, which is rediculous. THANKS AGAIN! - especially almightyegg Quote Link to comment https://forums.phpfreaks.com/topic/62742-how-can-i-included-a-dash-as-part-of-variabled-sql-query/#findComment-312381 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.