Re: Entering a Query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



thanks for your reply,

What i was after is a way of representing the data, given that you dont know
what columns will be displayed and how many rows etc?

I would only be looking to do 'selects' so how can i ensure that this is the
only type of query run?

Thanks for your help

"Ronan Chilvers" <ronan@thelittledot.com> wrote in message
20030401142044.03fe1fd9.ronan@thelittledot.com">news:20030401142044.03fe1fd9.ronan@thelittledot.com...
> Hi Shaun
>
> Comments inline ...
>
> On 01 Apr,2003 at 13:37 shaun shaun wrote:
>
> <snip>
> > Hi,
> >
> > 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?
> >
> </snip>
>
> Fairly simple At its most basic you have a form :-
>
> <form method="post" action="do_query.php">
> <textarea name="myquery"></textarea>
> <input type="submit" name="submit" value="Submit">
> </form>
>
> which posts to your php page :-
>
> <?php
>
> $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 ... :-)
>
> --
> Ronan
> e: ronan@thelittledot.com
> t: 01903 739 997
> w: www.thelittledot.com
>
> 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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux