Hello, newbie here.

I hope these 2 questions makes sense to someone.

QUESTION 1
+++++++++

I am writing a PHP script which is used to call a web service. In my PHP script I am constructing an SQL statement which is sent to the web service and the plan is to simply return data back to the browser. I am having a problem constructing the WHERE statement when I try to compare TEXT values (comparing NUMERIC values works fine)

Following is an extract of the code that does NOT work;

$queryDefElement .= '<queryDef schema="nms:recipient" xtkschema="xtk:queryDef" operation="select">';
$queryDefElement .= ' <select>';
$queryDefElement .= ' <node expr="@"/>';
$queryDefElement .= ' <node expr="@"/>';
$queryDefElement .= ' <node expr="@mobilePhone"/>';
$queryDefElement .= ' </select>';
$queryDefElement .= ' <where>';
$queryDefElement .= ' <condition expr="@=//'smith//'"/>'; <<<<< ERROR
.....
.....

as you can see I just want to return the records where the last name is smith however I get the following error in my Apace error log

[Wed Aug 13 17:15:47 2008] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected T_LNUMBER in C:\Program Files\Apache Group\Apache2\htdocs\nlws2.php on line 19

If I try to compare numeric values using the following example it works fine;

$queryDefElement .= ' <condition expr="@gender!=0"/>

Therefore my problem looks like it is something to do with the way the quotation marks are handled/constructed in the WHERE statement.

Do any of you know what the correct syntax is to construct the WHERE statement when comparing text values?

QUESTION 2
+++++++++

Relating to question 1 above.

Once I have managed to solve the initial problem I will be using an HTML form that requests the lastname from the user. The HTML form will then call my PHP script and the entered lastname will be used in the generated SQL.

How do I test the value of the entered lastname in the HTML form? Put another way I want to use the entered lastname as the test on the WHERE statement.

My HTML form is very simple.. here is the code..

<html>
<body>

<form action="nlws2.php" method="post">
Enter Name. i.e. smith: <input type="text" name="lastname" />
<input type="Submit" />
</form>

</body>
</html>

Many many thanks for you assistance in advance!

Cheers

Jason

    Write a Reply...