Jump to content

how can i included a DASH ( - ) as part of variabled SQL Query ?


gordo2dope

Recommended Posts

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

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.