473,467 Members | 1,303 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SELECT LIKE returns no result

18 New Member
Hi there!

In my script I use the following code:

Expand|Select|Wrap|Line Numbers
  1. $table = "_lisausers"; 
  2. $mypassword; //this is a 'POST' variable
  3. $query =mysql_query("SELECT pwd FROM `$table` WHERE pwd LIKE '$mypassword'" ) or die();
  4. if (mysql_num_rows( $query ) > 0) {
  5.     print "&retour=true";
  6. }
  7. else {
  8.     print "&retour=false";
  9. }
Despite the fact that $mypassword already exists in the $table, this query always gives me a wrong result if I ask an existing or not pwd in this table !!!

Would you tell me what's wrong in this query and the if/else block?

Many thanks in advance for your help!

Regards,
Gerry
Feb 25 '08 #1
4 1489
Markus
6,050 Recognized Expert Expert
I think when you use LIKE you also have to use the % operator.

[php]
SELECT * FROM `table` WHERE `column` LIKE '%something%';
[/php]

Also, in your: 'or die()' add this: or die(mysql_error());
for error checking.
Feb 25 '08 #2
nomad
664 Recognized Expert Contributor
I think when you use LIKE you also have to use the % operator.

[php]
SELECT * FROM `table` WHERE `column` LIKE '%something%';
[/php]

Also, in your: 'or die()' add this: or die(mysql_error());
for error checking.
or you could do this as well
SELECT * FROM `table` WHERE item_name LIKE 'A%';

This would find any item that starts with the letter A

nomad
Feb 25 '08 #3
nomad
664 Recognized Expert Contributor
I think when you use LIKE you also have to use the % operator.

[php]
SELECT * FROM `table` WHERE `column` LIKE '%something%';
[/php]

Also, in your: 'or die()' add this: or die(mysql_error());
for error checking.
sorry I thought the first one did not go thro...

nomad
Feb 25 '08 #4
Germaris
18 New Member
Thanks very much to all of you folks for your replies.

The problem is solved.
The PHP is okay, it's the way I manipulate the results in my .swf file which was wrong.
Silly of me !

Best regards,
Gerry
Feb 26 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Rocky XXVIII | last post by:
Goodmorning, Could I have a SELECT statement that normally returns two rows ,but that instead returns one row appending to the first row the second one of the result ? For example Query:...
3
by: Hendry Taylor | last post by:
I have a problem where if I issue a select * from against a database it returns no data, but if I select column from it returns the data. Why would the * not be working as a wildcard?
2
by: shumaker | last post by:
The query: SELECT BTbl.PKey, BTbl.Result FROM BTbl INNER JOIN ATbl ON BTbl.PKey = ATbl.PKey WHERE (ATbl.Status = 'DROPPED') AND (BTbl.Result <> 'RESOLVED') Returns no rows. If...
4
by: Alex | last post by:
Hi, I have a bit string , 7 bits, every bit representing a day of the week. e.g. 1110011. Is there and easy way where I can translate/format that string in a query. I want to give the string...
6
by: Terentius Neo | last post by:
Is it possible to combine (in DB2 UDB 8.1) a stored procedure and a select statement? I mean something like this: Select c.number, call procedure( c.number ) as list from table c With best...
4
by: VK | last post by:
Hello, I have a dataset which has one datatable in it. The dt has over 3000 rows in it. Now I would like to get the rows where the StartDate is 15 Feb 2005, so I did the following: ...
17
by: geniajanssen | last post by:
Hi there: I cannot get the code below to work properly. It works fine on the first loop but the next times around "$querySQL = 'SELECT * FROM host_index'" returns the wrong value. Can somebody...
11
by: Richard Maher | last post by:
Hi, I have read many of the copius entries on the subject of IE performance (or the lack thereof) when populating Select Lists. I don't mind the insert performance so much, (I get 100x120byte...
4
by: Konrad Hammerer | last post by:
Hi! I have the following problem: I have a query (a) using another query (b) to get the amount of records of this other query (b), means: select count(MNR) as Number from...
2
by: msridhar87 | last post by:
hi, am doing a multi server chat program using select()..in the client side i need to multiplex thei/p from server and stdin. #include <stdio.h> #include <sys/types.h> #include <sys/socket.h>...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.