|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (10 bit)
|
MySQL query question
Hi guys,
I'm trying to determine if a row or multiple rows in a database exist with specific data in them. What i've got is a DB with 4 fields, one of which is username, i want to check to see if the username exists already in the database to prevent the name being added multiple times, (im doing this in PHP) so the script should add the row's if the username isnt in the DB already or should amend them if they already exist. Here's my code so far, could you look over it and see what im doing wrong PHP Code:
Thanks
__________________
Intel Core i7 920 2.66GHz | Asus P6T SE| 6GB Corsair ram | XFX Radeon HD 4780 | 2 x 250 Gb Maxtor SATA II (in RAID 0), 1 x 250GB SATA II | Creative XFI soundcard | Coolermaster 650W PSU | ThermalTake Tsunami case My new website -Carp Fishing Forums |
|
|
|
|
|
#2 |
|
Member (6 bit)
Join Date: Apr 2004
Location: Malta
Posts: 41
|
I don't know how to use php but i think you may have a mistake in you sql code.
When you are comparing with a string, u must make sure that the string is in " ' ", i.e. Code:
select * from users where users_name='deitel'; Code:
sql := "select * from users where users_name='" + usernamevariable + "';"; |
|
|
|
|
|
#3 |
|
Member (10 bit)
|
I've just found the mistake
changed this PHP Code:
PHP Code:
and missed a ; later onBy the way the $user is a variable, it's value is obtained higher up the script and is imported from the forum database ![]() Anyways, ran into one other PHP problem and that's how do I validate the user's input for the $quartertime variable, this is taken from a text entry field on a different page. I am expecting to see values greater than 3 but not greater than 30, it can also be values to 3 decimal places i.e 10.345 would be ok but not to 4 decimal places, i want to reject anything outside of these conditions (mainly to prevent people typing into the box and submitting it )Thanks |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|