• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

PHP like operator

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
kajirouji
Asked:
kajirouji
  • 5
  • 3
  • 2
2 Solutions
 
benbalboCommented:
Can you paste in the output of the
   echo $info1," ",$info2, " ", $info3
line?
0
 
kajiroujiAuthor Commented:
Yes , the output line result is correct
0
 
kajiroujiAuthor Commented:
sorry the format shoud

$str="SELECT clientip,time,url FROM access3 where clientip like '%$info1%' AND time like '%$info2%' AND url like '%$info3%' ;"
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
akshah123Commented:
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
 
akshah123Commented:
or

$str="SELECT clientip,time,url FROM access3 where clientip like '%$info1%' AND time like '%$info2%' AND url like '%$info3%' ";
0
 
kajiroujiAuthor Commented:
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
 
benbalboCommented:
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
 
kajiroujiAuthor Commented:
Thanks akshah123 I work , it but why ther ; before the " and after the " different , any refernace page ?
0
 
kajiroujiAuthor Commented:
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
 
benbalboCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now