Comments inline ...
On 01 Apr,2003 at 13:37 shaun shaun wrote:
> I would be very interested to see an example of how it would be possible to
> enter a query into a text area and the results of the query displayed on the
> next page, similar to PHP admin I guess, are they any examples out there?
Fairly simple At its most basic you have a form :-
<form method="post" action="do_query.php">
<input type="submit" name="submit" value="Submit">
which posts to your php page :-
$sql = $HTTP_POST_VARS["myquery"];
// You'll need code here to sanitize the query and make sure there's
// no nasty surprises in it.
// then simply create your connection (assuming a function here)
$conn = db_connect();
$result = mysql_query($sql);
// Code to display the result here
You would need to have some checking involved for the query. Also, as always, apply
'least privilege' to the user the query runs as. I don't know what you're using it
for but be VERY careful - I would only allow selects here unless you're sure you know
how it will be used.
Hope this helps ... :-)
e: [EMAIL PROTECTED]
t: 01903 739 997
The Little Dot is a partnership of
Ronan Chilvers and Giles Webberley
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php