Solved

PHP like operator

Posted on 2004-09-06
10
274 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

919 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

14 Experts available now in Live!

Get 1:1 Help Now