real time sql query

real time sql query

am 25.08.2007 00:00:54 von flashvarss

Hi,
I am making a web-based chat but to get the msg from the database i
need to refresh the page and that will make load and extra bandwidth
on the server so i want to make the query in real time ( only the new
msg to be received without refresh the whole page ), Any one in here
knows how to get data from sql database without having to refresh
page?
thanks all for your time

Re: real time sql query

am 25.08.2007 01:02:48 von Toby A Inkster

flashvarss wrote:

> Any one in here knows how to get data from sql database without having
> to refresh page?

Other than periodically refreshing the page, you have two options:

1. Using AJAX to continuously poll the server;
2. The "multipart/x-mixed-replace" MIME type;
3. Server-sent events .

A page refresh will offer the widest range of browser support. AJAX will
work in any reasonably modern browser with Javascript enabled. Multipart/
X-Mixed-Replace is an old Netscape 1.x push technology, which is still
supported in Gecko-based browsers, plus Opera and Safari, but not Internet
Explorer. Server-sent events, although the neatest solution are only
supported by one browser so far -- Opera 9.x -- expect wider browser
support in the future.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 65 days, 2:30.]

TrivialEncoder/0.2
http://tobyinkster.co.uk/blog/2007/08/19/trivial-encoder/

Re: real time sql query

am 25.08.2007 01:53:32 von flashvarss

On Aug 25, 2:02 am, Toby A Inkster
wrote:
> flashvarss wrote:
> > Any one in here knows how to get data from sql database without having
> > to refresh page?
>
> Other than periodically refreshing the page, you have two options:
>
> 1. Using AJAX to continuously poll the server;
> 2. The "multipart/x-mixed-replace" MIME type;
> 3. Server-sent events .
>
> A page refresh will offer the widest range of browser support. AJAX will
> work in any reasonably modern browser with Javascript enabled. Multipart/
> X-Mixed-Replace is an old Netscape 1.x push technology, which is still
> supported in Gecko-based browsers, plus Opera and Safari, but not Internet
> Explorer. Server-sent events, although the neatest solution are only
> supported by one browser so far -- Opera 9.x -- expect wider browser
> support in the future.
>
> --
> Toby A Inkster BSc (Hons) ARCS
> [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
> [OS: Linux 2.6.12-12mdksmp, up 65 days, 2:30.]
>
> TrivialEncoder/0.2
> http://tobyinkster.co.uk/blog/2007/08/19/trivial-encoder/

So ajax is the best then
i have a question now
a simple normal script to call the msg from the database is like that:

Display Messages
<--//
refresh script with no click sound when refreshing


mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("chat") or die(mysql_error());
$data = mysql_query("SELECT * FROM chat") or die(mysql_error());
while($info = mysql_fetch_array( $data )) {
Echo " "said ".$info['words'] . " ";
}?>


Is there an ajax simple example for that?
Thnaks

Re: real time sql query

am 25.08.2007 02:36:33 von Jerry Stuckle

flashvarss wrote:
> On Aug 25, 2:02 am, Toby A Inkster
> wrote:
>> flashvarss wrote:
>>> Any one in here knows how to get data from sql database without having
>>> to refresh page?
>> Other than periodically refreshing the page, you have two options:
>>
>> 1. Using AJAX to continuously poll the server;
>> 2. The "multipart/x-mixed-replace" MIME type;
>> 3. Server-sent events .
>>
>> A page refresh will offer the widest range of browser support. AJAX will
>> work in any reasonably modern browser with Javascript enabled. Multipart/
>> X-Mixed-Replace is an old Netscape 1.x push technology, which is still
>> supported in Gecko-based browsers, plus Opera and Safari, but not Internet
>> Explorer. Server-sent events, although the neatest solution are only
>> supported by one browser so far -- Opera 9.x -- expect wider browser
>> support in the future.
>>
>> --
>> Toby A Inkster BSc (Hons) ARCS
>> [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
>> [OS: Linux 2.6.12-12mdksmp, up 65 days, 2:30.]
>>
>> TrivialEncoder/0.2
>> http://tobyinkster.co.uk/blog/2007/08/19/trivial-encoder/
>
> So ajax is the best then
> i have a question now
> a simple normal script to call the msg from the database is like that:
>
> Display Messages
> <--//
> refresh script with no click sound when refreshing
>
>
> > mysql_connect("localhost", "root", "password") or die(mysql_error());
> mysql_select_db("chat") or die(mysql_error());
> $data = mysql_query("SELECT * FROM chat") or die(mysql_error());
> while($info = mysql_fetch_array( $data )) {
> Echo " "said ".$info['words'] . " ";
> }?>
>
>
> Is there an ajax simple example for that?
> Thnaks
>

Try comp.lang.javascript. AJAX is more javascript than it is PHP (in
fact, you can be running PERL, ASP, etc. on the server - and not even
use PHP).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: real time sql query

am 25.08.2007 10:26:45 von gosha bine

flashvarss wrote:
> On Aug 25, 2:02 am, Toby A Inkster
> wrote:
>> flashvarss wrote:
>>> Any one in here knows how to get data from sql database without having
>>> to refresh page?
>> Other than periodically refreshing the page, you have two options:
>>
>> 1. Using AJAX to continuously poll the server;
>> 2. The "multipart/x-mixed-replace" MIME type;
>> 3. Server-sent events .
>>
>> A page refresh will offer the widest range of browser support. AJAX will
>> work in any reasonably modern browser with Javascript enabled. Multipart/
>> X-Mixed-Replace is an old Netscape 1.x push technology, which is still
>> supported in Gecko-based browsers, plus Opera and Safari, but not Internet
>> Explorer. Server-sent events, although the neatest solution are only
>> supported by one browser so far -- Opera 9.x -- expect wider browser
>> support in the future.
>>
>> --
>> Toby A Inkster BSc (Hons) ARCS
>> [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
>> [OS: Linux 2.6.12-12mdksmp, up 65 days, 2:30.]
>>
>> TrivialEncoder/0.2
>> http://tobyinkster.co.uk/blog/2007/08/19/trivial-encoder/
>
> So ajax is the best then
> i have a question now
> a simple normal script to call the msg from the database is like that:
>
> Display Messages
> <--//
> refresh script with no click sound when refreshing
>
>
> > mysql_connect("localhost", "root", "password") or die(mysql_error());
> mysql_select_db("chat") or die(mysql_error());
> $data = mysql_query("SELECT * FROM chat") or die(mysql_error());
> while($info = mysql_fetch_array( $data )) {
> Echo " "said ".$info['words'] . " ";
> }?>
>
>
> Is there an ajax simple example for that?
> Thnaks
>

AJAX and other html-based solutions are heavy, ugly and incompatible.

Why don't you simply use flash?

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

Re: real time sql query

am 25.08.2007 21:04:54 von Steve

| AJAX and other html-based solutions are heavy, ugly and incompatible.
|
| Why don't you simply use flash?

because flash sux.

hmmm...ajax is 'heavy' and 'ugly'. care to quantify and qualify? oh, and
ajax says, 'whatever you say bounces of me and sticks to you'.

Re: real time sql query

am 26.08.2007 08:41:29 von flashvarss

On Aug 25, 10:04 pm, "Steve" wrote:
> | AJAX and other html-based solutions are heavy, ugly and incompatible.
> |
> | Why don't you simply use flash?
>
> because flash sux.
>
> hmmm...ajax is 'heavy' and 'ugly'. care to quantify and qualify? oh, and
> ajax says, 'whatever you say bounces of me and sticks to you'.

But i want something very fast, example of magma chat server ( you
cant find it now ), its a frame based chat that is very fast to load,
the body of it

body.html - this is the streaming chat frame where the chat will
pop up as people post it. This is done through the
use of a special HTTP header declaring it as a
chunked data transfer...i think (but dont know)

How is that can be done?