473,508 Members | 2,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

quering a database using mysql/php

1 New Member
i want to display data in a table based on the user selection from a form (on a previous page).

my query isnt working:

$sth = $conn->prepare ('SELECT * FROM ROUTE WHERE ORIGIN = $ORIG');

the $ORIG is the value of the options inside the drop down list. (its the value of one option in the form on the previous page)
Aug 27 '14 #1
1 1177
Dormilich
8,658 Recognized Expert Moderator Expert
it’s not working because prepared statements don’t work like that.

example usage (PDO):
Expand|Select|Wrap|Line Numbers
  1. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  2. $stmt = $conn->prepare('SELECT * FROM ROUTE WHERE ORIGIN = ?');
  3. // assuming string type parameter
  4. $stmt->bindValue(1, $ORIG, PDO::PARAM_STR);
  5. $stmt->execute();
  6. foreach ($stmt as $row) {
  7.     // do something with $row
  8. }
  9.  
Aug 27 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2138
by: Shun | last post by:
Hello, I am new to .net Platform. I want to build a sample application using VB.net and backend mysql. now my problem is how to connect to the mysql database. which is the better provider(...
14
2875
by: Ben | last post by:
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one...
9
3166
by: christopher_board | last post by:
Hi all. I am trying to connect to a MySQL Database using PHP on a local machine using locahost. I am using the following code <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass =...
3
5210
by: Suresh P | last post by:
Hi All, I tried to access the mysql database in ODBC using ip address and username/password. It returns, "cannot connect to MySQL server on IP ADDRESS(10060)". This could be related to Firewall...
0
1452
by: John Kirkpatrick | last post by:
Hi all, I am having difficulty displaying records on a frontend MS Access 2000 form using a MySQL backend. The following code works well with the Jet database engine but doesn't work properly...
221
366982
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
0
1337
by: prakashghai | last post by:
After spending 3 days on internet and struggling with so many different forums , i have found a match and similar case of my problem here. Friends, I am zero in PHP, but still i have managed to do...
1
12117
by: santhanalakshmi | last post by:
Hi, I wrote some coding, to import excel data in mysql database using PHP Script? But my script, its not all inserting the excel data in mysql database. I don't know, what mistake did i made?...
0
2268
by: BSBabu | last post by:
Hi .... I'm a newbie to Asp.Net and MySql. I'm Trying to upload & Download .pptx,.docx,.pdf,.txt files into MySql Database. They are uploading successfully but when I'm trying to download...
0
7229
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
7129
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...
0
7398
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...
0
7502
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...
1
5057
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
4716
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
1566
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 ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
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.