Solved

PHP like operator

Posted on 2004-09-06
10
283 Views
Last Modified: 2013-12-12
Hi Sir/Madam,

  I want to select 3 fiield in 1 table with 3 like pattern , can I make the select like this
$info1=$_POST["cip"];
$info2=$_POST["cdate"];
$info3=$_POST["curl"];
echo $info1," ",$info2, " ", $info3;
$str="SELECT clientip,time,url FROM access3 where clientip like '%$info1%' AND time like '%$info2%' AND time like '%$info3%' ;"

I find when put the third pattern , my select statement is not work

Please give a help
0
Comment
Question by:kajirouji
  • 5
  • 3
  • 2
10 Comments
 
LVL 2

Expert Comment

by:benbalbo
ID: 11993159
Can you paste in the output of the
   echo $info1," ",$info2, " ", $info3
line?
0
 

Author Comment

by:kajirouji
ID: 11993245
Yes , the output line result is correct
0
 

Author Comment

by:kajirouji
ID: 11993249
sorry the format shoud

$str="SELECT clientip,time,url FROM access3 where clientip like '%$info1%' AND time like '%$info2%' AND url like '%$info3%' ;"
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Accepted Solution

by:
akshah123 earned 50 total points
ID: 11993449
change

$str="SELECT clientip,time,url FROM access3 where clientip like '%$info1%' AND time like '%$info2%' AND time like '%$info3%' ;"

to

$str="SELECT clientip,time,url FROM access3 where clientip like '%$info1%' AND time like '%$info2%' AND time like '%$info3%' ";
0
 
LVL 17

Expert Comment

by:akshah123
ID: 11993451
or

$str="SELECT clientip,time,url FROM access3 where clientip like '%$info1%' AND time like '%$info2%' AND url like '%$info3%' ";
0
 

Author Comment

by:kajirouji
ID: 11993621
akshah123 Thanks your advise ,

but this is my orginal ( The first I post is wrong on the third pattern , I amend the "time" to "url" and repost on this pasge second item)

$str="SELECT clientip,time,url FROM access3 where clientip like '%$info1%' AND time like '%$info2%' AND url like '%$info3%' ;"

what different on your one

$str="SELECT clientip,time,url FROM access3 where clientip like '%$info1%' AND time like '%$info2%' AND url like '%$info3%' ";
0
 
LVL 2

Assisted Solution

by:benbalbo
benbalbo earned 50 total points
ID: 11993629
akshah123 moved the last semi-colon after the quote.

can I just ask - are you still having a problem, or have you solved it now? Was the problem solved by amending time to url?
0
 

Author Comment

by:kajirouji
ID: 11993641
Thanks akshah123 I work , it but why ther ; before the " and after the " different , any refernace page ?
0
 

Author Comment

by:kajirouji
ID: 11993651
thanks akshah123 and benbalbo  , I am first time use this room , I hope did not make any wrong of the point issue

thanks a lot
0
 
LVL 2

Expert Comment

by:benbalbo
ID: 11993654
You don't need to end SQL statements with a semi-colon in the mysql_query statement. Your php statements should however end with semi-colons :-)

Thanks for the assist
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question