php-general Digest 10 Jul 2004 13:45:27 -0000 Issue 2868
Topics (messages 190111 through 190131):
breadcrumb app...
190111 by: bruce
190115 by: Tim Van Wassenhove
Re: eregi_replace driving me nuts
190112 by: Matt M.
Re: eregi_replace()
190113 by: Matt M.
190117 by: John Taylor-Johnston
190118 by: John Taylor-Johnston
190119 by: John Taylor-Johnston
ImageCopyResized works on JPG but not PNG?
190114 by: Jough P
190116 by: Jason Wong
search string / query format
190120 by: Ed Lazor
190121 by: John W. Holmes
190122 by: John Taylor-Johnston
190123 by: Ed Lazor
Re: PHP Hosting
190124 by: Cornelius Engelbrecht
get the month's last day
190125 by: Sheawh
190126 by: John W. Holmes
190128 by: Sheawh
Re: SOLVED: ImageCopyResized works on JPG but not PNG?
190127 by: Jough P
Help Formatting String into URL
190129 by: Ryan Schefke
190130 by: Frank Voorburg
190131 by: Ryan Schefke
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...
has anybody seen a reasonably good/basic breadcrumb app that works... new
pages are displayed to the user based upon the user's menu selection...
i'd like to be able to provide a trail at the top of the page, kind of
like..
home -> food -> fruit -> squash
were the user could then select one of the links of the trail, which would
take the user to the earlier page...
searching google results in hundreds of results, but i'm not sure which
examples are good/poor!!
thanks
-bruce
--- End Message ---
--- Begin Message ---
In article <[EMAIL PROTECTED]>, Bruce wrote:
> has anybody seen a reasonably good/basic breadcrumb app that works... new
> pages are displayed to the user based upon the user's menu selection...
The best approach i've seen untill now is to keep a stack with pages
that have been visited. And each time another script is expected to be
loaded/unloaded the calling script would have to call scriptNext or
scriptPrevious to keep the stack up to date. This way you do not only
have an easy way to build a path with breadcrumbs but also a way to
handle things like ppl that hit the back button after posting a form...
--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
--- End Message ---
--- Begin Message ---
> What I'm trying to do:
>
> I'm trying to have the proper variables for the eregi_replace so that each
> word in the $dico array is replaced by a link to its definition respecting
> the following rules :
> -only exact match makes a link to the definition, for example :
> - "abaisseraient" doesn't make a link
> - "reabaisser" doesn't make a link
> - " abaisser," or "smthg.Abaisser " makes a link on "abaisser" only,
> so that the whitespace, comma or dot isn't part of the link
> - "abaisser" a the end of the string make a link
>
> -I don't want to make a link when already in a link :
> - "<a href='some_page.php'>tu peux abaisser le levier</a>" doesn't not
> make a link on "abaisser"
>
> I know I'm bad with regex and really need some help on this. This would be
> really appreciated.
I gave it my best, I could not figure out how to do it in a single
regex. You could make this code more efficient but I think this might
do what you want.
<?
$dico = array(
"abaisser" => "def.php?id=9",
"singer" => "def.php?id=9"
);
$texte = "Abaisser Vous abaisserez la pate, abaisser.Singer Abaisser
Vous abaisserez la pate,<a href=\"some_page.php\">
abaisser.Singer</a>singer<a href=\"some_page_other.php\">
abaisser.Singer</a>";
echo $texte."<br />\n";
preg_match_all('/<a\s+.*?href=[\"\'\s]?.*?>.*?<\/a>/i', $texte, $matches);
if (is_array($matches[0])) {
$counter = 0;
foreach ($matches[0] as $value){
$texte = str_replace ( $value, " REPLACEME$counter ", $texte);
$counter++;
}
}
foreach ($dico as $mot => $def) {
$pattern = '/('.$mot.'\b)/i';
print "$pattern<br />\n";
$texte = preg_replace($pattern,"<a href=\"$def\">$1</a>",$texte);
}
if (is_array($matches[0])) {
$counter = 0;
foreach ($matches[0] as $value){
$texte = str_replace ( " REPLACEME$counter ", $value, $texte);
$counter++;
}
}
echo $texte;
?>
--- End Message ---
--- Begin Message ---
> $searchenquiry = "Never cry Wolfe"
> and
> $mydata->ST contains "... Never Cry Wolfe ..."
>
> This code echos:
> <td>".preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>",
> $mydata->ST)." </td>
>
> <td>... <b>Never cry Wolfe</b> ...</td>
>
> But I want it to use the original text and echo:
>
> <td>... <b>Never Cry Wolfe</b> ...</td>
I just tried this code:
$searchenquiry = "Never cry Wolfe";
$mydata = "... Never Cry Wolfe ...";
$new = preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata);
echo "<td>$new </td>";
here was my output:
<td>... <b>Never Cry Wolfe</b> ... </td>
isnt that what you want?
--- End Message ---
--- Begin Message ---
>isnt that what you want?
Hmm? Yes. But it doesn't work for me? It cannot be a php verison thing, can it?
I have phpversion() 4.1.2. I don't get it? :)
Compare with:
http://compcanlit.usherbrooke.ca/new1/db/index.php?searchenquiry=Never%20Cry%20Wolfe
and then:
http://compcanlit.usherbrooke.ca/new1/db/index.php?searchenquiry=Never%20cry%20Wolfe
Here is my code:
<td>".preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata->AU)." </td>
<td>".preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata->ST)." </td>
<td>".preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata->BT)." </td>
<td>".preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata->JR)." </td>
> I just tried this code:
>
> $searchenquiry = "Never cry Wolfe";
> $mydata = "... Never Cry Wolfe ...";
> $new = preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata);
> echo "<td>$new </td>";
>
> here was my output:
>
> <td>... <b>Never Cry Wolfe</b> ... </td>
>
> isnt that what you want?
--- End Message ---
--- Begin Message ---
>isnt that what you want?
I don't see anything in the manual that says it can't?
http://ca3.php.net/manual/en/function.preg-replace.php
Thanks for trying.
John
> > $searchenquiry = "Never cry Wolfe"
> > and
> > $mydata->ST contains "... Never Cry Wolfe ..."
> >
> > This code echos:
> > <td>".preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>",
> > $mydata->ST)." </td>
> >
> > <td>... <b>Never cry Wolfe</b> ...</td>
> >
> > But I want it to use the original text and echo:
> >
> > <td>... <b>Never Cry Wolfe</b> ...</td>
>
> I just tried this code:
>
> $searchenquiry = "Never cry Wolfe";
> $mydata = "... Never Cry Wolfe ...";
> $new = preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata);
> echo "<td>$new </td>";
>
> here was my output:
>
> <td>... <b>Never Cry Wolfe</b> ... </td>
>
> isnt that what you want?
--- End Message ---
--- Begin Message ---
Sorry. I have it working. My fault. I had a previous line:
$mydata->ST = eregi_replace($searchenquiry, "<b>".$searchenquiry."</b>", $mydata->ST);
THANKS!
John
"Matt M." wrote:
> > $searchenquiry = "Never cry Wolfe"
> > and
> > $mydata->ST contains "... Never Cry Wolfe ..."
> >
> > This code echos:
> > <td>".preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>",
> > $mydata->ST)." </td>
> >
> > <td>... <b>Never cry Wolfe</b> ...</td>
> >
> > But I want it to use the original text and echo:
> >
> > <td>... <b>Never Cry Wolfe</b> ...</td>
>
> I just tried this code:
>
> $searchenquiry = "Never cry Wolfe";
> $mydata = "... Never Cry Wolfe ...";
> $new = preg_replace ('/('.$searchenquiry.')/i' , "<b>$1</b>", $mydata);
> echo "<td>$new </td>";
>
> here was my output:
>
> <td>... <b>Never Cry Wolfe</b> ... </td>
>
> isnt that what you want?
--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not open-source, it's Murphy's Law."
' ' ' Collège de Sherbrooke:
ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
- Université de Sherbrooke:
http://compcanlit.ca/
819-569-2064
--- End Message ---
--- Begin Message ---
Greetings all, I have a real simple function. I works well on JPG
images but ImageCopyResized(), or ImagePNG() doesn't seem to be
working. When I view the uploaded file it is still it's original size.
Here is the function. I hope someone can help me, I'm pretty stumped.
function transform_to_profile_pic()
{
$path = $this->origpath;
$type = $this->type;
# make jpg or png image
$img_dst = imagecreatetruecolor(PROFILE_IMAGE_W,PROFILE_IMAGE_H);
if($type == 2)
$img_src = imagecreatefromjpeg($path);
else if($type == 3)
$img_src = imagecreatefrompng($path);
# Overwrite the original with the resized image to the filesystem
imagecopyresized($img_dst, $img_src, 0, 0, 0, 0, PROFILE_IMAGE_W,
PROFILE_IMAGE_H, imagesx($img_src), imagesy($img_src)
if($type == 2)
imagejpeg($img_dst, $path, 100);
else if($type == 3)
imagepng($img_dst, $path . ".png", 100);
}
--- End Message ---
--- Begin Message ---
On Saturday 10 July 2004 06:38, Jough P wrote:
> Greetings all, I have a real simple function. I works well on JPG
> images but ImageCopyResized(), or ImagePNG() doesn't seem to be
> working. When I view the uploaded file it is still it's original size.
> Here is the function. I hope someone can help me, I'm pretty stumped.
Several points:
1) Is this copy and paste? You seem to have a missing semi-colon in your code.
2) You do realise you're using a different filename for your resized PNG?
3) Strip your code down to the bare minimum so that you can isolate the
problem and make debugging easier. In this case remove the jpeg stuff and
hence the IF clauses.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
"We Americans, we're a simple people... but piss us off, and we'll bomb
your cities."
-- Robin Williams, _Good Morning Vietnam_
*/
--- End Message ---
--- Begin Message ---
I'm going to create a search page that accepts input similar to places like
Yahoo and Google. Example input would be:
Keyword AND keyword2
Keyword -keyword2 +keyword3
"keyword keyword2" -keyword3
Rather than reinvent things though, I'm wondering if anyone here happens to
have a script or function that will handle that type of input. It would be
great if someone already has a function that accepts the initial query, a
table to query against, and a list of fields to query against, and returns
the appropirate SQL statement. Also, I've heard that MySQL's indexing can
support some of this, but I'm not sure how much.
Thanks in advance for any pointers or info you might have on this.
-Ed
--- End Message ---
--- Begin Message ---
Ed Lazor wrote:
I'm going to create a search page that accepts input similar to places like
Yahoo and Google.
[snip]
> Also, I've heard that MySQL's indexing can
support some of this, but I'm not sure how much.
Using a FULLTEXT index and searching in BOOLEAN mode supports the type
of search strings that you wrote.
Consult thine manual!! (The MySQL one) ;)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
>>Keyword AND keyword2
>>"keyword keyword2" -keyword3
It doesn't support AND or OR but it does use - + * and others.
>Consult thine manual!! (The MySQL one) ;)
http://dev.mysql.com/doc/mysql/en/Fulltext_Search.html
The problem is getting a FULLTEXT to sort by relevancy. This was a real pain, until
our friend John W. showed me the error of my ways; (see below).
MySQL> "The preceding example is a basic illustration showing how to use the MATCH()
function
MySQL> where rows are returned in order of decreasing relevance"
I never did believe the "examples" helped me:
http://dev.mysql.com/doc/mysql/en/Fulltext_Search.html
You will need something like this to make the operators display according to
relevancy. This works:
SELECT *,MATCH (field1,field2,field3) AGAINST ('Margaret Atwood' IN BOOLEAN MODE)
AS relevancy FROM
mytable WHERE MATCH (field1,field2,field3) AGAINST ('Margaret Atwood' IN BOOLEAN
MODE) ORDER BY
relevancy DESC;
This does not sort by relevancy well at all:
SELECT * (field1,field2,field3) FROM mytable AGAINST ('Margaret Atwood' IN BOOLEAN
MODE);
P.S. John W.: thanks for helping me on my post last week. I finally got this working.
John
"John W. Holmes" wrote:
> Ed Lazor wrote:
> > I'm going to create a search page that accepts input similar to places like
> > Yahoo and Google.
> [snip]
> > Also, I've heard that MySQL's indexing can
> > support some of this, but I'm not sure how much.
>
> Using a FULLTEXT index and searching in BOOLEAN mode supports the type
> of search strings that you wrote.
>
> Consult thine manual!! (The MySQL one) ;)
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> > I'm going to create a search page that accepts input similar to places
> like
> > Yahoo and Google.
> [snip]
> > Also, I've heard that MySQL's indexing can
> > support some of this, but I'm not sure how much.
>
> Using a FULLTEXT index and searching in BOOLEAN mode supports the type
> of search strings that you wrote.
>
> Consult thine manual!! (The MySQL one) ;)
*grin* Thanks John, I knew someone would know where I'd seen it hehe
-Ed
--- End Message ---
--- Begin Message ---
I have been using Zentrifugal.com for quite some time and it works great for
me. They are quite inexpensive too - only $99 per year. I have no
affiliation with them, just a satisfied customer.
Cornelius
-----Original Message-----
From: Ed Lazor [mailto:[EMAIL PROTECTED]
Sent: Friday, July 09, 2004 2:08 AM
To: [EMAIL PROTECTED]
Subject: [PHP] PHP Hosting
Hey, does anyone have experience hosting PHP / MySQL apps on EV1servers.net,
ServerBeach.net, or CIhost.com? I'm looking for value, reliability, and
quality support. Any other recommendations are also greatly appreciated.
-Ed
--- End Message ---
--- Begin Message ---
how can i retrieve the last day of the month?
like 31 - Jul, 30 - Jun , 28 - Feb
--- End Message ---
--- Begin Message ---
Sheawh wrote:
how can i retrieve the last day of the month?
like 31 - Jul, 30 - Jun , 28 - Feb
<?php
$month = 8;
$year = 2003;
$lastdayofmonth = mktime(12,0,0,$month+1,0,$year);
?>
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
I've found the date() function with "t" returns the correct result
thanks all
so check this out for more reference if anybody got same problem too!
http://hk2.php.net/manual/en/function.date.php
"Sheawh" <[EMAIL PROTECTED]> ¦b¶l¥ó
news:[EMAIL PROTECTED] ¤¤¼¶¼g...
> how can i retrieve the last day of the month?
> like 31 - Jul, 30 - Jun , 28 - Feb
--- End Message ---
--- Begin Message ---
yup, you were right. I was naming the image "image.png.png". DOH!
been a long week....
Thanks!!
On Jul 9, 2004, at 6:42 PM, Jason Wong wrote:
On Saturday 10 July 2004 06:38, Jough P wrote:
Greetings all, I have a real simple function. I works well on JPG
images but ImageCopyResized(), or ImagePNG() doesn't seem to be
working. When I view the uploaded file it is still it's original
size.
Here is the function. I hope someone can help me, I'm pretty
stumped.
Several points:
1) Is this copy and paste? You seem to have a missing semi-colon in
your code.
2) You do realise you're using a different filename for your resized
PNG?
3) Strip your code down to the bare minimum so that you can isolate the
problem and make debugging easier. In this case remove the jpeg stuff
and
hence the IF clauses.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
"We Americans, we're a simple people... but piss us off, and we'll bomb
your cities."
-- Robin Williams, _Good Morning Vietnam_
*/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi,
Can someone help me write a short code snippet to format a string to add:
http://www <http://www/> -- if the string is "google.com" and doesn't have
http://www <http://www/> in front of it
http:// <http://www/> -- if the string is "www.google.com" and doesn't
have http:// in front of it
.if you know of a better way to securely check/format a url like this please
let me know.
Thanks,
Ryan
--- End Message ---
--- Begin Message ---
Ryan,
You can use the following function:
function FormatUrl($url)
{
if (eregi("www", $url))
$result = "http://$url";
else
$result = "http://www.$url";
return $result;
}
You can test it using:
$test1 = FormatUrl("google.com");
$test2 = FormatUrl("www.google.com");
print "test1 = $test1<br>";
print "test2 = $test2<br>";
And this will give you the results:
test1 = http://www.google.com
test2 = http://www.google.com
Good luck!
-Frank
"Ryan Schefke" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
>
>
> Can someone help me write a short code snippet to format a string to add:
>
>
>
> http://www <http://www/> -- if the string is "google.com" and doesn't
have
> http://www <http://www/> in front of it
>
>
>
> http:// <http://www/> -- if the string is "www.google.com" and doesn't
> have http:// in front of it
>
>
>
> .if you know of a better way to securely check/format a url like this
please
> let me know.
>
>
>
> Thanks,
>
> Ryan
>
>
>
>
--- End Message ---
--- Begin Message ---
Hi Frank,
Thanks, you got me started. I modified your function a bit. I'm testing for
3 cases now and the appearance of http://, https://, or ftp:// in front of
the string. Let me know if you advise any changes.
<?php
function FormatUrl($url)
{
$url = trim($url);
if (eregi("^(((http)|(https)|(ftp)){1}://)", $url)) {
$result = "$url"; // do nothing
} else if (eregi("^www\.{1}", $url)) {
$result = "http://$url";
} else {
$result = "http://www.$url";
}
return $result;
}
?>
-----Original Message-----
From: Frank Voorburg [mailto:[EMAIL PROTECTED]
Sent: Saturday, July 10, 2004 9:59 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Help Formatting String into URL
Ryan,
You can use the following function:
function FormatUrl($url)
{
if (eregi("www", $url))
$result = "http://$url";
else
$result = "http://www.$url";
return $result;
}
You can test it using:
$test1 = FormatUrl("google.com");
$test2 = FormatUrl("www.google.com");
print "test1 = $test1<br>";
print "test2 = $test2<br>";
And this will give you the results:
test1 = http://www.google.com
test2 = http://www.google.com
Good luck!
-Frank
"Ryan Schefke" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
>
>
> Can someone help me write a short code snippet to format a string to add:
>
>
>
> http://www <http://www/> -- if the string is "google.com" and doesn't
have
> http://www <http://www/> in front of it
>
>
>
> http:// <http://www/> -- if the string is "www.google.com" and doesn't
> have http:// in front of it
>
>
>
> .if you know of a better way to securely check/format a url like this
please
> let me know.
>
>
>
> Thanks,
>
> Ryan
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---