|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Another simple SELECT problem
Hallo to all, I'm strugling with a (supposed) stupid problem with a SELCT query on a MySQL database.
System info are: MySQL 3.23.41 on a RH 7.2 PHP 4.0.6 My problem is that I'm trying to execute a query like: but what I get is just the list of the fields on my table without any record. I have tried also in the form some of you suggested in a similar post, i.e.: but then in the page which was supposed to show the good output I get only an error: Error: You have an error in your SQL syntax near ''ptsc'' at line 1 where 'ptsc' is the string I want to find and the field $field_1 is defined as varchar(10). Actually what I have is a table with some codes like 'ptsc' and I want to get all the records with this code. Eventually, in the future I'd like to combin it with a logical AND with another field, but for now I can't get work the first part of it. Do you have any suggestion? Thanks, Bighimot |
|
#2
|
|||
|
|||
|
RE: Another simple SELECT problem
|
|
#4
|
|||
|
|||
|
RE: Another simple SELECT problem
Thank you for your suggestions but still it does not work.
$to_find has a value which is ptsc, which it isn't single quoted. What it looks weird to me is that it seems that querying with a string value will not work. I've tried using a similar query like: in this case field_2 is a numeric field (int unsigned) and the var $to_find_2 contains a numeric value. This one works. Again if a use a field_3 which is defined as date (formatted as YYYY-MM-DD), it still doesn't work. In the MySQL shell I would use (and actually works): SELECT * FROM my_table WHERE field_2 = "ptsc"; but quoting seems not allowed via PHP because any attempts to add quoting result in that error. Am I forgetting some stupid thing? Bighimot |
|
#5
|
|||
|
|||
|
RE: Another simple SELECT problem
|
|
#6
|
|||
|
|||
|
RE: RE: Another simple SELECT problem
You wrote:
Quote:
Well, it's more or less the same. I get: Error: You have an error in your SQL syntax near ''' at line 1 If I do not use quotes it does not work, if I do quoting it throws an error. It looks like a catch, but I don't understand why. Thank you anyway Nazly. B. |
|
#7
|
|||
|
|||
|
RE: Another simple SELECT problem
Got it!!!!!!!
Thank you all for your help. All the suggestions I got drove me to the solution. Well it's a funny stupid thing. PHP passing the query to another script automatically puts slashes in front of my data, thus I just needed to use stripslashes() and all works fine. Thank you all, again Bighimot. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Another simple SELECT problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|