Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.