473,396 Members | 1,967 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,396 software developers and data experts.

how to retrieve data from mysql via php form (how to pass whole query in parameter)

need my php page to be more like an interface to mysql. how can I use a text box to insert full sql query which is passed into parameter and get me a data I am asking for? I need my input to be whole query from start to the end.

thanks
Feb 14 '11 #1
4 2604
code green
1,726 Expert 1GB
You would pass a whole query the same way as passing one piece of data.
But this is not very secure and maybe large strings are unreliable.
Which part of this process is causing problems?
Feb 14 '11 #2
$query ="SELECT * from table where id='1' AND name LIKE '$form_input'";
I want $form_input - to be the whole query. means I need to send actual SQL statement from the form. in my text field I want to be able to type: select * from table where..., submit the form and get result displayed by php. Any chance sth like this would work: $query = $form_input. I also know it's not a secure way to do this but that's the only idea I've got... and by the way: it's going to be sth like SQL tutorial - user types statement and if data is not retreived then error instead.
thank you in advance
Feb 14 '11 #3
Dormilich
8,658 Expert Mod 8TB
means I need to send actual SQL statement from the form.
never, ever do that. server-side code must not be leaked to the client (this is like posting your root password on the web).
Feb 15 '11 #4
code green
1,726 Expert 1GB
The usual way would be for the user to fill in textboxes, then when form is submitted, process this and build the query 'live-time'.
So in process_form.php something like
Expand|Select|Wrap|Line Numbers
  1. $form_input = $_POST['form_input']; #cleanse/validate data here
  2. $id = $_POST['form_input'];#cleanse/validate data here
  3. $query ="SELECT * from table where id='$id' AND name LIKE '$form_input'";
I am not sure what you are trying to achieve with your whole query idea.
Feb 15 '11 #5

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

Similar topics

3
by: Paradigm | last post by:
I want to create a pass through query in Access to get data from a MYSQL table. I need to do this using code so that sertain aspects of the query can be changed. When I look at the SQL version of...
1
by: ED | last post by:
I currently have an ODBC query that hits an Oracle database. I want to bring back records for a given month based on a job completion date in the Oracle database. I would like to have the user...
2
by: Galina | last post by:
Hello I need to get data from 4 Oracle tables and combine them into a temporary table in my application. I get data using a pass-through query dynamically created in code: mySQL = "SELECT...
3
by: Uwe | last post by:
Howdy! I've googled and googled for this without success, and either it's so easy that nobody has ever asked, or there is some serious reason nobody would do this. But I'm going to ask anyway....
1
by: woody | last post by:
I have a bit of a newbie question (basically stated in the subject of the posting). If need to get some data out of a SQL Server Database. Can I use a control from a form to supply a parameter. ...
4
by: Amar | last post by:
Hi All, I need to select data from a database table containing huge amount of data. Now I am storing data using one primary key and I am just using simple select statement, and this process...
2
by: Bob Alston | last post by:
If you have an access form with record source being a straightforward query and where clause in the form definition, will the query be sent to the back end jet/Access database and executed there,...
20
by: exipnakias | last post by:
Hello Guys. In a form I created a listbox which looks up the values of a table. I want: 1) ..to create a query where a parameter will be needed in order to be loaded. But I do not want to...
4
by: Rasha Farouk | last post by:
Peace upon u all I wanna know how to retrieve data from db and pass it to form controls.
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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...
0
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,...

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.