php-general Digest 4 Jun 2008 08:08:46 -0000 Issue 5496

Topics (messages 274972 through 274981):

no array passed error
        274972 by: PJ
        274973 by: Nathan Nobbe
        274974 by: Ted Wood

Regex in PHP
        274975 by: VamVan
        274976 by: Liran Oz
        274977 by: Nathan Nobbe

Re: APC + PHP Problem (apc_fcntl_lock failed: Bad file descriptor)
        274978 by: Scott McNaught [Synergy 8]

slowness mystery
        274979 by: Rene Veerman
        274980 by: Nathan Nobbe

Re: Avoid object twice
        274981 by: Yui Hiroaki

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message --- I don't know if this is the right list, it seems php and postgresql are rather interdependent in the webside I am debugging :(, but here goes:

I'm getting this error:
pg_execute() [<a href='function.pg-execute'>function.pg-execute</a>]: No array passed E_WARNING

for this line of code:
if( !($r=pg_execute($dbh, $query)) )

I suspect that I am not connecting to the database on the server...
How can I check my connection from withing the code or some other way?
Are the $dbh and $query built-in variables in postgres or php - I'm afraid that I'm rather a bumbling newbie :)

I can connect from XP to the FreeBSD 7.0 server and I can access and read the files and the samba connection appears to be correct... but I can't connect to the database from phped debugger
Can't figure this out...
Help ???

--- End Message ---
--- Begin Message ---
On Tue, Jun 3, 2008 at 4:28 PM, PJ <[EMAIL PROTECTED]> wrote:

> I don't know if this is the right list, it seems php and postgresql are
> rather interdependent in the webside I am debugging :(, but here goes:
>
> I'm getting this error:
> pg_execute() [<a href='function.pg-execute'>function.pg-execute</a>]: No
> array passed    E_WARNING
>
> for this line of code:
> if( !($r=pg_execute($dbh, $query)) )
>
> I suspect that I am not connecting to the database on the server...
> How can I check my connection from withing the code or some other way?
> Are the $dbh and $query built-in variables in postgres or php - I'm afraid
> that I'm rather a bumbling newbie  :)
>
> I can connect from XP to the FreeBSD 7.0 server and I can access and read
> the files and the samba connection appears to be correct... but I can't
> connect to the database from phped debugger
> Can't figure this out...
> Help ???


you definitely need to create a connection to the database before you make
any queries.  w/ the mysql api, if you dont supply function invocations the
connection parameter (for those that require it) the last created connection
will be used auto-magically by php.  its likely to be the same way in the
postgres api.  also, regarding those variables, no they are not any sort of
integrated or php specific values, they are local to your application.  $dbh
is likely to be the connection to the database, and $query should be some
sql you want the database to execute.

-nathan

--- End Message ---
--- Begin Message ---
PJ,

I remember the days when this stuff seemed beyond mystical.

1. $dbh and $query are not "built-in" variables... but they need to be defined somewhere earlier in the code. That could even be in a different file if the file you're in has been included.
2. One trick to try is to use the php function var_dump().

var_dump($dbh, $query);

That will spit out the contents of both of those variables so you can see what's "inside" them. If one or either of them spits out as NULL, then it is undefined. If you see FALSE, then there may have been an error connecting to the database.

~Ted



On 3-Jun-08, at 3:28 PM, PJ wrote:

I don't know if this is the right list, it seems php and postgresql are rather interdependent in the webside I am debugging :(, but here goes:

I'm getting this error:
pg_execute() [<a href='function.pg-execute'>function.pg-execute</ a>]: No array passed E_WARNING

for this line of code:
if( !($r=pg_execute($dbh, $query)) )

I suspect that I am not connecting to the database on the server...
How can I check my connection from withing the code or some other way?
Are the $dbh and $query built-in variables in postgres or php - I'm afraid that I'm rather a bumbling newbie :)

I can connect from XP to the FreeBSD 7.0 server and I can access and read the files and the samba connection appears to be correct... but I can't connect to the database from phped debugger
Can't figure this out...
Help ???

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



--- End Message ---
--- Begin Message ---
Hello All,

For example I have these email addressess -

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

What would be my PHP function[Regular expression[ to that can give me some
thing like

yahoo.com
hotmail.com
gmail.com

Thanks

--- End Message ---
--- Begin Message ---
You can use this:
$str = '[EMAIL PROTECTED]';

preg_match('/[EMAIL PROTECTED]@(.+)/', $str, $matches);
var_dump($matches);    //will be in $matches[1]


Or without regex:
echo substr($str, strpos($str, '@')+1);

Liran

----- Original Message ----- From: "VamVan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 04, 2008 3:39 AM
Subject: [PHP] Regex in PHP


Hello All,

For example I have these email addressess -

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

What would be my PHP function[Regular expression[ to that can give me some
thing like

yahoo.com
hotmail.com
gmail.com

Thanks



--- End Message ---
--- Begin Message ---
On Tue, Jun 3, 2008 at 8:39 PM, VamVan <[EMAIL PROTECTED]> wrote:

> Hello All,
>
> For example I have these email addressess -
>
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
> What would be my PHP function[Regular expression[ to that can give me some
> thing like
>
> yahoo.com
> hotmail.com
> gmail.com


if you know the values are valid email addresses, use a combination of
strripos() and substr().  it will be nice a fast that way.

as an aside, this is what the manual says on preg_match()
Do not use *preg_match()* if you only want to check if one string is
contained in another string. Use
strpos()<http://www.php.net/manual/en/function.strpos.php>or
strstr() <http://www.php.net/manual/en/function.strstr.php> instead as they
will be faster.

and the case insensitive versions are a hair faster still ;)

-nathan

--- End Message ---
--- Begin Message ---
Thanks for your reply.  I will try upgrading it. 

If anyone else has experienced this problem, please let me know.

-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Colin Guthrie
Sent: Monday, June 02, 2008 10:50 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: APC + PHP Problem (apc_fcntl_lock failed: Bad file 
descriptor)

Scott McNaught [Synergy 8] wrote:
> Hello,
> 
> I am running a production server with APC and php. We recently had a crash
> where APC bombed out. When it does this, the server serves empty, white
> pages.
> 
> Here is what the error_log says.

> I have not yet found a resolution for this.  There are no calls made to
> apc_store() on the server. It is solely script caching.  

> I am running PHP 5.2.5, and APC 3.0.15. This is the PHP info for APC.

I've recently deployed a similar setup, again only for script caching. 
It's working great for me with PHP 5.2.6 and APC 3.0.19. I'd suggest 
upgrading and seeing if that fixes it (esp the APC bit for obvious 
reasons - should also be pretty painless to upgrade only that part)

I only have a fairly low cache enabled and it does fill up and expunge 
data after a time out, so if I was affected by this I'd have expected to 
have seen it rear it's ugly head by now.

Col


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


--- End Message ---
--- Begin Message ---
Hi..

I've built a cms that's running into a serious speedbump.
I load several sets of javascript through a custom built db
caching&compression system.
Loading it without caching and compression takes between 2 and 3 seconds for
the entire app, 112Kb javascript.

The caching system first compresses/obfusicates the requested source-files,
then gzcompress()es that and stores the result in my database.

The next time the page is requested, the caching system detects the cached
copy, and outputs that with an echo statement.

One of these code bundles that i request takes over 6 full seconds to load.
It's the same 122Kb obfusi-compressed to 52Kb.
Even without obfusication, it takes 6 seconds to load when taken from the
database.
So it's not the browser being slow in parsing the obfusicated code.
Firebug's "net"-tab shows this one snippet taking 6 seconds. I don't know
exactly what that measures, just the transit time i hope..

I suspected the database query, but retrieval takes less than a millisecond.
So does the 'echo' statement that outputs it.

I'm really puzzled as to what can cause such a delay.

--- End Message ---
--- Begin Message ---
On Wed, Jun 4, 2008 at 3:05 AM, Rene Veerman <[EMAIL PROTECTED]> wrote:

> Hi..
>
> I've built a cms that's running into a serious speedbump.
> I load several sets of javascript through a custom built db
> caching&compression system.
> Loading it without caching and compression takes between 2 and 3 seconds
> for
> the entire app, 112Kb javascript.
>
> The caching system first compresses/obfusicates the requested source-files,
> then gzcompress()es that and stores the result in my database.
>
> The next time the page is requested, the caching system detects the cached
> copy, and outputs that with an echo statement.
>
> One of these code bundles that i request takes over 6 full seconds to load.
> It's the same 122Kb obfusi-compressed to 52Kb.
> Even without obfusication, it takes 6 seconds to load when taken from the
> database.
> So it's not the browser being slow in parsing the obfusicated code.
> Firebug's "net"-tab shows this one snippet taking 6 seconds. I don't know
> exactly what that measures, just the transit time i hope..
>
> I suspected the database query, but retrieval takes less than a
> millisecond.
> So does the 'echo' statement that outputs it.
>
> I'm really puzzled as to what can cause such a delay.
>

i think putting the js in the database at all, and then using php to
retrieve it is unnecessary overhead.  i would put the cached contents on
disc, and refer browsers to a direct url.  maybe you could just put the
contents of one of your compressed files on disc, and request it from the
browser, time that, and see if it gets you anywhere.

also, i would check into some of the resources yahoo has in this dept.  for
example, the ySlow firebug plugin,

http://developer.yahoo.com/yslow/
there are additional resources as well, and they even have a really slick js
compressor, freely available.  its so slick in fact, that it will reduce the
length of variable identifiers that are safe to do on because those
variables happen to be closures.  neat stuff.

-nathan

--- End Message ---
--- Begin Message ---
Thank you for your advice me!



-------------My.php-------
<?php

Class My{
       private $word;
       function __construct($getword){
            $this->word=$getword;
       }
       public function buff(){
            mail("[EMAIL PROTECTED]","test","test");
       }
}
?>
----------------------------------

--------------b.php------------
<?php
  function __autoload($class_name) {
  include_once $class_name . '.php';
  }


$objref=new My("Good");
$objref->buff();
?>
--------------------------------

--------------c.php----------
<?php
  function __autoload($class_name) {
  include_once $class_name . '.php';
  }

$obj=new My("Hello");
$obj->buff();
------------------------------


That is what I want to try.

When c.php run, Mail() function run // < it is OK
When b.php run, it also run Mail() fuction. // it is NOT OK

I would like to run Mail() function one time only from c.php.
However I also get prameter which declare "Good" in b.php

Now when c.php and b.php run, the program send twice email. That is not good!!
I would like to run c.php and b.php, then the program, which is Mail()
function, get one email and get  "Good"  from b.php


Regards,
Yui

--- End Message ---

Reply via email to