Re: [PHP] Shoutbox suggestion needed

2009-11-17 Thread Michael Kubler
The main issue with these systems is updating the client on a regular 
enough basis.
If the content is time critical, like with Facebook chat, then you need 
to do long polling.


However for a Shoutbox, because it's more like an IRC channel with 
people 'shouting' to a channel, you can probably just set the client to 
automatically update on a regular basis. Or even more advanced, would be 
to get it to check in increasing intervals. Firstly it checks 0.5s 
later, then 1s later, then 2s, 4s, 8s, 16s, with a limit of 60s (i.e it 
checks at least once a minute for an update), upon new content being 
received the time is reset back to the 0.5s


If you need to do long polling http://ajaxpatterns.org/HTTP_Streaming 
then look into the Tornado Webserver http://www.tornadoweb.org/ which 
Friendfeed http://friendfeed.com/, and more recently, Facebook use 
(for their LiveFeed system).
For a PHP based implementation check this out 
http://www.zeitoun.net/articles/comet_and_php/start.





Michael Kubler
*G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz
Mobile : 0433483008

I believe in a better world. I support the Zeitgeist Movement 
http://www.zeitgeistsa.com.




Ashley Sheridan wrote:

On Mon, 2009-11-16 at 12:06 -0500, Paul M Foster wrote:

  

On Mon, Nov 16, 2009 at 02:46:45PM +, Ashley Sheridan wrote:



I don't know of anything you can use like this, especially that runs
purely on Ajax. Just take a look at Facebook chat. That's Ajax, and
fails and falls over on a constant basis to the point where it is almost
useless. Imho, Java seems to be pretty good at this sort of thing, and
there are plenty of free options out there that you could use.
  

It's often been argued back and forth whether people have Javascript
turned off. I suspect the vast majority of people have Javascript turned
on. However, Java is another story. You may find that many more have it
turned off.

Paul

--
Paul M. Foster





Yeah, but then, generally, you can tell the people visiting this site
what they need enabled, as it looks like the visitors are going to be a
select few. Java is available on all the main browsers, and generally
only needs one to accept the applet. For a chat application to be
written using only Ajax technology, well, like I said before, if
Facebook tried it and still can't get it right with all the financial
backing they have, what hope for someone to release this sort of thing
open source and Facebook not be aware of it?

Thanks,
Ash
http://www.ashleysheridan.co.uk



  


[PHP] Re: [php] [mysql] select and subselect

2009-11-17 Thread David Robley
Allen McCabe wrote:

 I have a page on my site where I can optionaly filter by certain fields
 (order by filesize or file category), but I am implementing a shopping
 cart type of idea where users can submit an order.
 
 As administrators, my coworkers and I need to be able to filter orders by
 their contents. For example:
 
 View all orders for Jack and the Beanstalk, where an order may have Jack
 and the Beanstalk and other items.
 
 I have an order table that keeps track of the order_id, the date, the
 status, etc. I also have an order_lineitem table that is the contents of
 the order. This has a one-to-many structure (without foreign keys because
 it is mysql).
 
 I was baffled as to how to filter the orders by the item_id that appears
 in the order_lineitem table.
 
 I just came up with this, but I'm not sure how the mysql_queries will
 handle an array. Do I have to do some extensive regular expression
 management here to get this to work, or will it accept an array?
 
 ?php
 
 if (isset($_POST['showid']))
$showid = $_POST['showid'];
$subSQL = SELECT order_id FROM afy_show_lineitem WHERE show_id =
 {$_POST['showid']};;
$subResult = mysql_query($subSQL);
$where = WHERE;
$extQuery = 'order_id = {$subResult}';
   }
 
 $resultOrders = mysql_query(SELECT * FROM afy_order {$where}
 {$extQuery};) or die(mysql_error(Could not query the database!));
 
 ?
If $_POST['showid'] is likely to be an array, use implode to create a comma
separated string of values, then use IN to build the query.

$ids = implode(',', $_POST['showid'];
$subSQL = SELECT order_id FROM afy_show_lineitem WHERE show_id IN ($ids)

But you need also to check your logic - your query above will have two WHERE
in it and will fail miserably :-) And your call to mysql_error will
probably not help you either, as the (optional) argument should be a link
identifier, not a string of your choosing.



Cheers
-- 
David Robley

MS-DOS: celebrating ten years of obsolescence
Today is Sweetmorn, the 29th day of The Aftermath in the YOLD 3175. 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to call DLL in Javascript

2009-11-17 Thread Peter

Hi All,

I want to call dll in javascript

I tried the following script, but i got the error message 'ActiveXObject 
is undefined'

(Note : i have the feedback.dll in the same path only)


HTML
HEAD
script type='text/javascript' language='javascript'
function comEventOccured()
{

   try{
   var myobject;
   myobject = new ActiveXObject(feedback.dll);
   }catch(e){
   alert(e.description);
   return false;
   }

}
/script/head
body
input  type=button value=Call the DLL  onClick=comEventOccured()
/body
/html



Regards
Peter.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to call DLL in Javascript

2009-11-17 Thread Ashley Sheridan
On Tue, 2009-11-17 at 17:58 +0530, Peter wrote:

 Hi All,
 
 I want to call dll in javascript
 
 I tried the following script, but i got the error message 'ActiveXObject 
 is undefined'
 (Note : i have the feedback.dll in the same path only)
 
 
 HTML
 HEAD
 script type='text/javascript' language='javascript'
 function comEventOccured()
 {
 
 try{
 var myobject;
 myobject = new ActiveXObject(feedback.dll);
 }catch(e){
 alert(e.description);
 return false;
 }
 
 }
 /script/head
 body
 input  type=button value=Call the DLL  onClick=comEventOccured()
 /body
 /html
 
 
 
 Regards
 Peter.
 


I'm not even sure this is possible, and if it is, you know it would only
work on Internet Explorer yeah?

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Re: [php] [mysql] select and subselect

2009-11-17 Thread Nisse Engström
On Mon, 16 Nov 2009 14:21:41 -0800, Allen McCabe wrote:

 I have an order table that keeps track of the order_id, the date, the
 status, etc. I also have an order_lineitem table that is the contents of the
 order. This has a one-to-many structure (without foreign keys because it is
 mysql).

http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html

   InnoDB supports foreign key constraints. ...
 
 I was baffled as to how to filter the orders by the item_id that appears in
 the order_lineitem table.
 
 I just came up with this, but I'm not sure how the mysql_queries will handle
 an array. Do I have to do some extensive regular expression management here
 to get this to work, or will it accept an array?
 
 ?php
 
 if (isset($_POST['showid']))
$showid = $_POST['showid'];
$subSQL = SELECT order_id FROM afy_show_lineitem WHERE show_id =
 {$_POST['showid']};;
$subResult = mysql_query($subSQL);
$where = WHERE;
$extQuery = 'order_id = {$subResult}';
   }
 
 $resultOrders = mysql_query(SELECT * FROM afy_order {$where} {$extQuery};)
 or die(mysql_error(Could not query the database!));

[[ Note: You should probably have posted to the php-db list
   (or the php.db newsgroup) to increase the chance of
   getting responses from people who actually know what
   they're talking about. I'm a MySQL newbie... ]]


$subResult is a resource. You need to fetch the results
before you can use them like this. Maybe something like:


  /* UNTESTED */

  /* Don't forget to escape! Some will argue that
 you are better off using prepared statements. */
  $showid = mysql_real_escape_string ($_POST['showid']);

  $q = _
SELECT `order_id` FROM `afy_show_lineitem`
 WHERE `show_id` = '$showid';
_;

  $res = mysql_query ($q);
  if ($res) {
while ($row = mysql_fetch_row ($res)) {
  $ids[] = $row[0]; /* Assuming numerical ids. */
}
$ids_spec = implode (',', $ids);
mysql_free_result ($res);
  } else {
/* Handle error */
  }

  if (isset ($ids_spec)) {
$q = _
SELECT * FROM `afy_order`
 WHERE `order_id` IN ($ids_spec)
_;
$res = mysql_query ($q);
if ($res) {
  /* Do stuff */
} else {
  /* Handle error */
}
  }


But you could also do it in one query (*untested*):

  /* UNTESTED */

  SELECT `ao`.* FROM `afy_order` AS `ao`,
 `afy_show_lineitem` AS `asl`
   WHERE  `ao`.`show_id`  =  $show_id
 AND `asl`.`order_id` = `ao`.`show_id`


Or maybe there are better ways, such as using INNER JOIN,
but those sometimes end up using a temporary table...
(Hint: php-db, php.db, php-db, ...)


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to call DLL in Javascript

2009-11-17 Thread Phpster
I don't think you can di this with client side js. It would have to  
run outside the security sandbox and that is a bug no-no.


If the dll is in the server, you could potentially call the server via  
Ajax to instantiate the dll and have it's output sent to the browser


Bastien

Sent from my iPod

On Nov 17, 2009, at 7:28 AM, Peter pet...@egrabber.com wrote:


Hi All,

I want to call dll in javascript

I tried the following script, but i got the error message  
'ActiveXObject is undefined'

(Note : i have the feedback.dll in the same path only)


HTML
HEAD
script type='text/javascript' language='javascript'
function comEventOccured()
{

  try{
  var myobject;
  myobject = new ActiveXObject(feedback.dll);
  }catch(e){
  alert(e.description);
  return false;
  }

}
/script/head
body
input  type=button value=Call the DLL  onClick=comEventOccured()
/body
/html



Regards
Peter.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: How to make the PHP know the real SCRIPT_FILENAME?

2009-11-17 Thread Nathan Rixham
Dong Wang wrote:
 I am trying to use PHP as backend, which communicate with apache-2.3's
 mod_proxy_fcgi
 
 But I have noticed that the SCRIPT_FILENAME has been changed to
 proxy:balancer://xx, it cann't be recognized by  the remote PHP
 backend. So the request failed.
 In my opinion, the remote PHP backend use the SCRIPT_FILENAME to find the
 script file. But the PHP and the Apache may be in different computer, so the
 Document Root may be different. is that means the PHP shouldn't rely on the
 SCRIPT_FILENAME?
 
 how can I configure the PHP to know the real script file to execute?
 
 Thank you
 


$real_script_file = __FILE__;

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: How to call DLL in Javascript

2009-11-17 Thread Nathan Rixham
Peter wrote:
 Hi All,
 
 I want to call dll in javascript
 
 I tried the following script, but i got the error message 'ActiveXObject
 is undefined'
 (Note : i have the feedback.dll in the same path only)
 
 
 HTML
 HEAD
 script type='text/javascript' language='javascript'
 function comEventOccured()
 {
 
try{
var myobject;
myobject = new ActiveXObject(feedback.dll);
}catch(e){
alert(e.description);
return false;
}
 
 }
 /script/head
 body
 input  type=button value=Call the DLL  onClick=comEventOccured()
 /body
 /html
 
 
 
 Regards
 Peter.

usually .dll should be running client side not server side

jscript and javascript are two different beasts based on ecmascript;
you'll be wanting to get some JScript (microsofts own version) help for
this.. http://msdn.microsoft.com/en-us/library/7sw4ddf8%28VS.85%29.aspx
but as somebody else mentioned, you won't get it working on all browsers
AFAIK.. so running DLL on server side and calling wrapper functions via
ajax is more appropriate.

an asp.net forum or suchlike will probably yield a more useful response

regards

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP httpd debug question

2009-11-17 Thread Devendra Jadhav
Hi,
I am not getting what are you asking but if you want to run two httpd then
you have to run those on different ports.
For this you can change Listen 80 to Listen 2020 from httpd.conf file.
So that one server will run on 80 and other will run on 2020.
you can change 2020 to whatever port you want .. but check if that port is
not already assigned to some other application.


On Tue, Nov 17, 2009 at 5:35 AM, John Beaulaurier -X (jbeaulau - Advanced
Network Info at Cisco) jbeau...@cisco.com wrote:

 Hello,



 phpMyAdmin crashes when access is attempted each time, and I need to run
 an httpd backtrace. I have a question though.



 There is another httpd instance running on the same host. If I run httpd
 -X will it interfere with the other httpd process running, or will

 it be a separate process?



 Thanks

 -John




-- 
Devendra Jadhav
देवेंद्र जाधव


RE: [PHP] PHP httpd debug question

2009-11-17 Thread John Beaulaurier -X (jbeaulau - Advanced Network Info at Cisco)
Hi Devendra

 

That’s sounds like what I’m looking for. I don’t want to interfere with the 
current httpd process serving content while running the debug. 

 

Thanks

-John 

 

From: Devendra Jadhav [mailto:devendra...@gmail.com] 
Sent: Tuesday, November 17, 2009 5:57 AM
To: John Beaulaurier -X (jbeaulau - Advanced Network Info at Cisco)
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP httpd debug question

 

Hi,
I am not getting what are you asking but if you want to run two httpd then you 
have to run those on different ports.
For this you can change Listen 80 to Listen 2020 from httpd.conf file.
So that one server will run on 80 and other will run on 2020.
you can change 2020 to whatever port you want .. but check if that port is not 
already assigned to some other application. 



On Tue, Nov 17, 2009 at 5:35 AM, John Beaulaurier -X (jbeaulau - Advanced 
Network Info at Cisco) jbeau...@cisco.com wrote:

Hello,



phpMyAdmin crashes when access is attempted each time, and I need to run
an httpd backtrace. I have a question though.



There is another httpd instance running on the same host. If I run httpd
-X will it interfere with the other httpd process running, or will

it be a separate process?



Thanks

-John




-- 
Devendra Jadhav
देवेंद्र जाधव 



Re: [PHP] PHP httpd debug question

2009-11-17 Thread Nathan Rixham
John Beaulaurier -X (jbeaulau - Advanced Network Info at Cisco) wrote:
 That’s sounds like what I’m looking for. I don’t want to interfere with the 
 current httpd process serving content while running the debug. 
 

http://www.google.com/search?q=multiple+apache+instances

note: setting only the same instance to listen on port 2020 or suchlike
as well won't help you here, you need 2 instances

also see: http://httpd.apache.org/dev/debugging.html#crashes

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: How to make the PHP know the real SCRIPT_FILENAME?

2009-11-17 Thread Dong Wang
ur... you mean use this in the php script?
but the php-cgi still doesn't know which scriptfile to execute, isn't it?

php-cgi tries to find the aimed script using SCRIPT_FILENAME, but this
variable is changed by the mod_proxy_fcgi, so php-cgi can not find the real
scriptfile, that's the point, I think.

Or maybe there is something I misunderstand?

On Tue, Nov 17, 2009 at 9:19 PM, Nathan Rixham nrix...@gmail.com wrote:

 Dong Wang wrote:
  I am trying to use PHP as backend, which communicate with apache-2.3's
  mod_proxy_fcgi
 
  But I have noticed that the SCRIPT_FILENAME has been changed to
  proxy:balancer://xx, it cann't be recognized by  the remote PHP
  backend. So the request failed.
  In my opinion, the remote PHP backend use the SCRIPT_FILENAME to find the
  script file. But the PHP and the Apache may be in different computer, so
 the
  Document Root may be different. is that means the PHP shouldn't rely on
 the
  SCRIPT_FILENAME?
 
  how can I configure the PHP to know the real script file to execute?
 
  Thank you
 


 $real_script_file = __FILE__;



[PHP] Pear include path problem

2009-11-17 Thread Al
I've got script that uses the pear Mail class and have had problems on some 
shared hosts with the include path to Mail. E.g., Blue Host insists the site 
owner must change the php.ini file. I'd rather not expect them to do that.


Can you folks critique this approach for me.

if(EMAIL_MODE=='smtp'){
 $basePath = str_ireplace('public_html', '', $_SERVER['DOCUMENT_ROOT']);
 set_include_path(get_include_path() . PATH_SEPARATOR . basePath);
 require_once $basePath/php . '/Mail.php';
 $smtpStatus=(class_exists('Mail'))?true:false;
}

Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Pear include path problem

2009-11-17 Thread Jim Lucas
Al wrote:
 I've got script that uses the pear Mail class and have had problems on
 some shared hosts with the include path to Mail. E.g., Blue Host insists
 the site owner must change the php.ini file. I'd rather not expect them
 to do that.
 
 Can you folks critique this approach for me.
 
 if(EMAIL_MODE=='smtp'){
  $basePath = str_ireplace('public_html', '', $_SERVER['DOCUMENT_ROOT']);
  set_include_path(get_include_path() . PATH_SEPARATOR . basePath);
  require_once $basePath/php . '/Mail.php';
  $smtpStatus=(class_exists('Mail'))?true:false;
 }
 
 Thanks
 

How about this

# Check to see if the constant is defined BEFORE you try to use it.
if ( defined('EMAIL_MODE')  EMAIL_MODE == 'smtp' ) {

  # You might want to do more checking on the path.  Checking to see if it
  # has double forward slashes at the end would be the first place to start
  $basePath = str_ireplace('public_html', '', $_SERVER['DOCUMENT_ROOT']);

  # IMO, no improvement needed here
  set_include_path(get_include_path() . PATH_SEPARATOR . $basePath);

  # Well, it is what it is
  $filename = {$basePath}/php/Mail.php;

  # Check to see if file exists and is readable BEFORE you try including it
  if ( is_file($filename)  is_readable($filename) ) {
require_once $filename;
$smtpStatus=(class_exists('Mail'))?true:false;
  } else {
$smtpStatus = false;
  }
}

Jim Lucas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Pear include path problem

2009-11-17 Thread Al



Jim Lucas wrote:

Al wrote:

I've got script that uses the pear Mail class and have had problems on
some shared hosts with the include path to Mail. E.g., Blue Host insists
the site owner must change the php.ini file. I'd rather not expect them
to do that.

Can you folks critique this approach for me.

if(EMAIL_MODE=='smtp'){
 $basePath = str_ireplace('public_html', '', $_SERVER['DOCUMENT_ROOT']);
 set_include_path(get_include_path() . PATH_SEPARATOR . basePath);
 require_once $basePath/php . '/Mail.php';
 $smtpStatus=(class_exists('Mail'))?true:false;
}

Thanks



How about this

# Check to see if the constant is defined BEFORE you try to use it.
if ( defined('EMAIL_MODE')  EMAIL_MODE == 'smtp' ) {

  # You might want to do more checking on the path.  Checking to see if it
  # has double forward slashes at the end would be the first place to start
  $basePath = str_ireplace('public_html', '', $_SERVER['DOCUMENT_ROOT']);

  # IMO, no improvement needed here
  set_include_path(get_include_path() . PATH_SEPARATOR . $basePath);

  # Well, it is what it is
  $filename = {$basePath}/php/Mail.php;

  # Check to see if file exists and is readable BEFORE you try including it
  if ( is_file($filename)  is_readable($filename) ) {
require_once $filename;
$smtpStatus=(class_exists('Mail'))?true:false;
  } else {
$smtpStatus = false;
  }
}

Jim Lucas


Thanks for the feedback.  That's big help. I'm sending this revised code to my 
client to install on his Bluehost server.


Actually, I do check if EMAIL_MODE is defined; just didn't show it here.

And, I have debug mode that provides a more detailed error report. But, it 
doesn't help if it can't even find Mail


if (PEAR::isError($result))
{
$mode = EMAIL_MODE;

throw new Exception(The email mode \$mode\ does not work. Check the 
Applic email address and password in config file. br /
Tech support required, use DISABLE_MAIL_SEND to debug. Error found in 
pearEmailSend().br / .

$result-getMessage());
}




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to call a vc++ dll from a HTML form

2009-11-17 Thread Peter

Thanks to All.

I want to call a vc++ dll from a HTML form. The dll need to be triggered 
on a button click in the HTML form.


I want to access the dll from the client end(javascrript) without using 
the server.


Tell me whether its possible to call dll directly or through any interface ?

Please provide me your valuable inputs to solve this issue.

Regards
Peter

Nathan Rixham wrote:

Peter wrote:
  

Hi All,

I want to call dll in javascript

I tried the following script, but i got the error message 'ActiveXObject
is undefined'
(Note : i have the feedback.dll in the same path only)


HTML
HEAD
script type='text/javascript' language='javascript'
function comEventOccured()
{

   try{
   var myobject;
   myobject = new ActiveXObject(feedback.dll);
   }catch(e){
   alert(e.description);
   return false;
   }

}
/script/head
body
input  type=button value=Call the DLL  onClick=comEventOccured()
/body
/html



Regards
Peter.



usually .dll should be running client side not server side

jscript and javascript are two different beasts based on ecmascript;
you'll be wanting to get some JScript (microsofts own version) help for
this.. http://msdn.microsoft.com/en-us/library/7sw4ddf8%28VS.85%29.aspx
but as somebody else mentioned, you won't get it working on all browsers
AFAIK.. so running DLL on server side and calling wrapper functions via
ajax is more appropriate.

an asp.net forum or suchlike will probably yield a more useful response

regards

  


Re: [PHP] How to call a vc++ dll from a HTML form

2009-11-17 Thread James McLean
On Wed, Nov 18, 2009 at 3:21 PM, Peter pet...@egrabber.com wrote:
 Thanks to All.

 I want to call a vc++ dll from a HTML form. The dll need to be triggered on
 a button click in the HTML form.

 I want to access the dll from the client end(javascrript) without using the
 server.

 Tell me whether its possible to call dll directly or through any interface ?

 Please provide me your valuable inputs to solve this issue.

What does this have to do with PHP?

Oh, and it's a bad idea. Don't do it...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php