php-general Digest 4 Feb 2009 07:58:51 -0000 Issue 5939

2009-02-04 Thread php-general-digest-help

php-general Digest 4 Feb 2009 07:58:51 - Issue 5939

Topics (messages 287566 through 287594):

Throwing an exception seems to defeat output buffering
287566 by: Wickland, Leif
287568 by: Stuart
287573 by: Shawn McKenzie
287579 by: Alpár Török

Re: calculate the time that day ends
287567 by: Stuart
287569 by: Dan Shirah
287570 by: Thodoris
287571 by: Shawn McKenzie
287572 by: Jônatas Zechim
287574 by: Shawn McKenzie
287575 by: Thodoris
287576 by: Shawn McKenzie
287577 by: Shawn McKenzie
287578 by: Thodoris
287580 by: Ralf Meyer
287583 by: tedd
287594 by: Lupus Michaelis

Re: How can I do the opposite of property_exists(), maybe a creat_property() in 
PHP5?
287581 by: Daevid Vincent
287582 by: Daevid Vincent
287584 by: Chris

Re: [PROJECT HELP] - JotBug - A Project Management  Issue Tracker written 100% 
with Zend Framework
287585 by: rcastley

Is it possible to send POST vars through a header redirect?
287586 by: TS
287587 by: Jim Lucas
287588 by: Kyle Terry
287589 by: VamVan

Re: How can I do the opposite of property_exists(), maybe a create_property() 
in PHP5?
287590 by: Daevid Vincent
287591 by: Nathan Nobbe

Re: Visibility of class constant
287592 by: leledumbo
287593 by: Shawn McKenzie

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
I would expect that if I turn on output buffering, echo something, throw an 
exception, and catch the exception, nothing will have been actually output..  
That doesn't seem to be the case.  Throwing an exception seems to defeat output 
buffering.

In the following code, I would not expect to see the h1, but I do.



?
try {
ob_start();
echo 'h1You should not see this!/h1';
throw new Exception('h2This should be the first output./h2');
exit( 'Contents: ' . ob_get_clean());
}
catch (Exception $ex) {
exit('h2Exception:/h2' . $ex-getMessage());
}




I'm exercising that code on PHP 5.2.4 and 5.2.8.

Does anybody know why throwing an exception seems to override ob_start(), 
flushing the buffered output?

Thank you,

Leif Wickland
---End Message---
---BeginMessage---
2009/2/3 Wickland, Leif lwickl...@rightnow.com:
 I would expect that if I turn on output buffering, echo something, throw an 
 exception, and catch the exception, nothing will have been actually output..  
 That doesn't seem to be the case.  Throwing an exception seems to defeat 
 output buffering.

 In the following code, I would not expect to see the h1, but I do.



 ?
 try {
ob_start();
echo 'h1You should not see this!/h1';
throw new Exception('h2This should be the first output./h2');
exit( 'Contents: ' . ob_get_clean());
 }
 catch (Exception $ex) {
exit('h2Exception:/h2' . $ex-getMessage());
 }


 I'm exercising that code on PHP 5.2.4 and 5.2.8.

 Does anybody know why throwing an exception seems to override ob_start(), 
 flushing the buffered output?

It doesn't, but the end of the script performs an implicit flush.

-Stuart

-- 
http://stut.net/
---End Message---
---BeginMessage---
Wickland, Leif wrote:
 I would expect that if I turn on output buffering, echo something, throw an 
 exception, and catch the exception, nothing will have been actually output..  
 That doesn't seem to be the case.  Throwing an exception seems to defeat 
 output buffering.
 
 In the following code, I would not expect to see the h1, but I do.
 
 
 
 ?
 try {
 ob_start();
 echo 'h1You should not see this!/h1';
 throw new Exception('h2This should be the first output./h2');
 exit( 'Contents: ' . ob_get_clean());
 }
 catch (Exception $ex) {
 exit('h2Exception:/h2' . $ex-getMessage());
 }
 
 
 
 
 I'm exercising that code on PHP 5.2.4 and 5.2.8.
 
 Does anybody know why throwing an exception seems to override ob_start(), 
 flushing the buffered output?
 
 Thank you,
 
 Leif Wickland

Others have told you why, so these will work as you want (depending upon
what you want :)  You can use ob_end_clean() unless you need the
contents of the buffer.  I assigned the return of ob_get_contents() to a
var because I assume you have the exits() for testing.

?
try {
ob_start();
echo 'h1You should not see this!/h1';
$buffer = ob_get_clean();
throw new Exception('h2This should be the first output./h2');
}
catch (Exception $ex) {
exit('h2Exception:/h2' . $ex-getMessage());
}


-- or --


?
try {
ob_start();
echo 'h1You should not see this!/h1';
throw new Exception('h2This should be the first output./h2');
}
catch (Exception 

Re: [PHP] Is it possible to send POST vars through a header redirect?

2009-02-04 Thread Stuart
2009/2/3 TS sunnrun...@gmail.com:
 I'm trying to send vars via POST somehow. Is this possible?

 Currently I'm doing

 header(Location: http://domain/index.php?var=3;);

 but, want to send POST or some other method that doesn't stick with the 
 session.

I'm not sure what you mean by stick with the session. What exactly
are you trying to achieve?

-Stuart

-- 
http://stut.net/

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



[PHP] why does a html mail send as text ?

2009-02-04 Thread Bulend Kolay

I use php-5.2.6 and apache2.2.x on opensuse11

I have a file called mailsend.php to send a mail of html format.
the server sends the mail form of html format. But I get it as text instead 
of html.

default_mimetype is set as text/html in php.ini file.

How can I correct this ?





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



Re: [PHP] Is it possible to send POST vars through a header redirect?

2009-02-04 Thread Stuart
2009/2/4 Jônatas Zechim zechim@gmail.com:
 Try curl

1) I really wish people would look at other replies to a post before
sending their own. Duplicates are rarely useful.

2) CURL cannot perform a header redirect as the OP is asking for, so
the more useful response is to ask what they're actually trying to
achieve because they're wanting to know how to do something that's not
possible so the question is flawed.

Rant over.

-Stuart

 -Mensagem original-
 De: Stuart [mailto:stut...@gmail.com]
 Enviada em: quarta-feira, 4 de fevereiro de 2009 07:52
 Para: TS
 Cc: php-general@lists.php.net
 Assunto: Re: [PHP] Is it possible to send POST vars through a header redirect?

 2009/2/3 TS sunnrun...@gmail.com:
 I'm trying to send vars via POST somehow. Is this possible?

 Currently I'm doing

 header(Location: http://domain/index.php?var=3;);

 but, want to send POST or some other method that doesn't stick with the 
 session.

 I'm not sure what you mean by stick with the session. What exactly
 are you trying to achieve?

 -Stuart

 --
 http://stut.net/

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



Re: [PHP] How can I do the opposite of property_exists(), maybe a create_property() in PHP5?

2009-02-04 Thread Stuart
2009/2/3 Daevid Vincent dae...@daevid.com:
 On Wed, 2009-02-04 at 08:58 +1100, Chris wrote:

  the question is what is __set() doing, if it's throwing an exception
  for undefined properties then obviously it with 'blow up'.
 
 
 
  But why should __set() even be called if I'm accessing the property
  directly? This seems stupid.
 
  $this-oraclecustomerid =  1122;
 
  should NOT be the same as
 
  $this-set_oraclecustomerid(1122);
 
  The second one I agree should call __set(), but the first one should NOT
  be triggering __call() or __set()

 Yes it should.

 http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members

 __set() is run when writing data to inaccessible members.

 if it's a protected/private variable, it'll call __set.

 If it's a variable that doesn't exist, it'll call __set.



 Let me rephrase that. I see now that it is designed that way, but I
 think the logic is erroneous.  While I'm sure this argument/discussion
 is all for naught now, I believe that a straight assignment of a value
 to a variable, SHOULD NOT do any behind the scenes magic __set(). It
 should just do it. Otherwise, what's the point of being able to set a
 property/variable both ways? One gives no benefit over the other and as
 illustrated decreases flexibility. It appears it will work if I change
 my property to public, but I don't want them exposed like that. *sigh*

 Bottom line is there should be a create_property($name, $value = null,
 $type = 'protected') function/method that I can call to do what I'm
 trying to do.

 I assume unset($this-foo); works. So therefore, I can check for
 existence of a property, and consequently remove a property, but I
 cannot create a property.

In PHP class properties must be defined before being used. The __set
and __get magic methods allow you to arbitrarily create properties,
and IMHO is the most flexible way to do it. If it just worked as you
want it to you would not be able to create rules around what
properties can be created or what values they can hold.

I use those magic methods to implement validation in my model classes.
If $this-x simply created x I would have to implement it using
accessor functions which IMHO is much less intuitive.

When deciding whether to call __set or __get PHP looks at whether you
can access the property in the current context, so if you declare a
private or protected property you should be able to set its value from
within the class without involving the magic methods.

Hope that makes things a bit clearer.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] why does a html mail send as text ?

2009-02-04 Thread Phpster
Show your code, but it sounds like maybe the HTML flag is not set.  
Consider using a class like phpmailer or the mime mail class from  
phpclasses.org


Bastien

Sent from my iPod

On Feb 4, 2009, at 6:28, Bulend Kolay bma...@ihlas.net.tr wrote:


I use php-5.2.6 and apache2.2.x on opensuse11

I have a file called mailsend.php to send a mail of html format.
the server sends the mail form of html format. But I get it as text  
instead of html.

default_mimetype is set as text/html in php.ini file.

How can I correct this ?




--
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



Re: [PHP] calculate the time that day ends

2009-02-04 Thread Shawn McKenzie
Lupus Michaelis wrote:
 Shawn McKenzie a écrit :
 
 STFW
 
   That's not so fair. If Thodoris ask about day end, it is obvious he's
 wrong with the word. Wrong because he isn't mastering english. So,
 without the good word (sunset), he can't find. So please don't bash us
 when we appear silly !
 
 

It wasn't a bash.  Did you notice that I included the google link with
the search term sunset in it for him? ;-)

http://www.google.com/search?q=calculate+sunset+formula

I also researched more after that post and gave him a link to the PHP
function that I didn't even know existed.  Quite a lot of searching and
helpful info from me to be considered bashing.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] why does a html mail send as text ?

2009-02-04 Thread Bulend Kolay
I attached my code 


Thanks



Show your code, but it sounds like maybe the HTML flag is not set.  
Consider using a class like phpmailer or the mime mail class from  
phpclasses.org


Bastien

Sent from my iPod

On Feb 4, 2009, at 6:28, Bulend Kolay bma...@ihlas.net.tr wrote:


I use php-5.2.6 and apache2.2.x on opensuse11

I have a file called mailsend.php to send a mail of html format.
the server sends the mail form of html format. But I get it as text  
instead of html.

default_mimetype is set as text/html in php.ini file.

How can I correct this ?




--
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
$im_val_isim = $HTTP_POST_VARS['isim'];
$im_val_firma = $HTTP_POST_VARS['firma'];
$im_val_ortak_isimleri = $HTTP_POST_VARS['ortak_isimleri'];
$im_val_adres = $HTTP_POST_VARS['adres'];
$im_val_ilce = $HTTP_POST_VARS['ilce'];
$im_val_sehir = $HTTP_POST_VARS['sehir'];
$im_val_tel_is = $HTTP_POST_VARS['tel_is'];
$im_val_tel_cep = $HTTP_POST_VARS['tel_cep'];
$im_val_fax= $HTTP_POST_VARS['fax'];
$im_val_web = $HTTP_POST_VARS['web'];
$im_val_email = $HTTP_POST_VARS['email'];
//$im_val_ =$HTTP_POST_VARS[''];


$icerik_gelen ='
table width=466 border=0 cellspacing=0 cellpadding=2
   tr
 td width=6 class=style13/td
 td width=96 align=left class=style11Adı - Soyadı/td
 td width=10 align=right class=style11nbsp;/td
 td width=338 align=left'.$im_val_isim.'/td
   /tr
   tr bgcolor=#F4F4F4
 td width=6 class=style13/td
 td align=left class=style11Firma ünvanı ve şirketin açık 
ismi/td
 td align=right class=style11nbsp;/td
 td align=left'.$im_val_firma.'/td
   /tr
   tr
 td class=style11nbsp;/td
 td align=left class=style11Varsa şirket ortaklarının isimleribr / 
 /td
 td align=right class=style11nbsp;/td
 td align=left'.$im_val_ortak_isimleri.'/td
   /tr
   tr bgcolor=#f4f4f4
 td width=6 class=style13*/td
 td align=left class=style11Adres/td
 td align=right class=style11nbsp;/td
 td align=left'.$im_val_adres.'/td
   /tr
   tr
 td width=6 class=style13*/td
 td align=left class=style11İlçe/td
 td align=right class=style11nbsp;/td
 td align=left'.$im_val_ilce.'/td
   /tr
   tr bgcolor=#f4f4f4
 td width=6 class=style13*/td
 td align=left class=style11Ä°l/td
 td align=right class=style11nbsp;/td
 td align=left'.$im_val_sehir.'/td
   /tr
   tr
 td width=6 class=style13*/td
 td align=left class=style11İş Tel/td
 td align=right class=style11nbsp;/td
 td align=left'.$im_val_tel_is.'/td
   /tr
   tr
 td bgcolor=#f4f4f4 class=style11nbsp;/td
 td align=left bgcolor=#f4f4f4 class=style11Cep Tel/td
 td align=right bgcolor=#f4f4f4 class=style11nbsp;/td
 td align=left bgcolor=#f4f4f4'.$im_val_tel_cep.'/td
   /tr
   tr
 td class=style11nbsp;/td
 td align=left class=style11Fax/td
 td align=right class=style11nbsp;/td
 td align=left'.$im_val_fax.'/td
   /tr
 /table
 
 
 
 
 
 table width=574 border=0 cellspacing=0 cellpadding=2

   tr
 td class=style11nbsp;/td
 td align=left class=style11Yalnız bayiliği mi istiyorsunuz?br 
//td
 td align=right class=style11nbsp;/td
 td align=left class=style11'.$im_val_yalniz_bayiligi.'/td
   /tr
   tr bgcolor=#f4f4f4
 tdnbsp;/td
 td align=leftspan class=style11Vereceğiniz banka teminat mektubunun miktarı 
nedir?/span/td
 td align=rightnbsp;/td
 td align=left class=style11'.$im_val_teminat_miktar.'/td
   /tr
   tr bgcolor=#f4f4f4
 td class=style11nbsp;/td
 td align=left class=style11Bayilik istediğiniz İl veya İlçeler 
nedir?/td
 td align=right class=style11nbsp;/td
 td align=left class=style11'.$im_val_istenen_il_ilce.'/td
   /tr
   tr
 td class=style11nbsp;/td
 td align=left class=style11Merkeziniz hangi şehirde olacak?/td
 td align=right class=style11nbsp;/td
 td align=left class=style11'.$im_val_merkez_sehir.'/td
   /tr
   tr bgcolor=#f4f4f4
 tdnbsp;/td
 td align=leftspan class=style11Bölgenizde şube açmak, bayilik vermek 
istiyormusunuz, hangi şehirlerde?/span /td
 td align=rightnbsp;/td
 td align=left class=style11'.$im_val_bayilik_verilecek_yerler.'/td
   /tr
   tr
 td class=style11nbsp;/td
 td align=left class=style11Teşhir salonunuz kaç metre karedir?/td
 td align=right class=style11nbsp;/td
 td align=left class=style11'.$im_val_teshir_salonu.'/td
   /tr
   tr bgcolor=#f4f4f4
 td class=style11nbsp;/td
 td align=left class=style11Teşhir salonunuz merkezde mi, cadde üzerinde 
mi, site içinde mi?/td
 td align=right class=style11nbsp;/td
 td align=left class=style11'.$im_val_teshir_salonu_konum.'/td
   /tr
   tr
 td class=style11nbsp;/td
 td align=left class=style11Kendinize ait veya anlaşmalı, TSEli veya 
normal servisiniz var mı?/td
 

[PHP] php rpm

2009-02-04 Thread admin
Okay here is my question.
Does anyone know of an RPM of php that is pre-compiled with all the extras like 
soap, mssql, freetds, etc...

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



RE: [PHP] Is it possible to send POST vars through a header redirect?

2009-02-04 Thread Mike Roberts
Ladies and Gentlemen. 
 I am a recruiter who joined this list to understand a little about PHP. I 
respected the boundaries, and never tried to recruit you. Now I am asking for a 
courtesy in return. I have tried several ways and several times to be excluded 
from the list, but I still get emails. Can somebody who is 'in charge' please 
remove me from the list. Thank you. 





 Michael Roberts
 Senior Recruitment Strategist
 Corporate Staffing Services
 150 Monument Road, Suite 510
 Bala Cynwyd, PA 19004
 P 610-771-1084
 F 610-771-0390
 E mrobe...@jobscss.com

-Original Message-
From: TS [mailto:sunnrun...@gmail.com] 
Sent: Tuesday, February 03, 2009 5:47 PM
To: php-general@lists.php.net
Subject: [PHP] Is it possible to send POST vars through a header redirect?

I'm trying to send vars via POST somehow. Is this possible?

Currently I'm doing 

header(Location: http://domain/index.php?var=3;);

but, want to send POST or some other method that doesn't stick with the session.

Thanks, T


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



Re: [PHP] why does a html mail send as text ?

2009-02-04 Thread Bastien Koert
2009/2/4 Bulend Kolay bma...@ihlas.net.tr

 I attached my code
 Thanks




  Show your code, but it sounds like maybe the HTML flag is not set.
  Consider using a class like phpmailer or the mime mail class from
 phpclasses.org

 Bastien

 Sent from my iPod

 On Feb 4, 2009, at 6:28, Bulend Kolay bma...@ihlas.net.tr wrote:

  I use php-5.2.6 and apache2.2.x on opensuse11

 I have a file called mailsend.php to send a mail of html format.
 the server sends the mail form of html format. But I get it as text
  instead of html.
 default_mimetype is set as text/html in php.ini file.

 How can I correct this ?




 --
 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


Looking the code quickly, the only thing I do differently is setting the
headers:

  //build the headers
$headers = MIME-Version: 1.0\n;
$headers .= Content-type: text/html; charset=iso-8859-1\n;
$headers .= X-Priority: 1\n;
$headers .= X-MSMail-Priority: High\n;
$headers .= X-Mailer: PHP\n;
$headers .= From: \Site Admin no-re...@sitename.com\n;


What mail client are you using? Does it / is it set to accept html mails?

-- 

Bastien

Cat, the other other white meat


RE: [PHP] Is it possible to send POST vars through a header redirect?

2009-02-04 Thread tedd

At 9:47 AM -0500 2/4/09, Mike Roberts wrote:

Ladies and Gentlemen.
 I am a recruiter who joined this list to understand a little about 
PHP. I respected the boundaries, and never tried to recruit you. Now 
I am asking for a courtesy in return. I have tried several ways and 
several times to be excluded from the list, but I still get emails. 
Can somebody who is 'in charge' please remove me from the list. 
Thank you.


 Michael Roberts



Have you tried?


To unsubscribe, visit: http://www.php.net/unsub.php



It's at the bottom of every post.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] calculate the time that day ends

2009-02-04 Thread tedd

At 8:59 AM +0100 2/4/09, Lupus Michaelis wrote:

Shawn McKenzie a écrit :


STFW


  That's not so fair. If Thodoris ask about day 
end, it is obvious he's wrong with the word. 
Wrong because he isn't mastering english. So, 
without the good word (sunset), he can't find. 
So please don't bash us when we appear silly !



--
Mickaël Wolff aka Lupus Michaelis


Please don't assume that because you have 
difficulty with the English language that English 
speaking people are bashing you. That certainly 
was NOT the case here.


If I were you, I would look at why you think so? 
While it may be common for non English speaking 
people to criticize those who do, those 
criticisms are not usually well founded.


For example, a question was asked and this list 
gave good advice without bashing anyone. Check 
the records and prove otherwise if you believe 
different. In fact, I would like to understand 
why you think so.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] php rpm

2009-02-04 Thread Yannick Mortier
Can you tell us what distribution you have? Some distributions already
deliver PHP rpms and you just have to install additional modules.
Mostly they are called php(4|5)-(extensionname).
For example php5-mssql or php4-bc.
Try to look into your package manager or tell us what distro you have
so I can maybe do a little search for you.

-- 
Currently developing a browsergame...
http://www.p-game.de
Trade - Expand - Fight

Follow me at twitter!
http://twitter.com/moortier

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



RES: [PHP] Mutiple SQL request

2009-02-04 Thread Jônatas Zechim
For example i’ve this query:

 

SELECT admin_nome FROM ctalk_admin WHERE admin_lastping = '1233762658' AND
admin_lastping = '1233762608' AND admin_id='1'

 

I ran explain, the result for extra is ‘Impossible WHERE noticed after
reading const table...’

How can i optimize this query?

Is there some tutorial on the net?

 

Thanks, 

Zechim

 

De: Bastien Koert [mailto:phps...@gmail.com] 
Enviada em: quarta-feira, 4 de fevereiro de 2009 12:46
Para: Jônatas Zechim
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Mutiple SQL request

 

 

On Wed, Feb 4, 2009 at 9:43 AM, Jônatas Zechim zechim@gmail.com wrote:

Hi there, i've a system that do a query each 3s, does it impact on mysql
Server?
I mean, can this slow my Server?

zechim



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


It impacts system recources if this same query is run constantly for each
user. Example: if this runs a logon and you have 100 or 1000 users logging
on at roughly the same time, then you will have contention for the
resources. 

Can you check your indeces and run explain plans on the queries to see if
any of them can be optimised to run quicker?

-- 

Bastien

Cat, the other other white meat



Re: [PHP] why does a html mail send as text ?

2009-02-04 Thread Bulend Kolay
Ok it works. it comes as html,  
But  it comes with servername at From part.

That's to say, I get the mail no-re...@sitename.com@full.servername.com

How can I conceal the servername at the From part ?

Thanks  




2009/2/4 Bulend Kolay bma...@ihlas.net.tr


I attached my code
Thanks




 Show your code, but it sounds like maybe the HTML flag is not set.

 Consider using a class like phpmailer or the mime mail class from
phpclasses.org

Bastien

Sent from my iPod

On Feb 4, 2009, at 6:28, Bulend Kolay bma...@ihlas.net.tr wrote:

 I use php-5.2.6 and apache2.2.x on opensuse11


I have a file called mailsend.php to send a mail of html format.
the server sends the mail form of html format. But I get it as text
 instead of html.
default_mimetype is set as text/html in php.ini file.

How can I correct this ?




--
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



Looking the code quickly, the only thing I do differently is setting the
headers:

 //build the headers
$headers = MIME-Version: 1.0\n;
$headers .= Content-type: text/html; charset=iso-8859-1\n;
$headers .= X-Priority: 1\n;
$headers .= X-MSMail-Priority: High\n;
$headers .= X-Mailer: PHP\n;
$headers .= From: \Site Admin no-re...@sitename.com\n;


What mail client are you using? Does it / is it set to accept html mails?

--

Bastien

Cat, the other other white meat



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



[PHP] Re: Mutiple SQL request

2009-02-04 Thread Carlos Medina

Jônatas Zechim schrieb:

Hi there, i've a system that do a query each 3s, does it impact on mysql Server?
I mean, can this slow my Server?

zechim


No. and yes. I think if you are doing a Join Query over 32 Tables 
without indexes then it will be very slow


Carlos

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



RES: [PHP] Is it possible to send POST vars through a header redirect?

2009-02-04 Thread Jônatas Zechim
Try curl

-Mensagem original-
De: Stuart [mailto:stut...@gmail.com] 
Enviada em: quarta-feira, 4 de fevereiro de 2009 07:52
Para: TS
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Is it possible to send POST vars through a header redirect?

2009/2/3 TS sunnrun...@gmail.com:
 I'm trying to send vars via POST somehow. Is this possible?

 Currently I'm doing

 header(Location: http://domain/index.php?var=3;);

 but, want to send POST or some other method that doesn't stick with the 
 session.

I'm not sure what you mean by stick with the session. What exactly
are you trying to achieve?

-Stuart

-- 
http://stut.net/

-- 
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



Re: RES: [PHP] Mutiple SQL request

2009-02-04 Thread Jim Lucas
Jônatas Zechim wrote:
 For example i’ve this query:
 
  
 
 SELECT admin_nome FROM ctalk_admin WHERE admin_lastping = '1233762658' AND
 admin_lastping = '1233762608' AND admin_id='1'
 
  
 
 I ran explain, the result for extra is ‘Impossible WHERE noticed after
 reading const table...’
 
 How can i optimize this query?
 
 Is there some tutorial on the net?
 

I am going to guess that that admin_id column is already your primary key and 
therefor is unique and indexed by default.

I would add a compound index to ctalk_admin

ALTER TABLE `ctalk_admin` ADD INDEX (`admin_id`, `admin_lastping`)

or something along that line.

  
 
 Thanks, 
 
 Zechim
 
  
 
 De: Bastien Koert [mailto:phps...@gmail.com] 
 Enviada em: quarta-feira, 4 de fevereiro de 2009 12:46
 Para: Jônatas Zechim
 Cc: php-general@lists.php.net
 Assunto: Re: [PHP] Mutiple SQL request
 
  
 
  
 
 On Wed, Feb 4, 2009 at 9:43 AM, Jônatas Zechim zechim@gmail.com wrote:
 
 Hi there, i've a system that do a query each 3s, does it impact on mysql
 Server?
 I mean, can this slow my Server?
 
 zechim
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 It impacts system recources if this same query is run constantly for each
 user. Example: if this runs a logon and you have 100 or 1000 users logging
 on at roughly the same time, then you will have contention for the
 resources. 
 
 Can you check your indeces and run explain plans on the queries to see if
 any of them can be optimised to run quicker?
 


-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Mutiple SQL request

2009-02-04 Thread Bastien Koert
On Wed, Feb 4, 2009 at 9:43 AM, Jônatas Zechim zechim@gmail.com wrote:

 Hi there, i've a system that do a query each 3s, does it impact on mysql
 Server?
 I mean, can this slow my Server?

 zechim



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


It impacts system recources if this same query is run constantly for each
user. Example: if this runs a logon and you have 100 or 1000 users logging
on at roughly the same time, then you will have contention for the
resources.

Can you check your indeces and run explain plans on the queries to see if
any of them can be optimised to run quicker?

-- 

Bastien

Cat, the other other white meat


[PHP] Mutiple SQL request

2009-02-04 Thread Jônatas Zechim
Hi there, i've a system that do a query each 3s, does it impact on mysql Server?
I mean, can this slow my Server?

zechim



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



Re: [PHP] why does a html mail send as text ?

2009-02-04 Thread Bulend Kolay

Thanks to Bastien
I think, I wrote wrong the expression
I have entered the string again as below
$headers .= From: \Site Admin\ no-re...@sitename.com\n;

the mail comes as html and also server name at from part doesn't appear.





Ok it works. it comes as html,  But  it comes with servername at From 
part.

That's to say, I get the mail no-re...@sitename.com@full.servername.com

How can I conceal the servername at the From part ?

Thanks


2009/2/4 Bulend Kolay bma...@ihlas.net.tr


I attached my code
Thanks




 Show your code, but it sounds like maybe the HTML flag is not set.

 Consider using a class like phpmailer or the mime mail class from
phpclasses.org

Bastien

Sent from my iPod

On Feb 4, 2009, at 6:28, Bulend Kolay bma...@ihlas.net.tr wrote:

 I use php-5.2.6 and apache2.2.x on opensuse11


I have a file called mailsend.php to send a mail of html format.
the server sends the mail form of html format. But I get it as text
 instead of html.
default_mimetype is set as text/html in php.ini file.

How can I correct this ?




--
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



Looking the code quickly, the only thing I do differently is setting the
headers:

 //build the headers
$headers = MIME-Version: 1.0\n;
$headers .= Content-type: text/html; charset=iso-8859-1\n;
$headers .= X-Priority: 1\n;
$headers .= X-MSMail-Priority: High\n;
$headers .= X-Mailer: PHP\n;
$headers .= From: \Site Admin no-re...@sitename.com\n;


What mail client are you using? Does it / is it set to accept html mails?

--

Bastien

Cat, the other other white meat



--
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



Re: [PHP] Mutiple SQL request

2009-02-04 Thread Bastien Koert
On Wed, Feb 4, 2009 at 10:54 AM, Jônatas Zechim zechim@gmail.comwrote:

  For example i've this query:



 *SELECT admin_nome FROM ctalk_admin WHERE admin_lastping = '1233762658'
 AND admin_lastping = '1233762608' AND admin_id='1'*



 I ran explain, the result for extra is 'Impossible WHERE noticed after
 reading const table...'

 How can i optimize this query?

 Is there some tutorial on the net?



 Thanks,

 Zechim



 *De:* Bastien Koert [mailto:phps...@gmail.com]
 *Enviada em:* quarta-feira, 4 de fevereiro de 2009 12:46
 *Para:* Jônatas Zechim
 *Cc:* php-general@lists.php.net
 *Assunto:* Re: [PHP] Mutiple SQL request





 On Wed, Feb 4, 2009 at 9:43 AM, Jônatas Zechim zechim@gmail.com
 wrote:

 Hi there, i've a system that do a query each 3s, does it impact on mysql
 Server?
 I mean, can this slow my Server?

 zechim



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


 It impacts system recources if this same query is run constantly for each
 user. Example: if this runs a logon and you have 100 or 1000 users logging
 on at roughly the same time, then you will have contention for the
 resources.

 Can you check your indeces and run explain plans on the queries to see if
 any of them can be optimised to run quicker?

 --

 Bastien

 Cat, the other other white meat


Can you dump the table structure to show us how you've set it up?

-- 

Bastien

Cat, the other other white meat


Re: [PHP] why does a html mail send as text ?

2009-02-04 Thread Stuart
2009/2/4 Bulend Kolay bma...@ihlas.net.tr:
 I use php-5.2.6 and apache2.2.x on opensuse11

 I have a file called mailsend.php to send a mail of html format.
 the server sends the mail form of html format. But I get it as text instead
 of html.
 default_mimetype is set as text/html in php.ini file.

 How can I correct this ?

The default_mimetype applies to the headers returned to browsers by
PHP, it does not have any effect on emails you send.

To send HTML email I would suggest you use phpmailer[1] because it
makes the whole process quite painless.

-Stuart

[1] http://phpmailer.codeworxtech.com/

-- 
http://stut.net/

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



Re: [PHP] Mutiple SQL request

2009-02-04 Thread Per Jessen
Jônatas Zechim wrote:

 Hi there, i've a system that do a query each 3s, does it impact on
 mysql Server? I mean, can this slow my Server?

Probably not - if the query and the database doesn't change in between,
the results are cached.


/Per Jessen, Zürich


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



RES: [PHP] Mutiple SQL request

2009-02-04 Thread Jônatas Zechim
Can you dump the table structure to show us how you've set it up?
 
Bastien

Cat, the other other white meat

 

Yeah, that’s it:

 

CREATE TABLE `ctalk_admin` (

  `admin_id` int(9) NOT NULL auto_increment,

  `admin_nome` varchar(50) NOT NULL,

  `admin_login_nome` varchar(32) NOT NULL,

  `admin_pass` varchar(32) NOT NULL,

  `admin_login` int(10) NOT NULL,

  `admin_lastping` int(10) NOT NULL,

  PRIMARY KEY  (`admin_id`),

  KEY `admin_lastping` (`admin_lastping`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 

CREATE TABLE `ctalk_chat` (

  `id` int(4) NOT NULL auto_increment,

  `id_admin` int(4) NOT NULL,

  `id_cliente` int(4) NOT NULL,

  `start_time` int(10) NOT NULL,

  PRIMARY KEY  (`id`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 

CREATE TABLE `ctalk_chat_mensagem` (

  `id` int(4) NOT NULL auto_increment,

  `mensagem` varchar(400) NOT NULL,

  `hora` int(10) NOT NULL,

  `id_chat` int(4) NOT NULL,

  PRIMARY KEY  (`id`),

  KEY `id_chat` (`id_chat`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 

CREATE TABLE `ctalk_cliente` (

  `cliente_id` int(4) NOT NULL auto_increment,

  `cliente_nome` varchar(50) NOT NULL,

  `cliente_email` varchar(50) NOT NULL,

  `cliente_cpf` varchar(14) NOT NULL,

  `cliente_login` int(10) NOT NULL,

  `cliente_key` varchar(32) NOT NULL,

  `cliente_lastping` int(10) NOT NULL,

  `cliente_inchat` int(1) NOT NULL,

  PRIMARY KEY  (`cliente_id`),

  KEY `cliente_lastping` (`cliente_lastping`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 







Re: [PHP] Is it possible to send POST vars through a header redirect?

2009-02-04 Thread Morris
Not possible to send POST in header if your aim is to hide vars from users.

Could think about dynamically send POST using Javascript. form.send();

This requires some JS knowledge about how to exchange data between PHP and
JS

2009/2/4 tedd tedd.sperl...@gmail.com

 At 9:47 AM -0500 2/4/09, Mike Roberts wrote:

 Ladies and Gentlemen.
  I am a recruiter who joined this list to understand a little about PHP. I
 respected the boundaries, and never tried to recruit you. Now I am asking
 for a courtesy in return. I have tried several ways and several times to be
 excluded from the list, but I still get emails. Can somebody who is 'in
 charge' please remove me from the list. Thank you.

  Michael Roberts



 Have you tried?

 To unsubscribe, visit: http://www.php.net/unsub.php



 It's at the bottom of every post.

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com


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




RES: [PHP] Is it possible to send POST vars through a header redirect?

2009-02-04 Thread Jônatas Zechim
U can do it by using a session, or using a XML request via JS to save the
vars.

-Mensagem original-
De: Morris [mailto:morris...@gmail.com] 
Enviada em: quarta-feira, 4 de fevereiro de 2009 16:00
Para: tedd
Cc: Mike Roberts; php-general@lists.php.net
Assunto: Re: [PHP] Is it possible to send POST vars through a header
redirect?

Not possible to send POST in header if your aim is to hide vars from users.

Could think about dynamically send POST using Javascript. form.send();

This requires some JS knowledge about how to exchange data between PHP and
JS

2009/2/4 tedd tedd.sperl...@gmail.com

 At 9:47 AM -0500 2/4/09, Mike Roberts wrote:

 Ladies and Gentlemen.
  I am a recruiter who joined this list to understand a little about PHP.
I
 respected the boundaries, and never tried to recruit you. Now I am asking
 for a courtesy in return. I have tried several ways and several times to
be
 excluded from the list, but I still get emails. Can somebody who is 'in
 charge' please remove me from the list. Thank you.

  Michael Roberts



 Have you tried?

 To unsubscribe, visit: http://www.php.net/unsub.php



 It's at the bottom of every post.

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com


 --
 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



Re: RES: [PHP] Mutiple SQL request

2009-02-04 Thread Jim Lucas
Jônatas Zechim wrote:
 Can you dump the table structure to show us how you've set it up?
  
 Bastien
 
 Cat, the other other white meat
 
  
 
 Yeah, that’s it:
 
  
 
 CREATE TABLE `ctalk_admin` (
 
   `admin_id` int(9) NOT NULL auto_increment,
 
   `admin_nome` varchar(50) NOT NULL,
 
   `admin_login_nome` varchar(32) NOT NULL,
 
   `admin_pass` varchar(32) NOT NULL,
 
   `admin_login` int(10) NOT NULL,
 
   `admin_lastping` int(10) NOT NULL,
 
   PRIMARY KEY  (`admin_id`),
 
   KEY `admin_lastping` (`admin_lastping`)
 
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
  

I would add a second column to that admin_lastping KEY

KEY `admin_lastping` (`admin_lastping`, `admin_id`)

Since you are using both columns in your where clause, they both need to be 
specified /in the same/ index for and index to be used.

Otherwise, some random index might be used.  But you will get the best 
performance if both are listed in the same index.

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



RES: RES: [PHP] Mutiple SQL request

2009-02-04 Thread Jônatas Zechim
Thank i'll try these to see the perfomance..

Thanks

Zechim

-Mensagem original-
De: Jim Lucas [mailto:li...@cmsws.com] 
Enviada em: quarta-feira, 4 de fevereiro de 2009 16:11
Para: Jônatas Zechim
Cc: 'Bastien Koert'; php-general@lists.php.net
Assunto: Re: RES: [PHP] Mutiple SQL request

Jônatas Zechim wrote:
 Can you dump the table structure to show us how you've set it up?
  
 Bastien
 
 Cat, the other other white meat
 
  
 
 Yeah, that’s it:
 
  
 
 CREATE TABLE `ctalk_admin` (
 
   `admin_id` int(9) NOT NULL auto_increment,
 
   `admin_nome` varchar(50) NOT NULL,
 
   `admin_login_nome` varchar(32) NOT NULL,
 
   `admin_pass` varchar(32) NOT NULL,
 
   `admin_login` int(10) NOT NULL,
 
   `admin_lastping` int(10) NOT NULL,
 
   PRIMARY KEY  (`admin_id`),
 
   KEY `admin_lastping` (`admin_lastping`)
 
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
  

I would add a second column to that admin_lastping KEY

KEY `admin_lastping` (`admin_lastping`, `admin_id`)

Since you are using both columns in your where clause, they both need to be 
specified /in the same/ index for and index to be used.

Otherwise, some random index might be used.  But you will get the best 
performance if both are listed in the same index.

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Is it possible to send POST vars through a header redirect?

2009-02-04 Thread Shawn McKenzie
Stuart wrote:
 2009/2/4 Jônatas Zechim zechim@gmail.com:
 Try curl
 
 1) I really wish people would look at other replies to a post before
 sending their own. Duplicates are rarely useful.
 
 2) CURL cannot perform a header redirect as the OP is asking for, so
 the more useful response is to ask what they're actually trying to
 achieve because they're wanting to know how to do something that's not
 possible so the question is flawed.
 
 Rant over.
 
 -Stuart
 
 -Mensagem original-
 De: Stuart [mailto:stut...@gmail.com]
 Enviada em: quarta-feira, 4 de fevereiro de 2009 07:52
 Para: TS
 Cc: php-general@lists.php.net
 Assunto: Re: [PHP] Is it possible to send POST vars through a header 
 redirect?

 2009/2/3 TS sunnrun...@gmail.com:
 I'm trying to send vars via POST somehow. Is this possible?

 Currently I'm doing

 header(Location: http://domain/index.php?var=3;);

 but, want to send POST or some other method that doesn't stick with the 
 session.
 I'm not sure what you mean by stick with the session. What exactly
 are you trying to achieve?

 -Stuart

 --
 http://stut.net/

Well, since the OP can't POST using header, then maybe alternatives to
help them out?

If you want to use sessions or are already using them (i.e.
session_start() on each of the pages), you can just use session vars:

session_start();
$_SESSION['var'] = 3;
header(Location: http://domain/index.php;);
exit;

Then in the next page you have the var:

session_start();
$var = $_SESSION['var'];


-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] is this use of subquery smart

2009-02-04 Thread Afan Pasalic

What would be more appropriate way to create a query:

Solution 1:
select records from registrants table

SELECT r.reg_id, r.date_registered, r.old_record
FROM registrants r
WHERE r.org_id=12
AND r.reg_status=0
AND r.reg_id=r.person_id

# php validation
if($old_record != 0)
{
   SELECT CONCAT(people.last_name, ', ', people.first_name) FROM 
people, registrants

   WHERE people.instance_id=12
   AND people.person_id=registrants.person_id
   AND registrants.reg_id=r.ghost_record
}

this way 2nd query will be executed only if old_record is zero (let's 
say 10% - 20% of all records)



Solution 2:
SELECT r.reg_id, r.date_registered, r.old_record, if(r.ghost_record!=0, 
(SELECT CONCAT(people.last_name, ', ', people.first_name) FROM people, 
registrants WHERE people.instance_id=12 and 
people.person_id=registrants.person_id AND 
registrants.reg_id=r.ghost_record), 'y') as registered_by_name

FROM registrants r
WHERE r.org_id=12
AND r.reg_status=0
AND r.reg_id=r.person_id

this way subquery will be executed everytime, but I have everything on 
one place?



thanks for any opinion...

afan

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



RE: [PHP] Is it possible to send POST vars through a header redirect?

2009-02-04 Thread Ashley Sheridan
Just look at the headers of EVERY email that comes from the mailing
list, as they contain the unsubscribe email address.

On Wed, 2009-02-04 at 09:47 -0500, Mike Roberts wrote:
 Ladies and Gentlemen. 
  I am a recruiter who joined this list to understand a little about PHP. I 
 respected the boundaries, and never tried to recruit you. Now I am asking for 
 a courtesy in return. I have tried several ways and several times to be 
 excluded from the list, but I still get emails. Can somebody who is 'in 
 charge' please remove me from the list. Thank you. 
 
 
 
 
 
  Michael Roberts
  Senior Recruitment Strategist
  Corporate Staffing Services
  150 Monument Road, Suite 510
  Bala Cynwyd, PA 19004
  P 610-771-1084
  F 610-771-0390
  E mrobe...@jobscss.com
 
 -Original Message-
 From: TS [mailto:sunnrun...@gmail.com] 
 Sent: Tuesday, February 03, 2009 5:47 PM
 To: php-general@lists.php.net
 Subject: [PHP] Is it possible to send POST vars through a header redirect?
 
 I'm trying to send vars via POST somehow. Is this possible?
 
 Currently I'm doing 
 
 header(Location: http://domain/index.php?var=3;);
 
 but, want to send POST or some other method that doesn't stick with the 
 session.
 
 Thanks, T
 
 


Ash
www.ashleysheridan.co.uk


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



[PHP] Bad words [SQL, database, txt, whatever]

2009-02-04 Thread Jônatas Zechim
Hi there I don't know how to say 'palavrões'(i mean bad words, like f***
you, your bi***, as*) in English, but I need that.

Anyone has or know where I can get a database, txt, whatever of 'bad words
or 'palavrões''

zechim


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



Re: [PHP] why does a html mail send as text ?

2009-02-04 Thread Ashley Sheridan
On Wed, 2009-02-04 at 18:43 +0200, Bulend Kolay wrote:
 Thanks to Bastien
 I think, I wrote wrong the expression
 I have entered the string again as below
 $headers .= From: \Site Admin\ no-re...@sitename.com\n;
 
 the mail comes as html and also server name at from part doesn't appear.
 
 
 
 
 
  Ok it works. it comes as html,  But  it comes with servername at From 
  part.
  That's to say, I get the mail no-re...@sitename.com@full.servername.com
 
  How can I conceal the servername at the From part ?
 
  Thanks
 
  2009/2/4 Bulend Kolay bma...@ihlas.net.tr
 
  I attached my code
  Thanks
 
 
 
 
   Show your code, but it sounds like maybe the HTML flag is not set.
   Consider using a class like phpmailer or the mime mail class from
  phpclasses.org
 
  Bastien
 
  Sent from my iPod
 
  On Feb 4, 2009, at 6:28, Bulend Kolay bma...@ihlas.net.tr wrote:
 
   I use php-5.2.6 and apache2.2.x on opensuse11
 
  I have a file called mailsend.php to send a mail of html format.
  the server sends the mail form of html format. But I get it as text
   instead of html.
  default_mimetype is set as text/html in php.ini file.
 
  How can I correct this ?
 
 
 
 
  --
  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
 
 
  Looking the code quickly, the only thing I do differently is setting the
  headers:
 
   //build the headers
  $headers = MIME-Version: 1.0\n;
  $headers .= Content-type: text/html; charset=iso-8859-1\n;
  $headers .= X-Priority: 1\n;
  $headers .= X-MSMail-Priority: High\n;
  $headers .= X-Mailer: PHP\n;
  $headers .= From: \Site Admin no-re...@sitename.com\n;
 
 
  What mail client are you using? Does it / is it set to accept html mails?
 
  -- 
 
  Bastien
 
  Cat, the other other white meat
 
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  
 
 
The From header shouldn't have  in at all, not even escaped as you've
done. It should be a valid email address only, and I'm not entirely sure
that  in email addresses are allowed in most email systems/clients, so
it will cause problems.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] php rpm

2009-02-04 Thread Yannick Mortier
2009/2/4  ad...@buskirkgraphics.com:
 Wow I am so sorry did not mean to be so vague about my installation.
 RHEL 5.3
 The distro that comes with it is 5.1.6
 The bad part is the Redhat does not offer an uptodate disto of php.
 So i am compiling from source. I cant find much information on the distro's. 
 So i was wondering if there is a distro that explained what is compliled in 
 it. And if there was the ultimate distro that comes with everything i may 
 ever want compiled. I know i am dreaming :)


 2009/2/4  ad...@buskirkgraphics.com:
 Well that is a good point.
 current 5.1.6
 I see 5.2.8 is avilable in that distribution is there more precompiled
 options?


 Yes, the latest version of PHP is 5.2.8. So your distribution only
 provides 5.1.6? What distribution do you use? openSuSE, Fedora,
 Mandriva? And what version? (10.3, 11.0 for example would be valid for
 openSuSe). I can't tell you if there are any backports available if
 you don't tell me that.


 --
 Currently developing a browsergame...
 http://www.p-game.de
 Trade - Expand - Fight

 Follow me at twitter!
 http://twitter.com/moortier



Sorry... I don't know enough about Red Hat Enterprise Linux. Just
search for backports or something. Maybe someone else from the list
can help you.


-- 
Currently developing a browsergame...
http://www.p-game.de
Trade - Expand - Fight

Follow me at twitter!
http://twitter.com/moortier

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



[PHP] Passing an undetermined amount of arguments by reference

2009-02-04 Thread Jay Moore

Greetings list.

Say I have a function that escapes a string before being passed to MySQL 
like so:


function escape($id, $string)
{
$string = mysql_real_escape_string($string, $id);
}

I'm passing $string as a reference so I don't have to reassign it like so:

$foo = escape($id, $foo);

Simply calling

escape($id, $foo);

works just fine.


How can I do this if I have a variable number of arguments?  I know I 
can use func_get_args(), func_num_args() and so forth to get the 
arguments but can I still pass by reference?


It'd be so much easier to do

escape($id, $a, $b, $c, $d);

Than

$a = escape($id, a);

and so forth.

Does this make sense?  Is it possible to do?

Thanks in advance,
Jay

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



Re: [PHP] php rpm

2009-02-04 Thread Ashley Sheridan
On Wed, 2009-02-04 at 20:52 +0100, Yannick Mortier wrote:
 2009/2/4  ad...@buskirkgraphics.com:
  Wow I am so sorry did not mean to be so vague about my installation.
  RHEL 5.3
  The distro that comes with it is 5.1.6
  The bad part is the Redhat does not offer an uptodate disto of php.
  So i am compiling from source. I cant find much information on the 
  distro's. So i was wondering if there is a distro that explained what is 
  compliled in it. And if there was the ultimate distro that comes with 
  everything i may ever want compiled. I know i am dreaming :)
 
 
  2009/2/4  ad...@buskirkgraphics.com:
  Well that is a good point.
  current 5.1.6
  I see 5.2.8 is avilable in that distribution is there more precompiled
  options?
 
 
  Yes, the latest version of PHP is 5.2.8. So your distribution only
  provides 5.1.6? What distribution do you use? openSuSE, Fedora,
  Mandriva? And what version? (10.3, 11.0 for example would be valid for
  openSuSe). I can't tell you if there are any backports available if
  you don't tell me that.
 
 
  --
  Currently developing a browsergame...
  http://www.p-game.de
  Trade - Expand - Fight
 
  Follow me at twitter!
  http://twitter.com/moortier
 
 
 
 Sorry... I don't know enough about Red Hat Enterprise Linux. Just
 search for backports or something. Maybe someone else from the list
 can help you.
 
 
 -- 
 Currently developing a browsergame...
 http://www.p-game.de
 Trade - Expand - Fight
 
 Follow me at twitter!
 http://twitter.com/moortier
 
Generally I've always used the installation repositories that the
different Linux distributions have, and I've not ran into any problems
there. They'll generally get everything set up for you, with the minimum
of tinkering around of config files needed. I've got Fedora on my home
system, which is essentially the same as Red Hat, and it comes with a
good package manager that comes with many PEAR modules, lots of database
connection modules, and other things you may need like GD, SOAP, and
others. I'd say you can't go too wrong with all of that, as it lets you
add only what you need as and when you require it.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Passing an undetermined amount of arguments by reference

2009-02-04 Thread Ashley Sheridan
On Wed, 2009-02-04 at 14:02 -0600, Jay Moore wrote:
 Greetings list.
 
 Say I have a function that escapes a string before being passed to MySQL 
 like so:
 
 function escape($id, $string)
 {
   $string = mysql_real_escape_string($string, $id);
 }
 
 I'm passing $string as a reference so I don't have to reassign it like so:
 
 $foo = escape($id, $foo);
 
 Simply calling
 
 escape($id, $foo);
 
 works just fine.
 
 
 How can I do this if I have a variable number of arguments?  I know I 
 can use func_get_args(), func_num_args() and so forth to get the 
 arguments but can I still pass by reference?
 
 It'd be so much easier to do
 
 escape($id, $a, $b, $c, $d);
 
 Than
 
 $a = escape($id, a);
 
 and so forth.
 
 Does this make sense?  Is it possible to do?
 
 Thanks in advance,
 Jay
 
What about something like (untested):

list($id, $a, $b, $c, $d) = escape($id, $a, $b, $c, $d);

And then instead of altering the actual values in your function by using
pass-by-reference, you can just return an array of elements instead.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Passing an undetermined amount of arguments by reference

2009-02-04 Thread Jim Lucas
Jay Moore wrote:
 Greetings list.
 
 Say I have a function that escapes a string before being passed to MySQL
 like so:
 
 function escape($id, $string)
 {
 $string 
 }

Use an array as an alternate method of sending/returning data to the second 
argument.

function escape($id, $data) {
if ( is_array($data) ) {
foreach ( $data AS $k = $v ) {
escape($id, $v);
$data[$k] = $v;
}
} else {
$data = mysql_real_escape_string($data, $id);
}
}

This would handle any number of nested arrays/datasets.

Hope it helps.

 
 I'm passing $string as a reference so I don't have to reassign it like so:
 
 $foo = escape($id, $foo);
 
 Simply calling
 
 escape($id, $foo);
 
 works just fine.
 
 
 How can I do this if I have a variable number of arguments?  I know I
 can use func_get_args(), func_num_args() and so forth to get the
 arguments but can I still pass by reference?
 
 It'd be so much easier to do
 
 escape($id, $a, $b, $c, $d);
 
 Than
 
 $a = escape($id, a);
 
 and so forth.
 
 Does this make sense?  Is it possible to do?
 
 Thanks in advance,
 Jay
 


-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Passing an undetermined amount of arguments by reference

2009-02-04 Thread Jay Moore

Ashley Sheridan wrote:

On Wed, 2009-02-04 at 14:02 -0600, Jay Moore wrote:

Greetings list.

Say I have a function that escapes a string before being passed to MySQL 
like so:


function escape($id, $string)
{
$string = mysql_real_escape_string($string, $id);
}

I'm passing $string as a reference so I don't have to reassign it like so:

$foo = escape($id, $foo);

Simply calling

escape($id, $foo);

works just fine.


How can I do this if I have a variable number of arguments?  I know I 
can use func_get_args(), func_num_args() and so forth to get the 
arguments but can I still pass by reference?


It'd be so much easier to do

escape($id, $a, $b, $c, $d);

Than

$a = escape($id, a);

and so forth.

Does this make sense?  Is it possible to do?

Thanks in advance,
Jay


What about something like (untested):

list($id, $a, $b, $c, $d) = escape($id, $a, $b, $c, $d);

And then instead of altering the actual values in your function by using
pass-by-reference, you can just return an array of elements instead.


Ash
www.ashleysheridan.co.uk



Yeah, I had considered doing it that way as well.  I just wanted to 
remove the need to type each variable twice.  It gets to be a pain when 
you have longer variable names.


Thanks for the suggestion.

Jay

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



Re: [PHP] Bad words [SQL, database, txt, whatever]

2009-02-04 Thread Andrew Ballard
On Wed, Feb 4, 2009 at 2:48 PM, Jônatas Zechim zechim@gmail.com wrote:
 Hi there I don't know how to say 'palavrões'(i mean bad words, like f***
 you, your bi***, as*) in English, but I need that.

 Anyone has or know where I can get a database, txt, whatever of 'bad words
 or 'palavrões''

 zechim


http://www.google.com/search?hl=enq=bad+word+dictionarybtnG=Google+Search

http://www.google.com/search?hl=enq=bad+word+listbtnG=Searchaq=foq=

http://www.google.com/search?hl=enq=bad+word+databasebtnG=Searchaq=foq=

Andrew

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



Re: [PHP] Passing an undetermined amount of arguments by reference

2009-02-04 Thread Jay Moore

Jim Lucas wrote:

Jay Moore wrote:

Greetings list.

Say I have a function that escapes a string before being passed to MySQL
like so:

function escape($id, $string)
{
$string 
}


Use an array as an alternate method of sending/returning data to the second 
argument.

function escape($id, $data) {
if ( is_array($data) ) {
foreach ( $data AS $k = $v ) {
escape($id, $v);
$data[$k] = $v;
}
} else {
$data = mysql_real_escape_string($data, $id);
}
}

This would handle any number of nested arrays/datasets.

Hope it helps.



Will that work properly?

$a = 'hello';
$b = sup;
$c = \\hola';

$d = array($a, $b, $c);

escape($id, $d);

Jay

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



Re: [PHP] Passing an undetermined amount of arguments by reference

2009-02-04 Thread Shawn McKenzie
Jay Moore wrote:
 Jim Lucas wrote:
 Jay Moore wrote:
 Greetings list.

 Say I have a function that escapes a string before being passed to MySQL
 like so:

 function escape($id, $string)
 {
 $string }

 Use an array as an alternate method of sending/returning data to the
 second argument.

 function escape($id, $data) {
 if ( is_array($data) ) {
 foreach ( $data AS $k = $v ) {
 escape($id, $v);
 $data[$k] = $v;
 }
 } else {
 $data = mysql_real_escape_string($data, $id);
 }
 }

 This would handle any number of nested arrays/datasets.

 Hope it helps.

 
 Will that work properly?
 
 $a = 'hello';
 $b = sup;
 $c = \\hola';
 
 $d = array($a, $b, $c);
 
 escape($id, $d);
 
 Jay

I would try: $d = compact('a', 'b', 'c');

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Passing an undetermined amount of arguments by reference

2009-02-04 Thread Jay Moore

Shawn McKenzie wrote:

Jay Moore wrote:

Jim Lucas wrote:

Jay Moore wrote:

Greetings list.

Say I have a function that escapes a string before being passed to MySQL
like so:

function escape($id, $string)
{
$string }

Use an array as an alternate method of sending/returning data to the
second argument.

function escape($id, $data) {
if ( is_array($data) ) {
foreach ( $data AS $k = $v ) {
escape($id, $v);
$data[$k] = $v;
}
} else {
$data = mysql_real_escape_string($data, $id);
}
}

This would handle any number of nested arrays/datasets.

Hope it helps.


Will that work properly?

$a = 'hello';
$b = sup;
$c = \\hola';

$d = array($a, $b, $c);

escape($id, $d);

Jay


I would try: $d = compact('a', 'b', 'c');



What is the difference?  Please excuse my naivety. :)

Jay

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



RES: [PHP] Bad words [SQL, database, txt, whatever]

2009-02-04 Thread Jônatas Zechim
Thank you, but i thought one of you had the .sql or .txt, .xls, etc.
I had already find that results.

But it's ok now..

zechim

-Mensagem original-
De: Andrew Ballard [mailto:aball...@gmail.com] 
Enviada em: quarta-feira, 4 de fevereiro de 2009 18:19
Para: Jônatas Zechim
Cc: PHP-General List
Assunto: Re: [PHP] Bad words [SQL, database, txt, whatever]

On Wed, Feb 4, 2009 at 2:48 PM, Jônatas Zechim zechim@gmail.com wrote:
 Hi there I don't know how to say 'palavrões'(i mean bad words, like f***
 you, your bi***, as*) in English, but I need that.

 Anyone has or know where I can get a database, txt, whatever of 'bad words
 or 'palavrões''

 zechim


http://www.google.com/search?hl=enq=bad+word+dictionarybtnG=Google+Search

http://www.google.com/search?hl=enq=bad+word+listbtnG=Searchaq=foq=

http://www.google.com/search?hl=enq=bad+word+databasebtnG=Searchaq=foq=

Andrew


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



Re: [PHP] php rpm

2009-02-04 Thread Daniel Brown
On Wed, Feb 4, 2009 at 09:46,  ad...@buskirkgraphics.com wrote:
 Okay here is my question.
 Does anyone know of an RPM of php that is pre-compiled with all the extras 
 like soap, mssql, freetds, etc...

Afternoon, Rich, et al;

On an RHEL 5.3 system, you should already have 'yum' installed
with the repos ready to go by default, so just drop to a command line
and, as root, type:

yum install php-soap
yum install php-mssql
yum install php-pdo

 etc.

If your 'yum' isn't working from the get-go, check
http://rpmfind.net/ or http://pbone.net/ for the individual RPM's.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: RES: [PHP] Bad words [SQL, database, txt, whatever]

2009-02-04 Thread Ashley Sheridan
On Wed, 2009-02-04 at 18:34 -0200, Jônatas Zechim wrote:
 Thank you, but i thought one of you had the .sql or .txt, .xls, etc.
 I had already find that results.
 
 But it's ok now..
 
 zechim
 
 -Mensagem original-
 De: Andrew Ballard [mailto:aball...@gmail.com] 
 Enviada em: quarta-feira, 4 de fevereiro de 2009 18:19
 Para: Jônatas Zechim
 Cc: PHP-General List
 Assunto: Re: [PHP] Bad words [SQL, database, txt, whatever]
 
 On Wed, Feb 4, 2009 at 2:48 PM, Jônatas Zechim zechim@gmail.com wrote:
  Hi there I don't know how to say 'palavrões'(i mean bad words, like f***
  you, your bi***, as*) in English, but I need that.
 
  Anyone has or know where I can get a database, txt, whatever of 'bad words
  or 'palavrões''
 
  zechim
 
 
 http://www.google.com/search?hl=enq=bad+word+dictionarybtnG=Google+Search
 
 http://www.google.com/search?hl=enq=bad+word+listbtnG=Searchaq=foq=
 
 http://www.google.com/search?hl=enq=bad+word+databasebtnG=Searchaq=foq=
 
 Andrew
 
 
It's not as simple as just blocking the bad words anyway, as people will
find clever ways of getting round them such as $hit, sh1t, shi+, etc.
Not only that, but just replacing words can cause it's own problems. I
remember a lot of early basic filters (Hotmail anyone?) that prevented
words like this, and any unfortunate with a surname of Hancock was left
in a right mess!


Ash
www.ashleysheridan.co.uk


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



Re: RES: [PHP] Bad words [SQL, database, txt, whatever]

2009-02-04 Thread Daevid Vincent
On Wed, 2009-02-04 at 21:10 +, Ashley Sheridan wrote:

 Not only that, but just replacing words can cause it's own problems. I
 remember a lot of early basic filters (Hotmail anyone?) that prevented
 words like this, and any unfortunate with a surname of Hancock was left
 in a right mess!

I second that. I had a website that tried to prevent users from entering
in so-called bad words as their user, first or last name upon
registration. 

Well my good friend's name is Tom Cassell My algorithm prevented him
from registering (due to the 'ass' in his last name).

Thankfully he IM'd me about it and I fixed it for him, but if he were a
real customer, I bet they would go away and never come back.  I
commented out the code and it's bit-rotting as we speak, as it's just
too much hassle to try and deal with all possibilities. Instead, I get
an email notification whenever someone joins up and if they're sketchy,
then I just delete them manually. Customers are too valuable to
ostracize because of a strstr() in their name...



Re: RES: [PHP] Bad words [SQL, database, txt, whatever]

2009-02-04 Thread Robert Cummings
On Wed, 2009-02-04 at 13:14 -0800, Daevid Vincent wrote:

 Thankfully he IM'd me about it and I fixed it for him, but if he were a
 real customer, I bet they would go away and never come back.  I
 commented out the code and it's bit-rotting as we speak, as it's just
 too much h*BLEEP*le to try and deal with all possibilities. Instead, I get
 an email notification whenever someone joins up and if they're sketchy,
 then I just delete them manually. Customers are too valuable to
 ostracize because of a strstr() in their name...

Fixed the above for you.

:)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: RES: [PHP] Bad words [SQL, database, txt, whatever]

2009-02-04 Thread Ashley Sheridan
On Wed, 2009-02-04 at 16:22 -0500, Robert Cummings wrote:
 On Wed, 2009-02-04 at 13:14 -0800, Daevid Vincent wrote:
 
  Thankfully he IM'd me about it and I fixed it for him, but if he were a
  real customer, I bet they would go away and never come back.  I
  commented out the code and it's bit-rotting as we speak, as it's just
  too much h*BLEEP*le to try and deal with all possibilities. Instead, I get
  an email notification whenever someone joins up and if they're sketchy,
  then I just delete them manually. Customers are too valuable to
  ostracize because of a strstr() in their name...
 
 Fixed the above for you.
 
 :)
 
 Cheers,
 Rob.
 -- 
 http://www.interjinn.com
 Application and Templating Framework for PHP
 
 
Even more recently than Hotmail, iTunes tried something similar to
protect their 'sensitive' customers and censored out album names like
'Smells Like T**n Spirit' and 'I Though I Saw A P***y Cat'. Seems a
little silly, but it goes to show that it's not a small problem, and
even one of the big boys (should those last two words be censored?) can
get it wrong!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] is this use of subquery smart

2009-02-04 Thread Chris




Solution 2:
SELECT r.reg_id, r.date_registered, r.old_record, if(r.ghost_record!=0, 
(SELECT CONCAT(people.last_name, ', ', people.first_name) FROM people, 
registrants WHERE people.instance_id=12 and 
people.person_id=registrants.person_id AND 
registrants.reg_id=r.ghost_record), 'y') as registered_by_name

FROM registrants r
WHERE r.org_id=12
AND r.reg_status=0
AND r.reg_id=r.person_id

this way subquery will be executed everytime, but I have everything on 
one place?


Because it has to evaluate the whole 'if' statement (including your 
subquery) for each row in the result set.


Best place to ask would be on the mysql mailing list:

http://lists.mysql.com/

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: RES: [PHP] Mutiple SQL request

2009-02-04 Thread Chris

Jônatas Zechim wrote:

For example i’ve this query:

 


SELECT admin_nome FROM ctalk_admin WHERE admin_lastping = '1233762658' AND
admin_lastping = '1233762608' AND admin_id='1'

 


I ran explain, the result for extra is ‘Impossible WHERE noticed after
reading const table...’


Well this one is impossible.

Find records with ping before '1233762658' AND
find records with ping after  '1233762608'

The before time is before the after time.

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: RES: [PHP] Mutiple SQL request

2009-02-04 Thread Ashley Sheridan
On Thu, 2009-02-05 at 08:38 +1100, Chris wrote:
 Jônatas Zechim wrote:
  For example i’ve this query:
  
   
  
  SELECT admin_nome FROM ctalk_admin WHERE admin_lastping = '1233762658' AND
  admin_lastping = '1233762608' AND admin_id='1'
  
   
  
  I ran explain, the result for extra is ‘Impossible WHERE noticed after
  reading const table...’
 
 Well this one is impossible.
 
 Find records with ping before '1233762658' AND
 find records with ping after  '1233762608'
 
 The before time is before the after time.
 
 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/
 
 
Erm, I don't think so, notice that 5 as the second to last digit. He
wants to find a ping before the larger number and after the smaller
number, which is perfectly valid in the normal rules of the universe I
know ;)


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] is this use of subquery smart

2009-02-04 Thread Bastien Koert
On Wed, Feb 4, 2009 at 4:33 PM, Chris dmag...@gmail.com wrote:



  Solution 2:
 SELECT r.reg_id, r.date_registered, r.old_record, if(r.ghost_record!=0,
 (SELECT CONCAT(people.last_name, ', ', people.first_name) FROM people,
 registrants WHERE people.instance_id=12 and
 people.person_id=registrants.person_id AND
 registrants.reg_id=r.ghost_record), 'y') as registered_by_name
 FROM registrants r
 WHERE r.org_id=12
 AND r.reg_status=0
 AND r.reg_id=r.person_id

 this way subquery will be executed everytime, but I have everything on
 one place?


 Because it has to evaluate the whole 'if' statement (including your
 subquery) for each row in the result set.

 Best place to ask would be on the mysql mailing list:

 http://lists.mysql.com/

 --
 Postgresql  php tutorials
 http://www.designmagick.com/



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


try a case when then statement.

-- 

Bastien

Cat, the other other white meat


Re: RES: [PHP] Mutiple SQL request

2009-02-04 Thread Chris

Ashley Sheridan wrote:

On Thu, 2009-02-05 at 08:38 +1100, Chris wrote:

Jônatas Zechim wrote:

For example i’ve this query:

 


SELECT admin_nome FROM ctalk_admin WHERE admin_lastping = '1233762658' AND
admin_lastping = '1233762608' AND admin_id='1'

 


I ran explain, the result for extra is ‘Impossible WHERE noticed after
reading const table...’

Well this one is impossible.

Find records with ping before '1233762658' AND
find records with ping after  '1233762608'

The before time is before the after time.

--
Postgresql  php tutorials
http://www.designmagick.com/



Erm, I don't think so, notice that 5 as the second to last digit. He
wants to find a ping before the larger number and after the smaller
number, which is perfectly valid in the normal rules of the universe I
know ;)


*bangs head on desk*
Going to be a long day...

Either way, mysql knew this query couldn't return any results for some 
reason (hence impossible where noticed), so using this as an example 
when trying to optimize will fail.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] Passing an undetermined amount of arguments by reference

2009-02-04 Thread Jim Lucas
Jay Moore wrote:
 Shawn McKenzie wrote:
 Jay Moore wrote:
 Jim Lucas wrote:
 Jay Moore wrote:
 Greetings list.

 Say I have a function that escapes a string before being passed to
 MySQL
 like so:

 function escape($id, $string)
 {
 $string }
 Use an array as an alternate method of sending/returning data to the
 second argument.

 function escape($id, $data) {
 if ( is_array($data) ) {
 foreach ( $data AS $k = $v ) {
 escape($id, $v);
 $data[$k] = $v;
 }
 } else {
 $data = mysql_real_escape_string($data, $id);
 }
 }

 This would handle any number of nested arrays/datasets.

 Hope it helps.

 Will that work properly?

 $a = 'hello';
 $b = sup;
 $c = \\hola';

 $d = array($a, $b, $c);

 escape($id, $d);

 Jay

 I would try: $d = compact('a', 'b', 'c');

 
 What is the difference?  Please excuse my naivety. :)
 
 Jay
 

Good point.

http://us2.php.net/compact

Key phrase...

it does the opposite of extract()

So, using that I would do it like this...


$a = 'hello';
$b = sup;
$c = \\hola';

$d = compact('a', 'b', 'c');
escape($id, $d);
extract($d);

with the above changes to the escape() function.

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: RES: [PHP] Mutiple SQL request

2009-02-04 Thread Ashley Sheridan
On Thu, 2009-02-05 at 08:48 +1100, Chris wrote:
 Ashley Sheridan wrote:
  On Thu, 2009-02-05 at 08:38 +1100, Chris wrote:
  Jônatas Zechim wrote:
  For example i’ve this query:
 
   
 
  SELECT admin_nome FROM ctalk_admin WHERE admin_lastping = '1233762658' 
  AND
  admin_lastping = '1233762608' AND admin_id='1'
 
   
 
  I ran explain, the result for extra is ‘Impossible WHERE noticed after
  reading const table...’
  Well this one is impossible.
 
  Find records with ping before '1233762658' AND
  find records with ping after  '1233762608'
 
  The before time is before the after time.
 
  -- 
  Postgresql  php tutorials
  http://www.designmagick.com/
 
 
  Erm, I don't think so, notice that 5 as the second to last digit. He
  wants to find a ping before the larger number and after the smaller
  number, which is perfectly valid in the normal rules of the universe I
  know ;)
 
 *bangs head on desk*
 Going to be a long day...
 
 Either way, mysql knew this query couldn't return any results for some 
 reason (hence impossible where noticed), so using this as an example 
 when trying to optimize will fail.
 
 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/
 
 
MySQL may have noticed it was impossible with the current data he had
using the index on that field, but in the future it may become valid, so
I wouldn't necessary eliminate it if it's deemed crucial. A query that
returns no results is equally as useful as one that returns many.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] php rpm

2009-02-04 Thread Thodoris Goltsios

Daniel Brown wrote:

On Wed, Feb 4, 2009 at 09:46,  ad...@buskirkgraphics.com wrote:
  

Okay here is my question.
Does anyone know of an RPM of php that is pre-compiled with all the extras like 
soap, mssql, freetds, etc...



Afternoon, Rich, et al;

On an RHEL 5.3 system, you should already have 'yum' installed
with the repos ready to go by default, so just drop to a command line
and, as root, type:

yum install php-soap
yum install php-mssql
yum install php-pdo

 etc.

If your 'yum' isn't working from the get-go, check
http://rpmfind.net/ or http://pbone.net/ for the individual RPM's.

  


This probably more then one rpm :-) .

You can do most of things using your distro's repos but usually PHP 
doesn't come in a single rpm. The truth is IMHO that pre-compiled 
packages are responsible for some failures in certain circumstances but 
generally are very good if you don't want to get your hands dirty.


A good way to see how is your distro giving you a prepackaged PHP set of 
rpms is using yum:


# yum search php

This is to get the list of all the available packages. You can then go 
and install what you need. Using:

# yum install php (and whatever you need)

It is not a good practice making an rpm with all the features included 
because it could become huge and it will probably need many dependencies 
in order to get installed properly.


IMHO that is why the best OS to use as on a web server is FreeBSD  
because of the flexibility provided by the ports system and the way that 
PHP is divided into small parts that can be added or removed easily.


Not to mention that you are compiling PHP (as a port) and you can update 
it or remove it like a package the same time.


Again this is my point of view that I wanted to share.

---
Thodoris


Re: [PHP] php rpm

2009-02-04 Thread Kyle Terry
On Wed, Feb 4, 2009 at 12:59 PM, Daniel Brown danbr...@php.net wrote:
 On Wed, Feb 4, 2009 at 09:46,  ad...@buskirkgraphics.com wrote:
 Okay here is my question.
 Does anyone know of an RPM of php that is pre-compiled with all the extras 
 like soap, mssql, freetds, etc...

Afternoon, Rich, et al;

On an RHEL 5.3 system, you should already have 'yum' installed
 with the repos ready to go by default, so just drop to a command line
 and, as root, type:

yum install php-soap
yum install php-mssql
yum install php-pdo

 etc.

If your 'yum' isn't working from the get-go, check
 http://rpmfind.net/ or http://pbone.net/ for the individual RPM's.

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Unadvertised dedicated server deals, too low to print - email me to find out!

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



I might be wrong, but I think the packages have the php version
appended to the it. so php5-soap, for example.

At least it's like that in Fedora.

-- 
Kyle Terry | www.kyleterry.com
Help kick start VOOM (Very Open Object Model) for a library of PHP classes.
http://www.voom.me | IRC EFNet #voom

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



Re: [PHP] php rpm

2009-02-04 Thread Daniel Brown
On Wed, Feb 4, 2009 at 16:55, Thodoris Goltsios t...@kinetix.gr wrote:

 This probably more then one rpm :-) .

You're correct.  ;-P

I meant to lead-off the last email by saying that there is no
single official RHEL RPM that includes those modules/extensions by
default.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: RES: [PHP] Mutiple SQL request

2009-02-04 Thread Chris



MySQL may have noticed it was impossible with the current data he had
using the index on that field, but in the future it may become valid, so
I wouldn't necessary eliminate it if it's deemed crucial. A query that
returns no results is equally as useful as one that returns many.


I'm not arguing about the index, I'm saying you can't use that 
particular example to try and optimize the db.


In mysql you cannot use explain on a query that returns no results. 
Every time it will give the impossible where noticed error.


mysql create table test (id int);
Query OK, 0 rows affected (0.06 sec)

mysql insert into test(id) values (1);
Query OK, 1 row affected (0.06 sec)

mysql explain select * from test where id=1\G
*** 1. row ***
   id: 1
  select_type: SIMPLE
table: test
 type: system
possible_keys: NULL
  key: NULL
  key_len: NULL
  ref: NULL
 rows: 1
Extra:
1 row in set (0.00 sec)

mysql explain select * from test where id=2\G
*** 1. row ***
   id: 1
  select_type: SIMPLE
table: NULL
 type: NULL
possible_keys: NULL
  key: NULL
  key_len: NULL
  ref: NULL
 rows: NULL
Extra: Impossible WHERE noticed after reading const tables
1 row in set (0.01 sec)

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] php rpm

2009-02-04 Thread Daniel Brown
On Wed, Feb 4, 2009 at 16:56, Kyle Terry k...@kyleterry.com wrote:

 I might be wrong, but I think the packages have the php version
 appended to the it. so php5-soap, for example.

Some do, some don't.

 At least it's like that in Fedora.

Depends on the RPM packager and the repo, among other things.

http://rpmfind.net/linux/rpm2html/search.php?query=php-mssqlsystem=Fedora

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: RES: [PHP] Mutiple SQL request

2009-02-04 Thread Micah Gersten
Jim Lucas wrote:
 snip
 I would add a second column to that admin_lastping KEY

 KEY `admin_lastping` (`admin_lastping`, `admin_id`)

 Since you are using both columns in your where clause, they both need to be 
 specified /in the same/ index for and index to be used.

 Otherwise, some random index might be used.  But you will get the best 
 performance if both are listed in the same index.

   
This is definitely not true in MySQL 5 and I'm sure other RDBMS
systems.  MySQL 5 can use more than 1 index per table now.  Also, if
you're using the InnoDB engine, the Primary Key is stored in the
secondary index, so specifying it explicitly is unnecessary.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


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



[PHP] Clarity needed

2009-02-04 Thread tedd

Hi gang:

I need some fog removed.

I have a problem where I have an unlimited number of tutors teaching 
an unlimited number of courses. When I call upon a tutor, I want to 
see all the courses they teach.


In my old days, I would just set up a linked list of courses and 
attach it to the tutor (another linked list). As a tutor adds 
courses, I would just add the course to the end of the linked list. 
If the tutor deletes a course, then I would remove it from the list 
by changing a single pointer. If I needed a list of all the courses 
the tutor taught, I would just run down the linked list pulling them 
out as needed.


But now I have to think in terms of records in a database. I'll 
eventually figure it out, but what are your suggestions/solutions?


I understand that I can have one record set up for each tutor, and 
another record set up for each course, and then tie the two together 
by another record like an assignment. That way I can have as many 
assignments as I want tying courses to tutors.


It that the way you guys would do it?

Thanks,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Clarity needed

2009-02-04 Thread Ashley Sheridan
On Wed, 2009-02-04 at 17:24 -0500, tedd wrote:
 Hi gang:
 
 I need some fog removed.
 
 I have a problem where I have an unlimited number of tutors teaching 
 an unlimited number of courses. When I call upon a tutor, I want to 
 see all the courses they teach.
 
 In my old days, I would just set up a linked list of courses and 
 attach it to the tutor (another linked list). As a tutor adds 
 courses, I would just add the course to the end of the linked list. 
 If the tutor deletes a course, then I would remove it from the list 
 by changing a single pointer. If I needed a list of all the courses 
 the tutor taught, I would just run down the linked list pulling them 
 out as needed.
 
 But now I have to think in terms of records in a database. I'll 
 eventually figure it out, but what are your suggestions/solutions?
 
 I understand that I can have one record set up for each tutor, and 
 another record set up for each course, and then tie the two together 
 by another record like an assignment. That way I can have as many 
 assignments as I want tying courses to tutors.
 
 It that the way you guys would do it?
 
 Thanks,
 
 tedd
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 
Probably a table of tutors, a table of courses and then a table of links
between the two. That way you can use a single query joining the 3
tables together to pull out all the matches for a particular tutor or
course.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Clarity needed

2009-02-04 Thread Edmund Hertle
2009/2/4 tedd t...@sperling.com

 Hi gang:

 I need some fog removed.

 I have a problem where I have an unlimited number of tutors teaching an
 unlimited number of courses. When I call upon a tutor, I want to see all the
 courses they teach.

 In my old days, I would just set up a linked list of courses and attach it
 to the tutor (another linked list). As a tutor adds courses, I would just
 add the course to the end of the linked list. If the tutor deletes a course,
 then I would remove it from the list by changing a single pointer. If I
 needed a list of all the courses the tutor taught, I would just run down the
 linked list pulling them out as needed.

 But now I have to think in terms of records in a database. I'll eventually
 figure it out, but what are your suggestions/solutions?

 I understand that I can have one record set up for each tutor, and another
 record set up for each course, and then tie the two together by another
 record like an assignment. That way I can have as many assignments as I want
 tying courses to tutors.

 It that the way you guys would do it?

 Thanks,

 tedd


Hey,

as you said I would suggest 3 tables, one for the tutors, one for the
courses and the third, relational table for connecting tutors and courses.
I think this is the most flexible way you can do this.

-eddy


Re: [PHP] Clarity needed

2009-02-04 Thread TG
Yup, that's how I've done it before:


tutors
-
id
tutorname

courses
-
id
coursename


xref_tutors_courses

tutor_id
course_id


But I've been known to do things goofy before.  I'm curious to see how 
other people handle it.

-TG


- Original Message -
From: tedd t...@sperling.com
To: php-general@lists.php.net
Date: Wed, 4 Feb 2009 17:24:35 -0500
Subject: [PHP] Clarity needed

 Hi gang:
 
 I need some fog removed.
 
 I have a problem where I have an unlimited number of tutors teaching 
 an unlimited number of courses. When I call upon a tutor, I want to 
 see all the courses they teach.
 
 In my old days, I would just set up a linked list of courses and 
 attach it to the tutor (another linked list). As a tutor adds 
 courses, I would just add the course to the end of the linked list. 
 If the tutor deletes a course, then I would remove it from the list 
 by changing a single pointer. If I needed a list of all the courses 
 the tutor taught, I would just run down the linked list pulling them 
 out as needed.
 
 But now I have to think in terms of records in a database. I'll 
 eventually figure it out, but what are your suggestions/solutions?
 
 I understand that I can have one record set up for each tutor, and 
 another record set up for each course, and then tie the two together 
 by another record like an assignment. That way I can have as many 
 assignments as I want tying courses to tutors.
 
 It that the way you guys would do it?
 
 Thanks,
 
 tedd


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



[PHP] Speed Opinion

2009-02-04 Thread PHP
Hi all,
I am seeking some knowledge, hopefully I explain this right.

I am wondering what you think is faster.

Say you have 1000 records from 2 different tables that you need to get from a 
MySQL database.
A simple table will be displayed for each record, the second table contains 
related info for each record in table 1.

Is if faster to just read all the records from both tables into two arrays, 
then use php to go through the array for table 1 and figure out what records 
from table 2 are related.

Or, you dump all the data in table 1 into an array, then as you go through each 
record you make a database query to table 2.




PS:
I know I can use a join, but I find anytime I use a join, the database query is 
extremely slow, I have tried it for each version of mysql and php for the last 
few years. The delay difference is in the order of 100x slower or more.





[PHP] Re: Clarity needed

2009-02-04 Thread Shawn McKenzie
tedd wrote:
 Hi gang:
 
 I need some fog removed.
 
 I have a problem where I have an unlimited number of tutors teaching an
 unlimited number of courses. When I call upon a tutor, I want to see all
 the courses they teach.
 
 In my old days, I would just set up a linked list of courses and attach
 it to the tutor (another linked list). As a tutor adds courses, I would
 just add the course to the end of the linked list. If the tutor deletes
 a course, then I would remove it from the list by changing a single
 pointer. If I needed a list of all the courses the tutor taught, I would
 just run down the linked list pulling them out as needed.
 
 But now I have to think in terms of records in a database. I'll
 eventually figure it out, but what are your suggestions/solutions?
 
 I understand that I can have one record set up for each tutor, and
 another record set up for each course, and then tie the two together by
 another record like an assignment. That way I can have as many
 assignments as I want tying courses to tutors.
 
 It that the way you guys would do it?
 
 Thanks,
 
 tedd

As others have said, that's how I always do it.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Clarity needed

2009-02-04 Thread Daniel Brown
On Wed, Feb 4, 2009 at 17:24, tedd t...@sperling.com wrote:
[snip!]

 I understand that I can have one record set up for each tutor, and another
 record set up for each course, and then tie the two together by another
 record like an assignment. That way I can have as many assignments as I want
 tying courses to tutors.

 It that the way you guys would do it?

I would, yes.  Very basically:

database.tutors:
id INT(8) NOT NULL auto_increment
f_name VARCHAR(32)
l_name VARCHAR(32)

database.courses
id INT(8) NOT NULL auto_increment
class_name VARCHAR(90)
class_description MEDIUMTEXT

database.course_tutors
id INT(8) NOT NULL auto_increment
tutor_id INT(8)
course_id INT(8)


Then just run the query you want based on the following example:

?php
// Database includes, etc
$sql  = SELECT course_name,course_description FROM courses WHERE id ;
$sql .= IN (SELECT course_id FROM course_tutors WHERE tutor_id=;
$sql .= '.mysql_real_escape_string($_GET['tutor_id']).');
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
echo Class: .$row['course_name'].br /\n;
echo Description: .$row['course_description'].br /\n;
}
?

You can also use JOINs and so forth, of course, but a simple
WHERE/IN should be fine.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Speed Opinion

2009-02-04 Thread Chris

PHP wrote:

Hi all,
I am seeking some knowledge, hopefully I explain this right.

I am wondering what you think is faster.

Say you have 1000 records from 2 different tables that you need to get from a 
MySQL database.
A simple table will be displayed for each record, the second table contains 
related info for each record in table 1.

Is if faster to just read all the records from both tables into two arrays, 
then use php to go through the array for table 1 and figure out what records 
from table 2 are related.

Or, you dump all the data in table 1 into an array, then as you go through each 
record you make a database query to table 2.


Make the db do it.


PS:
I know I can use a join, but I find anytime I use a join, the database query is 
extremely slow, I have tried it for each version of mysql and php for the last 
few years. The delay difference is in the order of 100x slower or more.


Then you're missing indexes or something, I've joined tables with 
hundreds of thousands of records and it's very fast.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] Speed Opinion

2009-02-04 Thread Afan Pasalic


PHP wrote:

Hi all,
I am seeking some knowledge, hopefully I explain this right.

I am wondering what you think is faster.

Say you have 1000 records from 2 different tables that you need to get from a 
MySQL database.
A simple table will be displayed for each record, the second table contains 
related info for each record in table 1.

Is if faster to just read all the records from both tables into two arrays, 
then use php to go through the array for table 1 and figure out what records 
from table 2 are related.

Or, you dump all the data in table 1 into an array, then as you go through each 
record you make a database query to table 2.
  


in general mysql is faster than php. do/select as much as you can in 
mysql.



-afan



PS:
I know I can use a join, but I find anytime I use a join, the database query is 
extremely slow, I have tried it for each version of mysql and php for the last 
few years. The delay difference is in the order of 100x slower or more.


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



Re: [PHP] Speed Opinion

2009-02-04 Thread Robert Cummings
On Wed, 2009-02-04 at 14:42 -0800, PHP wrote:
 Hi all,
 I am seeking some knowledge, hopefully I explain this right.
 
 I am wondering what you think is faster.
 
 Say you have 1000 records from 2 different tables that you need to get from a 
 MySQL database.
 A simple table will be displayed for each record, the second table contains 
 related info for each record in table 1.
 
 Is if faster to just read all the records from both tables into two arrays, 
 then use php to go through the array for table 1 and figure out what records 
 from table 2 are related.
 
 Or, you dump all the data in table 1 into an array, then as you go through 
 each record you make a database query to table 2.
 
 
 
 
 PS:
 I know I can use a join, but I find anytime I use a join, the database query 
 is extremely slow, I have tried it for each version of mysql and php for the 
 last few years. The delay difference is in the order of 100x slower or more.

Grab records from table 1... build a list of IDs to match in table 2.
Use an IN clause. 2 queries and no joins as you requested.

SELECT * from foo_table AS FOO where something something;

SELECT * from fee_table AS FEE where foo_id IN ( list, of, ids );

You REALLY don't want to do a query for every row matched in the first
query.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Passing an undetermined amount of arguments by reference

2009-02-04 Thread Shawn McKenzie
Jim Lucas wrote:
 Jay Moore wrote:
 Shawn McKenzie wrote:
 Jay Moore wrote:
 Jim Lucas wrote:
 Jay Moore wrote:
 Greetings list.

 Say I have a function that escapes a string before being passed to
 MySQL
 like so:

 function escape($id, $string)
 {
 $string }
 Use an array as an alternate method of sending/returning data to the
 second argument.

 function escape($id, $data) {
 if ( is_array($data) ) {
 foreach ( $data AS $k = $v ) {
 escape($id, $v);
 $data[$k] = $v;
 }
 } else {
 $data = mysql_real_escape_string($data, $id);
 }
 }

 This would handle any number of nested arrays/datasets.

 Hope it helps.

 Will that work properly?

 $a = 'hello';
 $b = sup;
 $c = \\hola';

 $d = array($a, $b, $c);

 escape($id, $d);

 Jay
 I would try: $d = compact('a', 'b', 'c');

 What is the difference?  Please excuse my naivety. :)

 Jay

 
 Good point.
 
 http://us2.php.net/compact
 
 Key phrase...
 
   it does the opposite of extract()
 
 So, using that I would do it like this...
 
 
 $a = 'hello';
 $b = sup;
 $c = \\hola';
 
 $d = compact('a', 'b', 'c');
 escape($id, $d);
 extract($d);
 
 with the above changes to the escape() function.
 

Right, so: $d = array($a, $b, $c); would give you an array like this:

0 = 'hello'
1 = sup
2 = \\hola'

Whereas: $d = compact('a', 'b', 'c'); would give you:

'a' = 'hello'
'b' = sup
'c' = \\hola'

So the keys are your var names instead of numerical indexes.


Also, I can't test it now, but a shorter though cramped way might be
(assuming that you modify escape() to return instead of modifying the
reference):


extract(escape($id, compact('a', 'b', 'c')));

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] [PROJECT HELP] - JotBug - A Project Management Issue Tracker written 100% with Zend Framework

2009-02-04 Thread rcastley

Hi,

I forget to mention that you can log into the site using any username (no
password is required).  This is just dummy/test authentication mechanism
whilst I finished off support for LDAP and OpenID.


rcastley wrote:
 
 Hi,
 
 I now have a demo site available so you can easily monitor the projects
 progress.  The site is updated daily with the svn checkins.
 
 http://www.jotbug.org
 
 The source is still hosted at http://jotbug.googlecode.com
 
 Regards,
 
 - Robert
 
 

-- 
View this message in context: 
http://www.nabble.com/-PROJECT-HELPJotBug---A-Project-Management---Issue-Tracker-written-100--with-Zend-Framework-tp21696826p21841680.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Speed Opinion

2009-02-04 Thread Ashley Sheridan
On Thu, 2009-02-05 at 09:44 +1100, Chris wrote:
 PHP wrote:
  Hi all,
  I am seeking some knowledge, hopefully I explain this right.
  
  I am wondering what you think is faster.
  
  Say you have 1000 records from 2 different tables that you need to get from 
  a MySQL database.
  A simple table will be displayed for each record, the second table contains 
  related info for each record in table 1.
  
  Is if faster to just read all the records from both tables into two arrays, 
  then use php to go through the array for table 1 and figure out what 
  records from table 2 are related.
  
  Or, you dump all the data in table 1 into an array, then as you go through 
  each record you make a database query to table 2.
 
 Make the db do it.
 
  PS:
  I know I can use a join, but I find anytime I use a join, the database 
  query is extremely slow, I have tried it for each version of mysql and php 
  for the last few years. The delay difference is in the order of 100x slower 
  or more.
 
 Then you're missing indexes or something, I've joined tables with 
 hundreds of thousands of records and it's very fast.
 
 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/
 
 
I've used joins on tables with millions of rows, and it's still not been
too slow to use. Admittedly it was an MSSQL database, which I've always
found to be slower, but MySQL was built to be a relational database, and
can handle many many millions of records quite happily. The slowdown you
experienced is either not using indexes on tables, or the way you were
displaying/manipulating those results from within PHP.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Clarity needed

2009-02-04 Thread Phpster
Yep, 3 tables is the way to go! One for tutors, one for courses and  
one to join them


Bastien

Sent from my iPod

On Feb 4, 2009, at 17:24, tedd t...@sperling.com wrote:


Hi gang:

I need some fog removed.

I have a problem where I have an unlimited number of tutors teaching  
an unlimited number of courses. When I call upon a tutor, I want to  
see all the courses they teach.


In my old days, I would just set up a linked list of courses and  
attach it to the tutor (another linked list). As a tutor adds  
courses, I would just add the course to the end of the linked list.  
If the tutor deletes a course, then I would remove it from the list  
by changing a single pointer. If I needed a list of all the courses  
the tutor taught, I would just run down the linked list pulling them  
out as needed.


But now I have to think in terms of records in a database. I'll  
eventually figure it out, but what are your suggestions/solutions?


I understand that I can have one record set up for each tutor, and  
another record set up for each course, and then tie the two together  
by another record like an assignment. That way I can have as many  
assignments as I want tying courses to tutors.


It that the way you guys would do it?

Thanks,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
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



Re: [PHP] is this use of subquery smart

2009-02-04 Thread Chris

Bastien Koert wrote:



On Wed, Feb 4, 2009 at 4:33 PM, Chris dmag...@gmail.com 
mailto:dmag...@gmail.com wrote:




Solution 2:
SELECT r.reg_id, r.date_registered, r.old_record,
if(r.ghost_record!=0, (SELECT CONCAT(people.last_name, ', ',
people.first_name) FROM people, registrants WHERE
people.instance_id=12 and people.person_id=registrants.person_id
AND registrants.reg_id=r.ghost_record), 'y') as registered_by_name
FROM registrants r
WHERE r.org_id=12
AND r.reg_status=0
AND r.reg_id=r.person_id

this way subquery will be executed everytime, but I have
everything on one place?


Because it has to evaluate the whole 'if' statement (including your
subquery) for each row in the result set.

Best place to ask would be on the mysql mailing list:

http://lists.mysql.com/





try a case when then statement.


Same problem - the case is evaluated (including the subquery) with every 
row in the result.


It could be done as a join I guess but I'll leave that as an exercise 
for the OP.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



[PHP] Re: Clarity needed

2009-02-04 Thread Nathan Rixham

tedd wrote:

Hi gang:

I need some fog removed.

I have a problem where I have an unlimited number of tutors teaching an 
unlimited number of courses. When I call upon a tutor, I want to see all 
the courses they teach.


In my old days, I would just set up a linked list of courses and attach 
it to the tutor (another linked list). As a tutor adds courses, I would 
just add the course to the end of the linked list. If the tutor deletes 
a course, then I would remove it from the list by changing a single 
pointer. If I needed a list of all the courses the tutor taught, I would 
just run down the linked list pulling them out as needed.


But now I have to think in terms of records in a database. I'll 
eventually figure it out, but what are your suggestions/solutions?


I understand that I can have one record set up for each tutor, and 
another record set up for each course, and then tie the two together by 
another record like an assignment. That way I can have as many 
assignments as I want tying courses to tutors.


It that the way you guys would do it?

Thanks,

tedd


not even read the other responses but yep, just normalise it like you 
said two tables + a link table
tutorId,courseId and a unique index over those two columns to make sure 
you don't get duplicates :)


regards!

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



Re: [PHP] Speed Opinion

2009-02-04 Thread Nathan Rixham

Ashley Sheridan wrote:

On Thu, 2009-02-05 at 09:44 +1100, Chris wrote:

PHP wrote:

Hi all,
I am seeking some knowledge, hopefully I explain this right.

I am wondering what you think is faster.

Say you have 1000 records from 2 different tables that you need to get from a 
MySQL database.
A simple table will be displayed for each record, the second table contains 
related info for each record in table 1.

Is if faster to just read all the records from both tables into two arrays, 
then use php to go through the array for table 1 and figure out what records 
from table 2 are related.

Or, you dump all the data in table 1 into an array, then as you go through each 
record you make a database query to table 2.

Make the db do it.


PS:
I know I can use a join, but I find anytime I use a join, the database query is 
extremely slow, I have tried it for each version of mysql and php for the last 
few years. The delay difference is in the order of 100x slower or more.
Then you're missing indexes or something, I've joined tables with 
hundreds of thousands of records and it's very fast.


--
Postgresql  php tutorials
http://www.designmagick.com/



I've used joins on tables with millions of rows, and it's still not been
too slow to use. Admittedly it was an MSSQL database, which I've always
found to be slower, but MySQL was built to be a relational database, and
can handle many many millions of records quite happily. The slowdown you
experienced is either not using indexes on tables, or the way you were
displaying/manipulating those results from within PHP.


Ash
www.ashleysheridan.co.uk



and if you use spatial indexes and points instead of integers you can 
join on the biggest of databases with literally no perfomance hit, same 
speed regardless of table size :p (plus cos a point has two values you 
can use one for id and the other for timestamp ;)


regards

ps: i've said this many times before, but not for like 6 months so time 
for another reminder


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



[PHP] PHP pop-up windows

2009-02-04 Thread Clancy

I'm working on a website editor, primarily for my own use. Normally it will be 
used on my
own computer, and much of what I wish to achieve could arguably be better done 
in either C
or JavaScript, but both of these have a similar programming syntax to PHP, but 
with subtle
differences, and I don't think my brain could cope with trying to work in two 
similar but
different languages simultaneously.

 An example of what I would like to achieve is:

The primary instance of the program opens a text input window for the user to 
enter, say,
one or more addresses from the contact list. It then pops up a second window, 
which could
be another instance of the same program. In this window the user can search the 
contacts
for the names he wants, and highlight them. When he is satisfied he clicks the 
submit
button on the second window.

When he does this the second window closes, and the primary window detects the 
response,
processes it, and inserts it into the entry area.

I gather that it would be possible for the first program to spawn a child 
process when the
user clicks the button, and this could then open the second window. I think 
that the child
can share session variables with the parent, so the parent could redraw its 
window, then
wait for some flag to be set in the session window, indicating the second 
window was
closing. The parent would then redraw its page incorporating the new 
information.

Is this a feasible mode of operation, and if so would anyone like to suggest 
ways to
implement it, and/or traps to be avoided?



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



Re: [PHP] PHP pop-up windows

2009-02-04 Thread Chris

Clancy wrote:

I'm working on a website editor, primarily for my own use. Normally it will be 
used on my
own computer, and much of what I wish to achieve could arguably be better done 
in either C
or JavaScript, but both of these have a similar programming syntax to PHP, but 
with subtle
differences, and I don't think my brain could cope with trying to work in two 
similar but
different languages simultaneously.

 An example of what I would like to achieve is:

The primary instance of the program opens a text input window for the user to 
enter, say,
one or more addresses from the contact list. It then pops up a second window, 
which could
be another instance of the same program. In this window the user can search the 
contacts
for the names he wants, and highlight them. When he is satisfied he clicks the 
submit
button on the second window.

When he does this the second window closes, and the primary window detects the 
response,
processes it, and inserts it into the entry area.

I gather that it would be possible for the first program to spawn a child 
process when the
user clicks the button, and this could then open the second window. I think 
that the child
can share session variables with the parent, so the parent could redraw its 
window, then
wait for some flag to be set in the session window, indicating the second 
window was
closing. The parent would then redraw its page incorporating the new 
information.

Is this a feasible mode of operation, and if so would anyone like to suggest 
ways to
implement it, and/or traps to be avoided?


If it's a desktop app, you could probably do it with gtk 
(http://gtk.php.net/) and get it to handle new windows etc for you.


If it's a web based app, just use javascript to open a new window, do 
it's work, close the window, bring focus back to the first window.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



[PHP] Re: PHP pop-up windows

2009-02-04 Thread Nathan Rixham

Clancy wrote:

I'm working on a website editor, primarily for my own use. Normally it will be 
used on my
own computer, and much of what I wish to achieve could arguably be better done 
in either C
or JavaScript, but both of these have a similar programming syntax to PHP, but 
with subtle
differences, and I don't think my brain could cope with trying to work in two 
similar but
different languages simultaneously.

 An example of what I would like to achieve is:

The primary instance of the program opens a text input window for the user to 
enter, say,
one or more addresses from the contact list. It then pops up a second window, 
which could
be another instance of the same program. In this window the user can search the 
contacts
for the names he wants, and highlight them. When he is satisfied he clicks the 
submit
button on the second window.

When he does this the second window closes, and the primary window detects the 
response,
processes it, and inserts it into the entry area.

I gather that it would be possible for the first program to spawn a child 
process when the
user clicks the button, and this could then open the second window. I think 
that the child
can share session variables with the parent, so the parent could redraw its 
window, then
wait for some flag to be set in the session window, indicating the second 
window was
closing. The parent would then redraw its page incorporating the new 
information.

Is this a feasible mode of operation, and if so would anyone like to suggest 
ways to
implement it, and/or traps to be avoided?




if ever somebody needed flex, it's you

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



[PHP] Reg-ex help

2009-02-04 Thread Craige Leeder

Hey guys,

I'm trying to write a regular expression to match a tag for my 
frameworks template engine.  I seem to be having some trouble.  The 
expression should match:


{:seg 'segname':}
{:seg 'segname' cache:}

What I have is...

$fSegRegEx = #\{:seg \'[a-z0-9\-\_]{3,}\'( cache)?:\}#i;

Which when run against my test data, seems to match:

{:seg 'segname' cache:}
 cache





For arguments sake, I'll provide the whole code snippet...

   preg_match($fSegRegEx, $this-msOpCont, $faSegMatches);

   /* faSegMatches ==

* array

* 0 = '{:seg 'users_online' cache:}'//

* 1 = ' cache'//

*/

 while ( $fMatch = current($faSegMatches) ) {

   /* 


* Expected:

* $fMatch[0] = {:seg 

* $fMatch[1] = Segment Name

* 


* $fMatch[2] =  cache:}

* or

* $fMatch[2] =  :}

*/

   $faMatch  = explode(', $fMatch);

   //...

   //...

   next($faSegMatches);

 }// End While


Thanks guys.  This has been bugging me for a couple days.
- Craige


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



Re: [PHP] PHP pop-up windows

2009-02-04 Thread Phpster
Forget using the two windows and avoid the cross window communication  
by using a couple of divs and Ajax.


Bastien

Sent from my iPod

On Feb 4, 2009, at 20:22, Clancy clanc...@cybec.com.au wrote:



I'm working on a website editor, primarily for my own use. Normally  
it will be used on my
own computer, and much of what I wish to achieve could arguably be  
better done in either C
or JavaScript, but both of these have a similar programming syntax  
to PHP, but with subtle
differences, and I don't think my brain could cope with trying to  
work in two similar but

different languages simultaneously.

An example of what I would like to achieve is:

The primary instance of the program opens a text input window for  
the user to enter, say,
one or more addresses from the contact list. It then pops up a  
second window, which could
be another instance of the same program. In this window the user can  
search the contacts
for the names he wants, and highlight them. When he is satisfied he  
clicks the submit

button on the second window.

When he does this the second window closes, and the primary window  
detects the response,

processes it, and inserts it into the entry area.

I gather that it would be possible for the first program to spawn a  
child process when the
user clicks the button, and this could then open the second window.  
I think that the child
can share session variables with the parent, so the parent could  
redraw its window, then
wait for some flag to be set in the session window, indicating the  
second window was
closing. The parent would then redraw its page incorporating the new  
information.


Is this a feasible mode of operation, and if so would anyone like to  
suggest ways to

implement it, and/or traps to be avoided?



--
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



Re: [PHP] Reg-ex help

2009-02-04 Thread Jim Lucas

Craige Leeder wrote:

Hey guys,

I'm trying to write a regular expression to match a tag for my 
frameworks template engine.  I seem to be having some trouble.  The 
expression should match:


{:seg 'segname':}
{:seg 'segname' cache:}

What I have is...

$fSegRegEx = #\{:seg \'[a-z0-9\-\_]{3,}\'( cache)?:\}#i;

Which when run against my test data, seems to match:

{:seg 'segname' cache:}
 cache


Thanks guys.  This has been bugging me for a couple days.
- Craige




I used some of your code, but try this variant on for size.

plaintext
?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$dummyData = DATA

html
body
h1{:seg 'title':}/h1
h1{:seg 'title' cache:}/h1
/body
/html

DATA;

# For arguments sake, I'll provide the whole code snippet...

$fSegRegEx = |\{:(seg) \'([a-z0-9\-\_]{3,})\'\s?(cache)?:\}|i;

preg_match_all($fSegRegEx, $dummyData, $faSegMatches, PREG_SET_ORDER);
print_r($faSegMatches);

?

Not sure what your input is going to be (HTML, XML, etc...) so I used HTML

Anyways, output from the above code is this:

plaintext

Array
(
[0] = Array
(
[0] = {:seg 'title':}
[1] = seg
[2] = title
)

[1] = Array
(
[0] = {:seg 'title' cache:}
[1] = seg
[2] = title
[3] = cache
)

)

Hope this starts you down the right path.

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Re: PHP webhosting - USA - conclusion

2009-02-04 Thread Thodoris


I should have said in the beginning it's a small website and I am not 
looking for a dedicated server.


Howewer, I decided to move to Lypha.com

Thanks for all your fruitful* comments :)
Martin


PS: PHP mailgroup rulz

*) that was in dictionary



You could check ICDsoft

http://www.icdsoft.com/

--
Thodoris


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



Re: RES: [PHP] Bad words [SQL, database, txt, whatever]

2009-02-04 Thread Alpár Török
2009/2/4 Ashley Sheridan a...@ashleysheridan.co.uk

 On Wed, 2009-02-04 at 16:22 -0500, Robert Cummings wrote:
  On Wed, 2009-02-04 at 13:14 -0800, Daevid Vincent wrote:
  
   Thankfully he IM'd me about it and I fixed it for him, but if he were a
   real customer, I bet they would go away and never come back.  I
   commented out the code and it's bit-rotting as we speak, as it's just
   too much h*BLEEP*le to try and deal with all possibilities. Instead, I
 get
   an email notification whenever someone joins up and if they're sketchy,
   then I just delete them manually. Customers are too valuable to
   ostracize because of a strstr() in their name...
 
  Fixed the above for you.
 
  :)
 
  Cheers,
  Rob.
  --
  http://www.interjinn.com
  Application and Templating Framework for PHP
 
 
 Even more recently than Hotmail, iTunes tried something similar to
 protect their 'sensitive' customers and censored out album names like
 'Smells Like T**n Spirit' and 'I Though I Saw A P***y Cat'. Seems a
 little silly, but it goes to show that it's not a small problem, and
 even one of the big boys (should those last two words be censored?) can
 get it wrong!


 Ash
 www.ashleysheridan.co.uk


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


I say, let the people curs as much as they fee appropriate to :) it's a for
of free expression.

-- 
Alpar Torok


[PHP] File Manager

2009-02-04 Thread Sn!per
What would you guys recommend as a good and free opensource file  
management system?


TIA.




--
Sign Up for free Email at http://ureg.home.net.my/


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



Re: [PHP] Clarity needed

2009-02-04 Thread Yannick Mortier
2009/2/4 tedd t...@sperling.com:
 Hi gang:

 I need some fog removed.

 I have a problem where I have an unlimited number of tutors teaching an
 unlimited number of courses. When I call upon a tutor, I want to see all the
 courses they teach.

 In my old days, I would just set up a linked list of courses and attach it
 to the tutor (another linked list). As a tutor adds courses, I would just
 add the course to the end of the linked list. If the tutor deletes a course,
 then I would remove it from the list by changing a single pointer. If I
 needed a list of all the courses the tutor taught, I would just run down the
 linked list pulling them out as needed.

 But now I have to think in terms of records in a database. I'll eventually
 figure it out, but what are your suggestions/solutions?

 I understand that I can have one record set up for each tutor, and another
 record set up for each course, and then tie the two together by another
 record like an assignment. That way I can have as many assignments as I want
 tying courses to tutors.

 It that the way you guys would do it?

 Thanks,

 tedd
 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com


Hi, tedd!
Though you might think that this is a stupid task I can recommend you
to draw a little entity-relationship model. It quite helps you to
overlook the structure of the database that you want to design. It has
got different relations between the data and defines a way to
represent those in the database.

If you are interested in this you can look in wikipedia here:
http://en.wikipedia.org/wiki/Entity-relationship_model

Since I heard from these models the first time I always use them and I
had no more database changes after I started coding since then.

Greetings



-- 
Currently developing a browsergame...
http://www.p-game.de
Trade - Expand - Fight

Follow me at twitter!
http://twitter.com/moortier

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