Solved

PHP like operator

Posted on 2004-09-06
10
278 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress Pagination Function Not working ? 7 31
hosting images 4 29
maybe no no httpd.conf 6 47
google analytics in wordpress 4 34
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 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