473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

php string parsing

I am trying to build a where clause for mysql based on different form
inputs but php seems to have a problem with the following:

$whrClause = "WHERE keywords LIKE '%$keywords%'"

I thought with the double quotes that the single-quote and percent
signs would remain unchanged and the variable $keywords would be
expanded to its value, but I guess I am wrong because i get a parsing
error... Any help for a php newbie?
Jul 17 '05 #1
3 6517
Hi,

On 17 Mar 2004 19:38:56 -0800, ke**********@cox.net (keith) wrote:
I am trying to build a where clause for mysql based on different form
inputs but php seems to have a problem with the following:

$whrClause = "WHERE keywords LIKE '%$keywords%'"

semicolon?

HTH, Jochen
I thought with the double quotes that the single-quote and percent
signs would remain unchanged and the variable $keywords would be
expanded to its value, but I guess I am wrong because i get a parsing
error... Any help for a php newbie?


--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2
Jochen Daum wrote:
Hi,

On 17 Mar 2004 19:38:56 -0800, ke**********@cox.net (keith) wrote:

I am trying to build a where clause for mysql based on different form
inputs but php seems to have a problem with the following:

$whrClause = "WHERE keywords LIKE '%$keywords%'"

semicolon?

HTH, Jochen

I thought with the double quotes that the single-quote and percent
signs would remain unchanged and the variable $keywords would be
expanded to its value, but I guess I am wrong because i get a parsing
error... Any help for a php newbie?


Try:

$whrClause = "WHERE keywords LIKE %'$keywords'%"

You want to pass the literal of $keywords, not the literal of %$keywords%.

IndyTim

Jul 17 '05 #3
Jochen Daum <jo*********@cabletalk.co.nz> wrote in message news:<sb********************************@4ax.com>. ..
Hi,

On 17 Mar 2004 19:38:56 -0800, ke**********@cox.net (keith) wrote:
I am trying to build a where clause for mysql based on different form
inputs but php seems to have a problem with the following:

$whrClause = "WHERE keywords LIKE '%$keywords%'"


semicolon?

HTH, Jochen
I thought with the double quotes that the single-quote and percent
signs would remain unchanged and the variable $keywords would be
expanded to its value, but I guess I am wrong because i get a parsing
error... Any help for a php newbie?

YEP, lol - the switch from vbscript to php is killing me. Thanks for the help.
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Kai Jaensch | last post by:
Hello, i am an newbie and i have to to solve this problem as fast as i can. But at this time i donīt have a lot of success. Can anybody help me (and understand my english :-))? I have a...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
50
by: z. f. | last post by:
HI, i have string in format dd/mm/yyyyy hh:mm:ss and giving this as an input to DateTime.Parse gives a string was not recognized as a valid date time format string error. how do i make the parse...
9
by: Python.LeoJay | last post by:
Dear all, i need to parse billions of numbers from a file into float numbers for further calculation. i'm not satisfied with the speed of atof() function on my machine(i'm using visual c++ 6)....
4
by: Michael Meckelein | last post by:
Hello, Wondering, if C# (framework 2.0) does not support parsing DateTime timezones in three letter acronyms. I would like to parse date strings like "2005 Nov 01 11:58:47.490 CST -6:00" but...
3
by: dimasteg | last post by:
Hi all C. Nead some help with string "on the fly" parsing, how it can be realized ? Any ideas? I got some of my own, but it's interesting to get other points of view . Regards.
9
balabaster
by: balabaster | last post by:
I'm looking for some ideas regarding string parsing and brackets. Say I have the following string: 56*(73+23/(28+(7/14)-(3/2)) What would be the best way to parse the string for each opening...
6
by: James Arnold | last post by:
Hello, I am new to C and I am trying to write a few small applications to get some hands-on practise! I am trying to write a random string generator, based on a masked input. For example, given...
6
by: (2b|!2b)==? | last post by:
I am expecting a string of this format: "id1:param1,param2;id2:param1,param2,param3;id" The tokens are seperated by semicolon ";" However each token is really a struct of the following...
1
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.