php-general Digest 16 Oct 2007 10:11:19 -0000 Issue 5075
Topics (messages 263217 through 263224):
Two MySQL instances in one server
263217 by: Matt Arnilo S. Baluyos (Mailing Lists)
263218 by: mike
Re: HTML Parse Issue
263219 by: Jim Lucas
Re: Classes - Dumb question
263220 by: Larry Garfield
263221 by: Nathan Nobbe
Re: A two flavored post
263222 by: Nathan Nobbe
Re: Screenshot from web page
263223 by: "Miguel J. Jiménez"
263224 by: Richard Heyes
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 ---
Hi all,
Would it be possible to have two MySQL instances running on one server
(each having different ports) and then have only one running Apache
server with PHP?
I have tried this once but PHP can only connect to one MySQL server
because it can only read one socket file at a time. As much as
possible, I would prefer a purely mod_php solution as opposed to one
that would have PHP running on CGI.
Thanks in advance,
Matt
--
Stand before it and there is no beginning.
Follow it and there is no end.
Stay with the ancient Tao,
Move with the present.
--- End Message ---
--- Begin Message ---
On 10/15/07, Matt Arnilo S. Baluyos (Mailing Lists)
<[EMAIL PROTECTED]> wrote:
> I have tried this once but PHP can only connect to one MySQL server
> because it can only read one socket file at a time.
are you sure? I am using multiple datasources (not socket ones) but I
see absolutely no reason there would be a limit. Are you sure you had
all the right paths?
I run multiple mysql instances on each of my mysql servers - each
client of mine has their own. I use mysqlmanager as the angel process
to manage them, restart them, etc. It's included in MySQL 5.x
nowadays. much better than having to tweak initscripts. But it can
easily be done from both sides.
--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
[EMAIL PROTECTED] wrote:
I am having a issue parsing an html file.
I want to pull all the data between two html tags.
Problem I am having is that no matter what I try I can pull either
tag or
both but not the data in between.
<div class="record" id="one">
<div class="rideon">
<h2>
<span>Welcome to
Rideon</span>
</h2>
</div>
</div>
</div class="record" id="one">
function datamatch($document)
{
preg_match_all('/<div class="record" [^<>]*>(.*)/<\/div
class="record" [^<>]*>/i',$document,$elements);
$match = implode("\r\n",$elements[0]);
return $match;
}
This should return the following
<div class="record" id="one">
<div class="rideon">
<h2>
<span>Welcome to
Rideon</span>
</h2>
</div>
</div>
</div class="record" id="one">
<plaintext><?php
$data = '
<div class="record" id="one"><div class="rideon"><h2><span>Welcome to
Rideon #1</span></h2></div></div>
<div class="record" id="two"><div class="rideon"><h2><span>Welcome to
Rideon #2</span></h2></div></div>
<div class="record" id="three"><div class="rideon"><h2><span>Welcome to
Rideon #3</span></h2></div></div>
<div class="record" id="four"><div class="rideon"><h2><span>Welcome to
Rideon #4</span></h2></div></div>
';
if ( preg_match_all('!<div class="record" id="([^"]+)"><div
class="rideon"><h2><span>([^<]+)</span></h2></div></div>!', $data,
$matches, PREG_SET_ORDER) ) {
print_r($matches);
} else {
echo 'Could not match anything.';
}
I just realized a problem with this code.
You have tabs/spaces/new lines between your different tags, so my regx needs a
little modification
Try this instead:
<plaintext><?php
$data = '
<div class="record" id="one">
<div class="rideon">
<h2><span>Welcome to Rideon #1</span></h2>
</div>
</div>
<div class="record" id="two">
<div class="rideon">
<h2><span>Welcome to Rideon #2</span></h2>
</div>
</div>
<div class="record" id="three">
<div class="rideon">
<h2><span>Welcome to Rideon #3</span></h2>
</div>
</div>
<div class="record" id="four">
<div class="rideon">
<h2><span>Welcome to Rideon #4</span></h2>
</div>
</div>
';
if ( preg_match_all('!<div class="record" id="([^"]+)">\s*<div
class="rideon">\s*<h2>\s*<span>([^<]+)</span>\s*</h2>\s*</div>\s*</div>!', $data, $matches,
PREG_SET_ORDER) ) {
print_r($matches);
} else {
echo 'Could not match anything.';
}
--
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
--- End Message ---
--- Begin Message ---
On Monday 15 October 2007, Nathan Nobbe wrote:
> On 10/15/07, tedd <[EMAIL PROTECTED]> wrote:
> > I understand the class concept. But, I am not familiar with autoload.
> >
> > Stut also made mention of that, so I shall investigate post haste.
>
> __autoload is pretty tight; but if you dont want to have all your class
> files in the same
> directory, i suggest you implement something custom.
> ive seen several implementations where class names basically have
> filesystem paths
> embedded in them; ugh.. i think thats what those buxa project guys are
> doing, but im
> not certain.
> also, the __autoload() function has to be available for it to be called,
> which means you
> will have to include the file that defines it in every file that would use
> it. since my php
> code is heavily oop; i just use the php.ini auto_prepend_file directive.
> oh; btw, Tedd, autoload is for classes only; if you like what you see maybe
> that will be
> the excuse youve been looking for to get into oop w/ php :)
>
> -nathan
__autoload() is also not recommended. :-) You can only have one per script.
Instead, use spl_autoload_register(). That way you can stack multiple
autoload routines cleanly.
(At least that's what the php-internals folks were saying the last time the
topic came up.)
http://us2.php.net/manual/en/function.spl-autoload-register.php
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
--- End Message ---
--- Begin Message ---
On 10/15/07, Larry Garfield <[EMAIL PROTECTED]> wrote:
>
> On Monday 15 October 2007, Nathan Nobbe wrote:
> > On 10/15/07, tedd <[EMAIL PROTECTED]> wrote:
> > > I understand the class concept. But, I am not familiar with autoload.
> > >
> > > Stut also made mention of that, so I shall investigate post haste.
> >
> > __autoload is pretty tight; but if you dont want to have all your class
> > files in the same
> > directory, i suggest you implement something custom.
> > ive seen several implementations where class names basically have
> > filesystem paths
> > embedded in them; ugh.. i think thats what those buxa project guys are
> > doing, but im
> > not certain.
> > also, the __autoload() function has to be available for it to be called,
> > which means you
> > will have to include the file that defines it in every file that would
> use
> > it. since my php
> > code is heavily oop; i just use the php.ini auto_prepend_file directive.
> > oh; btw, Tedd, autoload is for classes only; if you like what you see
> maybe
> > that will be
> > the excuse youve been looking for to get into oop w/ php :)
> >
> > -nathan
>
> __autoload() is also not recommended. :-) You can only have one per
> script.
> Instead, use spl_autoload_register(). That way you can stack multiple
> autoload routines cleanly.
>
> (At least that's what the php-internals folks were saying the last time
> the
> topic came up.)
>
> http://us2.php.net/manual/en/function.spl-autoload-register.php
>
neat; i didnt know about that, but i had checked out spl_autoload() before.
ive defined a singleton that has a method for loading of classpaths.
when __autoload is called, it delegates to the singleton to see if the
classpath is valid.
if theres a match it loads it, otherwise it chokes.
i cant imagine having multiple __autoload methods, but perhaps if there was
a third party
lib that was also using autoload() theirs could be stacked on top of yours
and that way they
could both live together. i might give that a shot.
-nathan
--- End Message ---
--- Begin Message ---
i was just working on some stuff and remembered how ive handled a problem
like this in the past.
the issue you have to wrestle w/ is the anchor tag will perform its normal
behavior after the onclick
handler has finished executing. basically, onclick is just part of the
process for the anchor tag.
well, what ive done in the past is determined, its only a link if you think
its a link :) so i just toss some
css on a span tag to make it look like a link, then you get full control
over the onclick behavior.
heres some sample css:
/* anchor imitator */
span.anchorImitator {
font-size: 11px;
font-family: Verdana,Arial,Helvetica,san-serif;
font-weight: 400;
color: #1505A5;
text-decoration: none;
}
span.anchorImitator:hover {
cursor:pointer;
font-size: 11px;
font-family: Verdana,Arial,Helvetica,san-serif;
font-weight: 400;
color: #AEF3F9;
text-decoration: underline;
}
of course it wont do much w/o javascript enabled.
-nathan
--- End Message ---
--- Begin Message ---
Gevorg Harutyunyan escribió:
Hi,
I would like to make web page screenshot and generate an image for
example .jpg or .png using PHP,Apache.
If any one has experiance in doing that please help.
I know that there are lot of services like that, but I don't want to use them.
In real I need that to generate screenshot of my local server pages.
There is a firefox extension called "screengrab" to do just that... The
results are, well, perfect! the URL is:
https://addons.mozilla.org/es-ES/firefox/addon/1146
--
.-------------------------------------------------------------------.
| Miguel J. Jiménez |
| Programador Senior |
| Área de Internet |
| [EMAIL PROTECTED] |
:-------------------------------------------------------------------:
| ISOTROL, S.A. |
| Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta. |
| Parque Tecnológico Cartuja '93, 41092 Sevilla (ESP). |
| Teléfono: +34 955 036 800 (ext.1805) - Fax: +34 955 036 849 |
| http://www.isotrol.com |
:-------------------------------------------------------------------:
| "Una bandera une a los habitantes de un pais bajo unos ideales |
| comunes y es por eso por lo que todos ellos deben aceptarlos de |
| buena gana y no ser forzados a ello pues entonces dicha bandera |
| no serviría de nada." - Emperador Ming, Flash Gordon (1x07)(2007) |
'-------------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
I would like to make web page screenshot and generate an image for
example .jpg or .png using PHP,Apache.
If any one has experiance in doing that please help.
I know that there are lot of services like that, but I don't want to
use them.
In real I need that to generate screenshot of my local server pages.
There is a firefox extension called "screengrab" to do just that... The
results are, well, perfect! the URL is:
https://addons.mozilla.org/es-ES/firefox/addon/1146
If you're not talking about automated screenshots, and you're using
Windows, just press your "PrtScr" button. Hold down Alt as well to get
just the active window. This will put the screenshot on to the
clipboard, so you'll then need to paste it into paint or other such
graphics program (PSP, Photoshop) after which you'll then be able to
save it to a file.
--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
that can cut the cost of online support
--- End Message ---