php-general Digest 8 Sep 2003 03:25:58 -0000 Issue 2284
Topics (messages 161911 through 161950):
Re: Want to change shell to bash for only one file
161911 by: Curt Zirzow
Re: Running PHP scripts in PHP Nuke
161912 by: Marek Kilimajer
161915 by: Dan Anderson
sscanf error?
161913 by: Nuno Lopes
161914 by: Catalin Trifu
161919 by: Nuno Lopes
161921 by: Catalin Trifu
this code unsets $_SESSION['editor'] but doesn't touch any other session variables
161916 by: anders thoresson
161917 by: John W. Holmes
161920 by: anders thoresson
161930 by: Raquel Rice
161931 by: anders thoresson
PDF Fonts
161918 by: Seth Willits
Re: Linux Issues
161922 by: Dan Anderson
161924 by: Stephen Craton
161926 by: Dan Anderson
Re: highlighting multi term search results
161923 by: jonas_weber.gmx.ch
161925 by: John W. Holmes
161938 by: jonas_weber.gmx.ch
161947 by: Lee O'Mara
Re: Encrypt/Serialize Source Code for Sale
161927 by: Jason Sheets
Re: Remove vars from memory?
161928 by: Dan Anderson
161933 by: \[cz\]Emo
161941 by: Jason Sheets
question about mysqli
161929 by: janet.valade.com
161932 by: Catalin Trifu
161950 by: janet.valade.com
Date Confusion
161934 by: Seth Willits
161935 by: Seth Willits
161942 by: John W. Holmes
game in php
161936 by: phpu
161937 by: Jon Haworth
161939 by: mek2600-php
161940 by: Mike Brum
function returning array
161943 by: Leonie
161944 by: Tom Rogers
161946 by: Leonie
161948 by: Tom Rogers
161949 by: Larry E. Ullman
ftok() not returning a valid SysV shared memory index?
161945 by: user.domain.invalid
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 ---
* Thus wrote Scott ([EMAIL PROTECTED]):
> I am trying to temporarily change from tcsh to bash. I need to use bash for
> a particular command that I am doing a shell_exec on. Currently:
> _SERVER["SHELL"] = tcsh
You can try put_env('SHELL=/bin/bash');
http://php.net/put_env
or if you making sure a script is ran under the shell you can
always call your script like:
/bin/bash scriptname
and of course you can make it so you don't have to worry about your
environment the file executible and add this to the first line:
#!/bin/bash
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
--- End Message ---
--- Begin Message ---
How does it not work. It explodes? Well, this happens with phpnuke
sometimes, that how it's got its name.
You need to be more specific. What error do you get?
Dan Anderson wrote:
I have a client who wants me to install a script on their web site.
Only problem is they use PHP nuke and when I edit a pages content and
type in :
<?php include("script.php"); ?>
Or do something like:
<OBJECT DATA="http://www.site.com/script.php"></OBJECT>
It doesn't work. Can anybody tell me how to run a script from within a
PHP nuke page?
Thanks,
Dan Anderson
--- End Message ---
--- Begin Message ---
> You need to be more specific. What error do you get?
I don't get any error. It will ask me for the HTML code to the page and
just not work. So I'm assuming that instead of being processed by
Apache and a preprocessor that can send it to PHP it's being printed to
the screen.
-Dan
--- End Message ---
--- Begin Message ---
Hello,
I'm trying to use sscanf, but I'm not receiving the results I expected! Can
anybody help me, please?
Thanking in advance,
Nuno Lopes
/************************************************/
<?
$db='"33996344","33996351","GB","GBR","UNITED KINGDOM"
"50331648","83886079","US","USA","UNITED STATES"
"94585424","94585439","SE","SWE","SWEDEN"';
$lines=explode("\n", $db);
foreach ($lines as $line) {
$array=sscanf($line, "\"%010d\",\"%010d\",\"%2s");
list ($start, $end, $country) = $array;
print_r($array);
}
?>
/******************************/
Output:
Array
(
[0] => 33996344
[1] => 33996351
[2] => GB
)
....
/****************/
Expected output:
Array
(
[0] => 0033996344
[1] => 0033996351
[2] => GB
)
--- End Message ---
--- Begin Message ---
Hi,
sscanf does what it says, that is
it reads parameters, which means it expects to find
a string like this "33996344" and converts it
into an integer; that's why you get the result you get.
This code does the job, but it's ugly: :).
<?php
$db='33996344,33996351,"GB","GBR","UNITED KINGDOM"
50331648,83886079,"US","USA","UNITED STATES"
94585424,94585439,"SE","SWE","SWEDEN"';
$lines=explode("\n", $db);
echo "<pre>";
print_r($lines);
foreach ($lines as $line) {
$args = explode(",", $line);
$array = sprintf("%010d,%010d,%2s", $args[0], $args[1], $args[2]);
$array = explode(",", $array);
list ($start, $end, $country) = $array;
print_r($array);
}
print_r(printf("%010d", "33996344"));
echo "</pre>";
?>
It uses sprintf.
Cheers,
Catalin
"Nuno Lopes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
>
> I'm trying to use sscanf, but I'm not receiving the results I expected!
Can
> anybody help me, please?
>
>
> Thanking in advance,
> Nuno Lopes
>
>
> /************************************************/
> <?
> $db='"33996344","33996351","GB","GBR","UNITED KINGDOM"
> "50331648","83886079","US","USA","UNITED STATES"
> "94585424","94585439","SE","SWE","SWEDEN"';
>
> $lines=explode("\n", $db);
>
> foreach ($lines as $line) {
> $array=sscanf($line, "\"%010d\",\"%010d\",\"%2s");
> list ($start, $end, $country) = $array;
> print_r($array);
> }
> ?>
> /******************************/
> Output:
> Array
> (
> [0] => 33996344
> [1] => 33996351
> [2] => GB
> )
> ....
> /****************/
> Expected output:
> Array
> (
> [0] => 0033996344
> [1] => 0033996351
> [2] => GB
> )
--- End Message ---
--- Begin Message ---
Hello,
Thanks for your answer!
You say that sscanf is doing it's job, so the documentation isn't very
clear.
I think it says that the format is equal to sprintf. And sprintf has %010d
in format that says that a var is a number with at least 10 digits, filled
with 0's. So I think that sscanf should do the job!
Nuno Lopes
----- Original Message -----
From: "Catalin Trifu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, September 07, 2003 5:51 PM
Subject: [PHP] Re: sscanf error?
> Hi,
>
> sscanf does what it says, that is
> it reads parameters, which means it expects to find
> a string like this "33996344" and converts it
> into an integer; that's why you get the result you get.
> This code does the job, but it's ugly: :).
>
> <?php
> $db='33996344,33996351,"GB","GBR","UNITED KINGDOM"
> 50331648,83886079,"US","USA","UNITED STATES"
> 94585424,94585439,"SE","SWE","SWEDEN"';
>
> $lines=explode("\n", $db);
>
> echo "<pre>";
> print_r($lines);
>
>
> foreach ($lines as $line) {
> $args = explode(",", $line);
> $array = sprintf("%010d,%010d,%2s", $args[0], $args[1], $args[2]);
> $array = explode(",", $array);
> list ($start, $end, $country) = $array;
> print_r($array);
> }
>
> print_r(printf("%010d", "33996344"));
> echo "</pre>";
>
> ?>
> It uses sprintf.
>
> Cheers,
> Catalin
>
> "Nuno Lopes" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hello,
> >
> > I'm trying to use sscanf, but I'm not receiving the results I expected!
> Can
> > anybody help me, please?
> >
> >
> > Thanking in advance,
> > Nuno Lopes
> >
> >
> > /************************************************/
> > <?
> > $db='"33996344","33996351","GB","GBR","UNITED KINGDOM"
> > "50331648","83886079","US","USA","UNITED STATES"
> > "94585424","94585439","SE","SWE","SWEDEN"';
> >
> > $lines=explode("\n", $db);
> >
> > foreach ($lines as $line) {
> > $array=sscanf($line, "\"%010d\",\"%010d\",\"%2s");
> > list ($start, $end, $country) = $array;
> > print_r($array);
> > }
> > ?>
> > /******************************/
> > Output:
> > Array
> > (
> > [0] => 33996344
> > [1] => 33996351
> > [2] => GB
> > )
> > ....
> > /****************/
> > Expected output:
> > Array
> > (
> > [0] => 0033996344
> > [1] => 0033996351
> > [2] => GB
> > )
--- End Message ---
--- Begin Message ---
Hi,
sscanf is meant to READ paramaters, which means
it "transforms" the input into the desired output, which in
your case it was an integer and an integer looses, of course
the initial zeros "if any".
What you wanted was, more or less, to transform the
parameters, job for which sprintf is better suited, at least in
this case.
Cheers,
Catalin
"Nuno Lopes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
>
> Thanks for your answer!
>
> You say that sscanf is doing it's job, so the documentation isn't very
> clear.
> I think it says that the format is equal to sprintf. And sprintf has %010d
> in format that says that a var is a number with at least 10 digits, filled
> with 0's. So I think that sscanf should do the job!
>
>
> Nuno Lopes
>
>
>
> ----- Original Message -----
> From: "Catalin Trifu" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, September 07, 2003 5:51 PM
> Subject: [PHP] Re: sscanf error?
>
>
> > Hi,
> >
> > sscanf does what it says, that is
> > it reads parameters, which means it expects to find
> > a string like this "33996344" and converts it
> > into an integer; that's why you get the result you get.
> > This code does the job, but it's ugly: :).
> >
> > <?php
> > $db='33996344,33996351,"GB","GBR","UNITED KINGDOM"
> > 50331648,83886079,"US","USA","UNITED STATES"
> > 94585424,94585439,"SE","SWE","SWEDEN"';
> >
> > $lines=explode("\n", $db);
> >
> > echo "<pre>";
> > print_r($lines);
> >
> >
> > foreach ($lines as $line) {
> > $args = explode(",", $line);
> > $array = sprintf("%010d,%010d,%2s", $args[0], $args[1], $args[2]);
> > $array = explode(",", $array);
> > list ($start, $end, $country) = $array;
> > print_r($array);
> > }
> >
> > print_r(printf("%010d", "33996344"));
> > echo "</pre>";
> >
> > ?>
> > It uses sprintf.
> >
> > Cheers,
> > Catalin
> >
> > "Nuno Lopes" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > Hello,
> > >
> > > I'm trying to use sscanf, but I'm not receiving the results I
expected!
> > Can
> > > anybody help me, please?
> > >
> > >
> > > Thanking in advance,
> > > Nuno Lopes
> > >
> > >
> > > /************************************************/
> > > <?
> > > $db='"33996344","33996351","GB","GBR","UNITED KINGDOM"
> > > "50331648","83886079","US","USA","UNITED STATES"
> > > "94585424","94585439","SE","SWE","SWEDEN"';
> > >
> > > $lines=explode("\n", $db);
> > >
> > > foreach ($lines as $line) {
> > > $array=sscanf($line, "\"%010d\",\"%010d\",\"%2s");
> > > list ($start, $end, $country) = $array;
> > > print_r($array);
> > > }
> > > ?>
> > > /******************************/
> > > Output:
> > > Array
> > > (
> > > [0] => 33996344
> > > [1] => 33996351
> > > [2] => GB
> > > )
> > > ....
> > > /****************/
> > > Expected output:
> > > Array
> > > (
> > > [0] => 0033996344
> > > [1] => 0033996351
> > > [2] => GB
> > > )
--- End Message ---
--- Begin Message ---
Hi,
I've had troubles with an application that randomly (until now) unsets the
session variable $_SESSION['editor']. I've hunted through all my code and
finally managed to rule out everything else than the following couple of
lines.
It unsets the session variable $_SESSION['editor'], but leaving others,
like $_SESSION['admin'] untouched. At the first debug, I get "Admin: Y
Editor: Y" printed (which is the way I suppose things to be), but at the
second debug I just get "Admin: Y Editor:".
I can't find the error though. Any input appreciated!
Best regards,
Anders Thoresson
<?php
// Debug, echoing session variables
echo ("Admin: " );
echo ($_SESSION['admin']);
echo (" Editor: " );
echo ($_SESSION['editor']);
$issuequery = "SELECT un_issue.i_date, un_issue.i_editor FROM un_issue
WHERE un_issue.i_date > CURDATE() ORDER BY i_date ASC";
$issueresult = mysql_query($issuequery);
$editorquery = "SELECT u_uname, u_id FROM un_user WHERE u_editor = 'Y'";
$editorresult = mysql_query($editorquery);
?>
<form action="issue_save_changes.php" method="post">
<table cellspacing="0">
<?php
// Initate counter for table background
$background = 1;
// Loop through all coming issues
while ($issue = mysql_fetch_row($issueresult))
{
mysql_data_seek($editorresult, 0);
if (is_even($background))
{
$row_background = "even";
}
else
{
$row_background = "odd";
}
?>
<tr class="<?php echo $row_background; ?>">
<td class="borderless"><input name="issue[]" type="hidden" value="<?php
echo $issue[0]; ?>"> <?php echo format_date($issue[0]); ?></td>
<td class="borderless"><select name="issue_editor[]">
<?php
// If editor isn't entered, highlight "Inte bestämt"
if (!isset($issue[1]))
{
?>
<option value=NULL selected>Inte bestämt
<?php
while ($editor = mysql_fetch_row($editorresult))
{
?>
<option value="<?php echo $editor[1] ?>"><?php echo $editor[0]; ?>
<?php
}
} // If an editor is entered, highlight her/him
else
{
?>
<option value=NULL>Inte bestämt
<?php
while ($editor = mysql_fetch_row($editorresult))
{
if ($editor[1] == $issue[1])
{
?>
<option value="<?php echo $editor[1] ?>" selected><?php echo
$editor[0]; ?>
<?php
}
else
{
?>
<option value="<?php echo $editor[1] ?>"><?php echo $editor[0]; ?>
<?php
}
}
}
?>
</select>
</tr>
<?php
++$background;
}
?>
</table>
<input type="submit" value="Spara ändringar">
</form>
<?php
// Debug, echoing session variables
echo ("Admin: " );
echo ($_SESSION['admin']);
echo (" Editor: " );
echo ($_SESSION['editor']);
--
anders thoresson
--- End Message ---
--- Begin Message ---
anders thoresson wrote:
Hi,
I've had troubles with an application that randomly (until now) unsets
the session variable $_SESSION['editor']. I've hunted through all my
code and finally managed to rule out everything else than the following
couple of lines.
It unsets the session variable $_SESSION['editor'], but leaving others,
like $_SESSION['admin'] untouched. At the first debug, I get "Admin: Y
Editor: Y" printed (which is the way I suppose things to be), but at the
second debug I just get "Admin: Y Editor:".
[snip]
while ($editor = mysql_fetch_row($editorresult))
[snip]
You more than likely have register globals ON, so by setting $editor to
some value above, you are also changing the value of $_SESSION['editor'].
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals - www.phparch.com
--- End Message ---
--- Begin Message ---
You more than likely have register globals ON, so by setting $editor to
some value above, you are also changing the value of $_SESSION['editor'].
Yes! Settings at ISP was with globals on, but at my local server they were
off. Which added quite a lot to my confusion.
Thanks!
--
anders thoresson
--- End Message ---
--- Begin Message ---
On Sun, 07 Sep 2003 13:42:21 -0400
"John W. Holmes" <[EMAIL PROTECTED]> wrote:
> anders thoresson wrote:
>
> > Hi,
> >
> > I've had troubles with an application that randomly (until now)
> > unsets the session variable $_SESSION['editor']. I've hunted
> > through all my code and finally managed to rule out everything
> > else than the following couple of lines.
> >
> > It unsets the session variable $_SESSION['editor'], but leaving
> > others, like $_SESSION['admin'] untouched. At the first debug, I
> > get "Admin: Y Editor: Y" printed (which is the way I suppose
> > things to be), but at the second debug I just get "Admin: Y
> > Editor:".
>
> [snip]
> > while ($editor = mysql_fetch_row($editorresult))
> [snip]
>
> You more than likely have register globals ON, so by setting
> $editor to some value above, you are also changing the value of
> $_SESSION['editor'].
>
> --
> ---John Holmes...
How about changing from an assignment operator "=" to a comparison
operator "==".
--
Raquel
============================================================
Discontent is the first step in the progress of a man or a nation.
--Oscar Wilde
--- End Message ---
--- Begin Message ---
> while ($editor = mysql_fetch_row($editorresult))
How about changing from an assignment operator "=" to a comparison
operator "==".
No. I want to step through each and every one of the rows in the result
set, and that's done that way.
--
anders thoresson
--- End Message ---
--- Begin Message ---
What do I need to do to get fonts working for PDF creation? Running the
script below, I get 2 errors. The first says "PDFlib error [2100]
PDF_begin_page: Function must not be called in 'object' scope" on line
2. If I remove "test.pdf" and change it to "", then it reports "PDFlib
error [2516] PDF_findfont: Metrics data for font 'Times New Roman' not
found" on line 2 also.
<?php
$pdf = pdf_new();
pdf_open_file($pdf, "test.pdf");
pdf_set_info($pdf, "Author", "Uwe Steinmann");
pdf_set_info($pdf, "Title", "Test for PHP wrapper of PDFlib 2.0");
pdf_set_info($pdf, "Creator", "See Author");
pdf_set_info($pdf, "Subject", "Testing");
pdf_begin_page($pdf, 595, 842);
pdf_add_bookmark($pdf, "Page 1");
$font = pdf_findfont($pdf, "Times New Roman", "winansi", 1);
pdf_setfont($pdf, $font, 10);
pdf_set_value($pdf, "textrendering", 1);
pdf_show_xy($pdf, "Times Roman outlined", 50, 750);
pdf_moveto($pdf, 50, 740);
pdf_lineto($pdf, 330, 740);
pdf_stroke($pdf);
pdf_end_page($pdf);
pdf_close($pdf);
pdf_delete($pdf);
echo "<A HREF=getpdf.php>finished</A>";
?>
Thanks,
Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine -
http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames
"No electrons were hurt in the transfer of this e-mail."
-- Anon
------------------------------------------------------------------------
---
--- End Message ---
--- Begin Message ---
> When downloading Linux ISOs or whatever, which do I need? What is the
> difference between i386, PPC, and all those other exactly? How do I know
> which I need?
This may be the source of your problems. i386, PPC, etc. are
architectures:
i386: x386 or higher
i586: Pentium II or higher (or equivalent)
i686: Pentium III or higher (or equivalent)
i786: Pentium IV or higher (or equivalent)
PPC: Mac Power PC
sparc: Sun Sparc
And the list goes on and on. You have yet to tell the list if you are
running any oddball configuration. Do you have any RAID or SCSI
controllers? What about anything else?
-Dan
--- End Message ---
--- Begin Message ---
I have a Pentium 4, this is probably the reason it's messing up. I don't
have any RAID or SCSI controllers and I've unplugged all my USB devices.
I'll try finding these things in i786, thanks for the help!
Thanks,
Stephen Craton
----- Original Message -----
From: "Dan Anderson" <[EMAIL PROTECTED]>
To: "Stephen Craton" <[EMAIL PROTECTED]>
Cc: "PHP List" <[EMAIL PROTECTED]>
Sent: Sunday, September 07, 2003 1:55 PM
Subject: Re: [PHP] Linux Issues
> > When downloading Linux ISOs or whatever, which do I need? What is the
> > difference between i386, PPC, and all those other exactly? How do I know
> > which I need?
>
> This may be the source of your problems. i386, PPC, etc. are
> architectures:
>
> i386: x386 or higher
> i586: Pentium II or higher (or equivalent)
> i686: Pentium III or higher (or equivalent)
> i786: Pentium IV or higher (or equivalent)
> PPC: Mac Power PC
> sparc: Sun Sparc
>
> And the list goes on and on. You have yet to tell the list if you are
> running any oddball configuration. Do you have any RAID or SCSI
> controllers? What about anything else?
>
> -Dan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
--- End Message ---
--- Begin Message ---
> I'll try finding these things in i786, thanks for the help!
Well you don't need an i786 and probably won't find one. i786 means you
can use it if you have a PIV but not a PIII -- basically it takes
advantage of architecture specific things. You could use an i586 or
i686 or i386 fine -- you just wouldn't get any hyperthreading (I'm not
even sure if this is supported by the Linux kernel)
-Dan
--- End Message ---
--- Begin Message ---
Am Sonntag, 07.09.03 um 14:11 Uhr schrieb Catalin Trifu
<[EMAIL PROTECTED]>:
Here the $result is changed to '<b>te</b>st' on the first search.
Obviously on the second replace the term will not be found anymore!
yes, it's obvious.
like i said:
output: this is just a <b>te</b>st
(after the first term is highlighted the second one can't be found
anymore.)
but how to work around it??
- jns
/snip/
hi, i'm working on a function that highlights search results. problem:
a search input like "te est"; two terms that match one word ("test").
the mysql query matches entries like this but my function isn't able
to highlight them the right way:
<?
function highlight($src_terms, $src_terms_int, $result) {
$i = 0;
while ($i < $src_terms_int) {
$result = preg_replace('/('.$src_terms[$i].')/si',
'<b>'.$src_terms[$i].'</b>', $result);
$i++;
}
return $result;
}
$search = "te est"; // user input to search for
$src_terms = explode(" ", $search);
$src_terms_int = count($src_terms);
$result = "this is just a test"; // result from database
print highlight($src_terms, $src_terms_int, $result);
?>
output: this is just a <b>te</b>st
(after the first term is highlighted the second one can't be found
anymore.)
someone has an idea how to work around this?
thanks for your effort!
jonas
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
Am Sonntag, 07.09.03 um 14:11 Uhr schrieb Catalin Trifu
output: this is just a <b>te</b>st
(after the first term is highlighted the second one can't be found
anymore.)
but how to work around it??
Highlight the longest words first?
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Am Sonntag, 07.09.03 um 21:17 Uhr schrieb John W. Holmes:
output: this is just a <b>te</b>st
(after the first term is highlighted the second one can't be found
anymore.)
but how to work around it??
Highlight the longest words first?
I don't think that would change anything. A search for "te est" then
highlights "test" into "t<b>est</b>" and "te" can't be found anymore.
thanks anyway!!
j
snip 8<
<?
function highlight($src_terms, $src_terms_int, $result) {
$i = 0;
while ($i < $src_terms_int) {
$result = preg_replace('/('.$src_terms[$i].')/si',
'<b>'.$src_terms[$i].'</b>', $result);
$i++;
}
return $result;
}
$search = "te est"; // user input to search for
$src_terms = explode(" ", $search);
$src_terms_int = count($src_terms);
$result = "this is just a test"; // result from database
print highlight($src_terms, $src_terms_int, $result);
?>
output: this is just a <b>te</b>st
(after the first term is highlighted the second one can't be found
anymore.)
someone has an idea how to work around this?
thanks for your effort!
jonas
ps: please also let me know if you know of a website that might help, i
didn't find anything useful. thanks!
--- End Message ---
--- Begin Message ---
On Mon, 8 Sep 2003 00:11:09 +0200, Jonas_weber @ Gmx . Ch
<[EMAIL PROTECTED]> wrote:
Am Sonntag, 07.09.03 um 21:17 Uhr schrieb John W. Holmes:
output: this is just a <b>te</b>st
(after the first term is highlighted the second one can't be found
anymore.)
but how to work around it??
Highlight the longest words first?
I don't think that would change anything. A search for "te est" then
highlights "test" into "t<b>est</b>" and "te" can't be found anymore.
Why not just allow for bold tags in the search term? What I mean is, I
think you can get the results you want by allowing any number of open or
close bold tags between each letter of the search term.
<?php
function highlight($src_terms, $src_terms_int, $result) {
$i = 0;
while ($i < $src_terms_int) {
$termWithOptionalBold = preg_replace('/(.)/', '(<\/?b>)
*\1',$src_terms[$i]);
$result = preg_replace('/(<\/?b>)*('.$termWithOptionalBold.')(<\/?b>)
*/si', '<b>\2</b>', $result);
$i++;
}
return $result;
}
?>
--
Lee O'Mara
--- End Message ---
--- Begin Message ---
I wrote a web based front end to the free Turck MMCache PHP
optimizer/encoder, a link is on the main Turck page near the bottom or
you can go to http://phpcoder.shadonet.com.
Turck was actually beating Zend in performance on the benchmark I ran as
of a few releases ago.
Jason
Charles Kline wrote:
Thanks. This is one I had not turned up in my search. Much appreciated.
- Charles
On Sunday, Sep 7, 2003, at 00:44 US/Eastern, Evan Nemerson wrote:
Take a look at Turck MMCache (free) and Zend Encoder (not).
http://www.turcksoft.com/en/e_mmc.htm
http://www.zend.com/store/products/zend-encoder.php
On Saturday 06 September 2003 01:59 pm, Charles Kline wrote:
What methods are available (ups and downs) for encrypting and
serializing php applications for sale?
Thanks,
Charles
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
> Note that you don't technically need to worry about it but if you are
> going to work with other languages it is a good habit to get into.
> Also I have noticed a significant performance increase in scripts that
> are coded more cleanly, if you don't need a variable anymore unset()
> it.
Well yes, the kind of programming you plan on doing makes a large
different. I wouldn't code an enterprise script the same way I do a
quick and dirty script to do something. You need to look at what you
are doing and its purpose. Sometimes you want to squeeze every iota of
performance out of your scripts. Sometimes you just want to get it
done. :-D
-Dan
--- End Message ---
--- Begin Message ---
Thanx for your advice.
I put this question because I need to increase performacne of the server.
So I must use unset() wherever is possible :o)
Thanx
Emo
"Dan Anderson" <[EMAIL PROTECTED]> píše v diskusním příspěvku
news:[EMAIL PROTECTED]
> > Note that you don't technically need to worry about it but if you are
> > going to work with other languages it is a good habit to get into.
> > Also I have noticed a significant performance increase in scripts that
> > are coded more cleanly, if you don't need a variable anymore unset()
> > it.
>
> Well yes, the kind of programming you plan on doing makes a large
> different. I wouldn't code an enterprise script the same way I do a
> quick and dirty script to do something. You need to look at what you
> are doing and its purpose. Sometimes you want to squeeze every iota of
> performance out of your scripts. Sometimes you just want to get it
> done. :-D
>
> -Dan
--- End Message ---
--- Begin Message ---
I would recommend installing Turck MMCache as well and you will see
immediate benefit for almost all PHP applications (assuming you are
running mod_php not as cgi), you should get a 2 to 10x performance
increase in many cases. MMCache is open source and is available free of
charge at http://www.turcksoft.com/en/e_mmc.htm for windows and unix/linux.
Jason
[cz]Emo wrote:
Thanx for your advice.
I put this question because I need to increase performacne of the server.
So I must use unset() wherever is possible :o)
Thanx
Emo
"Dan Anderson" <[EMAIL PROTECTED]> píše v diskusním příspěvku
news:[EMAIL PROTECTED]
Note that you don't technically need to worry about it but if you are
going to work with other languages it is a good habit to get into.
Also I have noticed a significant performance increase in scripts that
are coded more cleanly, if you don't need a variable anymore unset()
it.
Well yes, the kind of programming you plan on doing makes a large
different. I wouldn't code an enterprise script the same way I do a
quick and dirty script to do something. You need to look at what you
are doing and its purpose. Sometimes you want to squeeze every iota of
performance out of your scripts. Sometimes you just want to get it
done. :-D
-Dan
--- End Message ---
--- Begin Message ---
I am using PHP 5 on Windows. I have downloaded the lastest from snaps. When I
try to use the mysqli functions, I get the error message:
undefined function mysqli_connect()
I assume this means that mysqli support is not compiled into the Windows
version of PHP 5. However, there doesn't seem to be an extension dll for
mysqli either in the extension directory. And no line for it in the php.ini
file.
Does anyone know about mysqli for Windows? Is it going to be compiled into
PHP 5? Or an extension included? When might this happen? Or is there an
extension available somewhere that I can get? Or is mysqli support available
only if I compile the Windows version myself?
Thanks,
Janet
--- End Message ---
--- Begin Message ---
http://de.php.net/mysqli
Cheers,
Catalin
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am using PHP 5 on Windows. I have downloaded the lastest from snaps.
When I
> try to use the mysqli functions, I get the error message:
>
> undefined function mysqli_connect()
>
> I assume this means that mysqli support is not compiled into the Windows
> version of PHP 5. However, there doesn't seem to be an extension dll for
> mysqli either in the extension directory. And no line for it in the
php.ini
> file.
>
> Does anyone know about mysqli for Windows? Is it going to be compiled into
> PHP 5? Or an extension included? When might this happen? Or is there an
> extension available somewhere that I can get? Or is mysqli support
available
> only if I compile the Windows version myself?
>
> Thanks,
>
> Janet
--- End Message ---
--- Begin Message ---
Catalin,
Could you please be a little more specific about where on the manual page you
found the answers to my questions. I don't seem to be smart enough to find
them myself. If I was, I wouldn't have had to post the questions to the list.
Thanks,
Janet
In a message dated 9/7/2003 1:13:53 PM Pacific Daylight Time,
[EMAIL PROTECTED] writes:
http://de.php.net/mysqli
Cheers,
Catalin
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am using PHP 5 on Windows. I have downloaded the lastest from snaps.
When I
> try to use the mysqli functions, I get the error message:
>
> undefined function mysqli_connect()
>
> I assume this means that mysqli support is not compiled into the Windows
> version of PHP 5. However, there doesn't seem to be an extension dll for
> mysqli either in the extension directory. And no line for it in the
php.ini
> file.
>
> Does anyone know about mysqli for Windows? Is it going to be compiled into
> PHP 5? Or an extension included? When might this happen? Or is there an
> extension available somewhere that I can get? Or is mysqli support
available
> only if I compile the Windows version myself?
>
--- End Message ---
--- Begin Message ---
I'm having difficulty with understanding how to manipulate dates. It
seems that there's no date object manipulate so we just pass around a
bunch of values which is kinda of annoying.
A few things I'm trying to do:
1) Turn "MM/DD/YY" into an array like that returned from getdate(). I
don't want to explode it or split it, I want to get an array just as if
I used getdate() when the current day was MM/DD/YY.
2) Have a date string representing the first of the month and
manipulate it to be the last day of the previous month.
If I can figure out how I'm supposed to do those, then the rest I will
understand.
Thanks,
Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine -
http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames
"Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
------------------------------------------------------------------------
---
--- End Message ---
--- Begin Message ---
On Sunday, September 7, 2003, at 02:50 PM, Seth Willits wrote:
A few things I'm trying to do:
1) Turn "MM/DD/YY" into an array like that returned from getdate(). I
don't want to explode it or split it, I want to get an array just as
if I used getdate() when the current day was MM/DD/YY.
It just dawned on me that the timestamp parameter for getdate() is
exactly what does this. So forget this one :)
2) Have a date string representing the first of the month and
manipulate it to be the last day of the previous month.
This, I'm still wondering about. This is the code I have:
$month = $date['mon'];
$year = $date['year'];
if ($month == 1) {
$lastofprevmonth = date('t', strtotime('12' . '/01/' . ($year-1) ));
$lastofprevmonth = date('m/d/y', strtotime('12' . '/' .
$lastofprevmonth . '/' . ($year-1)));
} else {
$lastofprevmonth = date('t', strtotime(($month-1) . '/01/' . $year));
$lastofprevmonth = date('m/d/y', strtotime(($month-1) . '/' .
$lastofprevmonth . '/' . $year));
}
This is a far cry from the simple trick in other languages where you
just subtract one from the first of the current month and your date
then reflects the last day of the previous month. Can that be done in
PHP?
Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine -
http://www.rbdeveloper.com
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames
"When purchasing that gift for your Special Someone guys remember, girls
like cute things. If it makes you want to puke, your chick will totally
love it."
-- Someone else out There
------------------------------------------------------------------------
---
--- End Message ---
--- Begin Message ---
Seth Willits wrote:
2) Have a date string representing the first of the month and
manipulate it to be the last day of the previous month.
You can use mktime() for this. To get the last day of a given month,
just give the parameters for the "zeroth" day of the next month. For
example, to get the date for the end of $month:
$month = 4;
$year = 2003;
$endofmonth = date('m/d/y',mktime(12,0,0,$month+1,0,$year));
$endofmonth is now the last day of the April for 2003 in MM/DD/YY format.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Hello,
I wanna create an online game in php and mysql and I have a problem. I have this
database with this fields; id and number_attacks. And every 10 minutes number_attack
to be increased by 1. How can i do that?
Thanks
--- End Message ---
--- Begin Message ---
Hi,
> I have this database with this fields; id and
> number_attacks. And every 10 minutes
> number_attack to be increased by 1.
You'll need to set up some sort of scheduled task (if you're on unix, your
best bet is probably cron) - this task should call a script that connects to
your database and updates the field. If you like, you can write the script
in PHP and use something like lynx or wget to access it.
Cheers
Jon
--- End Message ---
--- Begin Message ---
*This message was transferred with a trial version of CommuniGate(tm) Pro*
Or, if you only want the number_attacks to increase for every 10 minutes
that someone's playing (so it's not increasing throughout the night)
you'll probably just want to hold the time the game started in a
variable (or DB whatever) and just check with each page refresh to see
if it's time to increase the value.
There's other ways to do it, but your question was kinda vague so I'm
not sure what method would work best for ya.
Michael Kennedy
www.onionology.com
-----Original Message-----
From: Jon Haworth [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 07, 2003 5:10 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] game in php
*This message was transferred with a trial version of CommuniGate(tm)
Pro*
Hi,
> I have this database with this fields; id and
> number_attacks. And every 10 minutes
> number_attack to be increased by 1.
You'll need to set up some sort of scheduled task (if you're on unix,
your
best bet is probably cron) - this task should call a script that
connects to
your database and updates the field. If you like, you can write the
script
in PHP and use something like lynx or wget to access it.
Cheers
Jon
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Another way you can do it if you don't have that much access to the machine
is to record the last time it was updated and when someone loads the page,
you take the amount of time between the last incriment and now().
You then find out how many sets of 10 minutes have passed and incriment it
that many times (if it's less than 10 minutes, you'll be incrimenting zero
times).
The only problem with this is that if 100 people load the script in a 10
minute period, only one will be updating the database - the other 99 are
wasted traffic on the DB.
But if you have no other options...
-----Original Message-----
From: Jon Haworth [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 07, 2003 6:10 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] game in php
Hi,
> I have this database with this fields; id and
> number_attacks. And every 10 minutes
> number_attack to be increased by 1.
You'll need to set up some sort of scheduled task (if you're on unix, your
best bet is probably cron) - this task should call a script that connects to
your database and updates the field. If you like, you can write the script
in PHP and use something like lynx or wget to access it.
Cheers
Jon
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
How do I get a function to return an array? This code doesn't work:
function getData() {
<function builds the array $theArray - tested ok>
return $theArray;
}
Any help on the syntax would be appreciated.
Cheers
Leonie
--- End Message ---
--- Begin Message ---
Hi,
Monday, September 8, 2003, 11:54:10 AM, you wrote:
L> How do I get a function to return an array? This code doesn't work:
L> function getData() {
L> <function builds the array $theArray - tested ok>
L> return $theArray;
L> }
L> Any help on the syntax would be appreciated.
L> Cheers
L> Leonie
That should work
what do you get with this:
$array = getData();
print_r($array);
--
regards,
Tom
--- End Message ---
--- Begin Message ---
Nothing. But it I run:
function getData() {
etc..
print_r ($theArray);
return $theArray;
}
the data is definitely there.
I should add that the function is within a class so it is like this:
class excel_com {
(all tested - it works well)
function getData() {
etc..
return $theArray;
}
}
and here is an example of the call:
$xls = new excel_com($workbook, $wks);
$xls->Range($range, $inclHeader);
$header=$xls->header;
$data = $xls->getData();
$xls->close();
unset($xls);
> what do you get with this:
>
> $array = getData();
> print_r($array);
>
> --
> regards,
> Tom
--- End Message ---
--- Begin Message ---
Hi,
Monday, September 8, 2003, 12:16:47 PM, you wrote:
L> Nothing. But it I run:
L> function getData() {
L> etc..
L> print_r ($theArray);
L> return $theArray;
L> }
L> the data is definitely there.
L> I should add that the function is within a class so it is like this:
L> class excel_com {
L> (all tested - it works well)
L> function getData() {
L> etc..
L> return $theArray;
L> }
L> }
L> and here is an example of the call:
L> $xls = new excel_com($workbook, $wks);
L> $xls->Range($range, $inclHeader);
L> $header=$xls->header;
L> $data = $xls->getData();
L> $xls->close();
L> unset($xls);
Well from what is there that should work...very strange
does print_r show an empty array or nothing?
is $theArray created in the getData() function or is part of the class and
needs return $this->theArray
--
regards,
Tom
--- End Message ---
--- Begin Message ---
Nothing. But it I run:
function getData() {
etc..
print_r ($theArray);
return $theArray;
}
the data is definitely there.
I think the example in the PHP manual goes something like...
function getData () {
// blah, blah
return array ('value1', 'value2', ...);
}
Then you would call it with
list ($var1, $var2, ...) = getData();
Hope that helps,
Larry
--- End Message ---
--- Begin Message ---
I'm running 4.3.3, and have made sure to compile it with
--enable-sysvshm. The code works on PHP5, so I think it might be a
problem with PHP4.
#! /usr/bin/php -q
<?php
$key = ftok("/etc/passwd", 'c');
$shmid = shm_attach($key);
$shm_var = "Shared Memory Data";
shm_put_var($key, 25, $shm_var);
$shm_data = shm_get_var($key, 25);
echo "$key, $shmid, $shm_var, $shm_data\n";
shm_detach($shmid);
?>
When I try and run it, I get these errors:
Warning: 1661167266 is not a SysV shared memory index in
/home/jason/dev/php/ipc/shm1.php on line 9
Warning: 1661167266 is not a SysV shared memory index in
/home/jason/dev/php/ipc/shm1.php on line 10
Am I doing something wrong, or is this a problem with PHP?
Jason
--- End Message ---