Solved

PHP like operator

Posted on 2004-09-06
10
271 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now