Jump to content

MySQL // PHP Query Help && "Hello!"


Cosizzle

Recommended Posts

First time here so "Hello"

 

I've created a forum that registers data to a Database once its filled out. However besides the error checks on blank fields, Im also wanting to error check two separate fields that will error check against information within a created table.

 

For my setup I've created two tables. One holds the information received from he PHP script. The other Table has the information in it that the PHP script will error check against.

 

For sake of confusion the two columns that the PHP script error checks against are "dCode" & "VIN"

Right now the problem(s) I am currently having are:

1. The dCode and VIN fields of the PHP script have to be correct to a certain extent but not 100% SO as long as the person knows a dCode and a VIN then they can log in. My problem here, is because its within a table the Query I have running now checks to see if dCode and VIN are beside one another.

SELECT user_id FROM ErrorCheck WHERE (dCode='3313' AND VIN='5J6RE')
SELECT user_id FROM ErrorCheck WHERE (dCode='$dc' AND VIN='$vin')

 

Question: Is it possible to make a query that can search two different user_id's and combine them as one.

 

2. Because I only need the 1st five characters of the VIN I only need to error check against that. The VIN it self is around 17-20 characters. I've created this Query to error check against that.

SELECT * FROM ErrorCheck WHERE MATCH (VIN) AGAINST ('5J6RE%')
SELECT * FROM ErrorCheck WHERE MATCH (VIN) AGAINST ('$vin%')

Question: As far as I can think, I need this to be run first, turned into a variable, that variable will be used with the error check... Thats my thinking - is this correct? If so how would I query this as a variable!

 

Ideally - both one and two will have to work with one another but that can wait.

 

Thank you in advance!

 

Link to comment
Share on other sites

You appear to be performing FULLTEXT matching which is needless in this scenario. Use the LIKE statement instead.

e.g.

SELECT * FROM ErrorCheck WHERE VIN LIKE '5J6RE%'

SELECT * FROM ErrorCheck WHERE VIN LIKE '$vin%'

 

I think my problem occurs with understanding, what your tables look like, and what data is stored. Both the queries you used above appear to use the ErrorCheck table, but as you said you have 2 tables. I'm taking a guess but I think a more appropriate query might be:

 

SELECT user_id FROM ErrorCheck WHERE dCode = '$dc' AND VIN LIKE '$vin%'

Link to comment
Share on other sites

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.