473,499 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parameters to SQL statements

I'm new to PHP. I have successfully set up a small script which pulls
data out of an Access database and puts it in an HTML page, using an SQL
query:
"SELECT * FROM ZWobservations WHERE Country = 'CY'"

I now want to parameterise this, like:
"SELECT * FROM ZWobservations WHERE Country = ?"

but have not managed to work out how to get this running. I'm getting
errors like:
"Warning: SQL error: [Microsoft][ODBC Microsoft
Access-stuurprogramma]Het veld COUNT is onjuist , SQL state 07001 in
SQLExecute"

The PHP manual is short on examples (to put it mildly) and Googling for
a tutorial or working example has had a surprising lack of success -
apparently I'm choosing just the wrong search terms.

Could someone point me to a working example / tutorial?

--
Stephen Poley
Barendrecht, Holland
Jul 16 '05 #1
2 9880
Try something like:

$parm = "CY";
$sql = "SELECT * FROM ZWobservations WHERE Country = '$parm'";

also take a look at the sql statement "select * from x where y like
'%test%'"

hope this helps

On Fri, 18 Jul 2003 13:36:29 +0200, Stephen Poley wrote:
I'm new to PHP. I have successfully set up a small script which pulls data
out of an Access database and puts it in an HTML page, using an SQL query:
"SELECT * FROM ZWobservations WHERE Country = 'CY'"

I now want to parameterise this, like: "SELECT * FROM ZWobservations WHERE
Country = ?"

but have not managed to work out how to get this running. I'm getting
errors like:
"Warning: SQL error: [Microsoft][ODBC Microsoft Access-stuurprogramma]Het
veld COUNT is onjuist , SQL state 07001 in SQLExecute"

The PHP manual is short on examples (to put it mildly) and Googling for a
tutorial or working example has had a surprising lack of success -
apparently I'm choosing just the wrong search terms.

Could someone point me to a working example / tutorial?


Jul 16 '05 #2
On Fri, 18 Jul 2003 13:44:01 +0200, "sotto" <ju**@sotto.be> wrote:
Try something like:

$parm = "CY";
$sql = "SELECT * FROM ZWobservations WHERE Country = '$parm'";

also take a look at the sql statement "select * from x where y like
'%test%'"

hope this helps


Well, yes I can do it that way of course. But it seems to render the
odbc_prepare and odbc_execute calls rather redundant - to say nothing of
the parameters_array parameter to odbc_execute. One ends up using
odbc_exec the whole time. I've done it using SQL parameters in Perl, and
the PHP manual certainly makes it look as if the intention is to do it
similarly, but I'm missing out on the fine detail somewhere.

--
Stephen Poley
Barendrecht, Holland
Jul 16 '05 #3

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

Similar topics

6
2582
by: Lauren Quantrell | last post by:
Is it possible the existence of a return parameter on an SP running insert statements would cause blocking to happen (any removing it might help eliminate it?) The SPs in question have three...
2
10850
by: Grant Stanley | last post by:
I'm writing a database client program in C#, and it accesses a MS SQL V7 database. In one part of my program I am using a SqlCommand class to run a SQL Statement, the command text uses parameters,...
2
3431
by: Mark | last post by:
Hi all, a quick ADO.NET question in regards to the command object. What are the advantages (if any) of specifying command parameters when executing a stored procedure over just calling the stored...
2
1851
by: Rob Meade | last post by:
Hi all, I was wondering if anyone could give me a small example of running a stored procedure with both output and input parameters via asp.net (vb). I have tried a couple of things, one of...
2
2079
by: tshad | last post by:
When I normally set up my Sql statements and parameters, I would normally do: Dim objCmd as New SqlCommand("AddNewResumeCoverTemplate",objConn) objCmd.CommandType = CommandType.StoredProcedure...
1
8805
by: Mikey G | last post by:
Hi, I created a simple VB.NET 2003 application through Visual Studio that connects to a MySQL database and loads a table into a Dataset, and then displays that table information in a DataGrid on a...
16
1632
by: Rob Somers | last post by:
Say I have the following code: void foo(int some_int); ..... int x = 5; foo(x); ..... void foo(int some_int) {
1
5675
by: stjulian | last post by:
If inside a stored procedure, there a SELECT statement to return a recordset and another SELECT to set the value of an output parameter (as in SELECT @OutValue = Name FROM table WHERE pkid=5),...
5
2340
by: ric_deez | last post by:
Hi there, I would like to create a simple search form to allow users to search for a job number based on a number of parameters. I think I understand how to use parameteres associated with Stored...
0
1159
by: =?Utf-8?B?VGVycnkgSG9sbGFuZA==?= | last post by:
I have written a stored procedure in SQL 2005 as below. When I call this procedure from QA with the SQL QA Test code the value of @strNewRef is returned correctly with my limited amount of...
0
7130
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
7171
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,...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.