473,626 Members | 3,041 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 9896
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.b e> 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_arra y 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
2597
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 INSERT INTO statements using an @@IDENTITY to help populate the second and third tables based on the PK of the newly inserted record in the first INSERT INTO Statement. I have recently stared to receive timeout errors in a multi-user enviroment and...
2
10861
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, but these do not seem to be functioning (as it does not find the record), it's probably some really stupid error I've made, but I've spend several hours trying to find it and its now driving me crazy. Also something very similar else where in the...
2
3440
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 procedure via dynamic SQL? // Pseudo code below using dynamic SQL private void InsertPerson(string sName) { SqlCommand myCommand = new SqlCommand(........ // Build the dynamic SQL
2
1858
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 which worked, but now I'm trying to change my code so that its the 'proper' way of doing things.. My stored proc expects the following:
2
2087
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 objCmd.parameters.add("@ClientID",SqldbType.VarChar,20).value = session("ClientID") objCmd.parameters.add("@Email",SqlDbType.VarChar,45).value = session("Email")
1
8821
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 form for editing. The table fill works fine, the delete function works fine, but when I try to update a row, the application fails with the following error message: An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in...
16
1647
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
5702
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), would 2 execute statements be needed to return the OUTPUT parameter? Like this? adocmd.CommandTimeout = 120 adocmd.ActiveConnection = conn
5
2353
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 Procedures with a data reader to add various parameters. However, if I have a stored procedure such as CREATE usp_SelectfromJobNumbers (@par1 datatype, @par2 datatype, @par3 datatype)
0
1176
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 testing thus far. When I try to use this procedure from my vb code im getting some unexpected results. Using the "VB Code Not Working" code I get incorrect results. The value returned into m_strNewRef is only ever 1 char long
0
8259
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8192
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8358
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4090
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1504
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.