Cosizzle Posted March 30, 2008 Share Posted March 30, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/98679-mysql-php-query-help-hello/ Share on other sites More sharing options...
aschk Posted March 31, 2008 Share Posted March 31, 2008 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%' Quote Link to comment https://forums.phpfreaks.com/topic/98679-mysql-php-query-help-hello/#findComment-505519 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.