php-general Digest 20 Aug 2007 02:01:16 -0000 Issue 4971
Topics (messages 261014 through 261028):
Re: Cookies and sent headers
261014 by: Nisse Engström
Re: Redirection with header (was Re: [PHP] Cookies and sent headers)
261015 by: tedd
261025 by: Wouter van Vliet / Interpotential
Re: getting from one table listing from another
261016 by: tedd
261017 by: Stut
261018 by: Jay Blanchard
261019 by: Larry Garfield
261022 by: tedd
261023 by: Jay Blanchard
Render fonts
261020 by: Emil Edeholt
261021 by: Al
261024 by: zerof
261028 by: Hamza Saglam
Re: iterating and changing value of an array using foreach and references - PHP
5.2.3
261026 by: Sean Pringle
Switch To VoIPTelco And Save!
261027 by: VoIPTelco.net
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 ---
On Sat, 18 Aug 2007 17:03:35 +0200, "M. Sokolewicz" wrote:
> The reason why setting cookies for you doesn't work is because of the
> way a HTTP response is structured. It consists of 2 parts: header and
> body separated by 2 new lines (\n\n). It is _required_ that _all_
> headers come _before_ the body. Cookies are actually headers (a
Actually, it is perfectly possible (in theory) to
send most headers _after_ the body. See RFC 2616,
sections 14.40, 3.6.1 and 14.39. I don't think it is
possible with (non-nph) PHP though.
/Nisse
--- End Message ---
--- Begin Message ---
At 8:52 AM +0200 8/19/07, Otto Wyss wrote:
In my case I could easilly do without redirection but just exit and
fall back on the calling page. Yet I want to remove the login page
from the browser history. Does the header function have the same
effect?
O. Wyss:
Instead of messing with the user's browser (not good IMO), why not
use $_SESSION and make it such that if the user selects the log-on
page again, they are redirected to another page? You don't even need
header() to do that.
Here's an example:
http://webbytedd.com/bb/one-time
You will only see that page only once -- unless you find a way to
clear the session.
The process is simply to set a session variable and allow the user to
see the page once. Upon returning, the session variable is checked
and if it is "not null", then the user is redirected to another page
like so:
if($visit != null)
{
ob_clean();
include('a.php');
exit(0);
}
Very simple.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
What you're proposing, is to actually display some content on another page
then were the content is originally intended? I'm sorry, but I would
consider that 'bad practice'. To me, it makes perfect sense that you don't
want to leave the user on the page where login was originally handled. For
various reasons. One very obvious would be the 'refresh thing', where your
browser asks the user if they want to send the form again. Quite annoying.
Then, what about bookmarks? ...
I would definately go for the Location: header solution!
On 19/08/07, tedd <[EMAIL PROTECTED]> wrote:
>
> At 8:52 AM +0200 8/19/07, Otto Wyss wrote:
> >In my case I could easilly do without redirection but just exit and
> >fall back on the calling page. Yet I want to remove the login page
> >from the browser history. Does the header function have the same
> >effect?
> >
>
> O. Wyss:
>
> Instead of messing with the user's browser (not good IMO), why not
> use $_SESSION and make it such that if the user selects the log-on
> page again, they are redirected to another page? You don't even need
> header() to do that.
>
> Here's an example:
>
> http://webbytedd.com/bb/one-time
>
> You will only see that page only once -- unless you find a way to
> clear the session.
>
> The process is simply to set a session variable and allow the user to
> see the page once. Upon returning, the session variable is checked
> and if it is "not null", then the user is redirected to another page
> like so:
>
> if($visit != null)
> {
> ob_clean();
> include('a.php');
> exit(0);
> }
>
> Very simple.
>
> 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
>
>
--
Interpotential.com
Phone: +31615397471
--- End Message ---
--- Begin Message ---
At 6:12 PM -0500 8/18/07, Jay Blanchard wrote:
[snip]
I know this is kinda crazy but I need it :P
I have one table that lists name's
and I have another table that has the name's and points
I want to know how to list the name's of the first table by the points
of the second table
[/snip]
Not crazy, pretty standard from a database point of view;
SELECT a.name, b.points
FROM table a LEFT OUTER JOIN table b
ON(a.name = b.name)
This only works if the name in table a matches a name in table b.
Then why use a JOIN? It's my understanding that JOINs are used to
included unmatched rows -- am I wrong?
Wouldn't this be simpler?
SELECT a.name, b.points
FROM table_name a, table_name_points b
WHERE a.name = b.name
Besides, all that JOIN stuff makes my head hurt.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
tedd wrote:
At 6:12 PM -0500 8/18/07, Jay Blanchard wrote:
[snip]
I know this is kinda crazy but I need it :P
I have one table that lists name's
and I have another table that has the name's and points
I want to know how to list the name's of the first table by the points
of the second table
[/snip]
Not crazy, pretty standard from a database point of view;
SELECT a.name, b.points
FROM table a LEFT OUTER JOIN table b
ON(a.name = b.name)
This only works if the name in table a matches a name in table b.
Then why use a JOIN? It's my understanding that JOINs are used to
included unmatched rows -- am I wrong?
Wouldn't this be simpler?
SELECT a.name, b.points
FROM table_name a, table_name_points b
WHERE a.name = b.name
Besides, all that JOIN stuff makes my head hurt.
Maybe so, but what you've done there is an implicit join. I'd recommend
you learn as much as you can about join operations - they can make life
a lot easier and more efficient.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
[snip]
At 6:12 PM -0500 8/18/07, Jay Blanchard wrote:
>[snip]
>I know this is kinda crazy but I need it :P
>I have one table that lists name's
>and I have another table that has the name's and points
>I want to know how to list the name's of the first table by the points
>of the second table
>[/snip]
>
>Not crazy, pretty standard from a database point of view;
>
>SELECT a.name, b.points
>FROM table a LEFT OUTER JOIN table b
>ON(a.name = b.name)
>
>This only works if the name in table a matches a name in table b.
Then why use a JOIN? It's my understanding that JOINs are used to
included unmatched rows -- am I wrong?
[/snip]
Exactly. If there is a name in table a that has no points in table b you
will see the name from a and a NULL from b. If you only want names that
have points you can use the implicit join that you illustrate.
--- End Message ---
--- Begin Message ---
On Sunday 19 August 2007, tedd wrote:
> >Not crazy, pretty standard from a database point of view;
> >
> >SELECT a.name, b.points
> >FROM table a LEFT OUTER JOIN table b
> >ON(a.name = b.name)
> >
> >This only works if the name in table a matches a name in table b.
>
> Then why use a JOIN? It's my understanding that JOINs are used to
> included unmatched rows -- am I wrong?
>
> Wouldn't this be simpler?
>
> SELECT a.name, b.points
> FROM table_name a, table_name_points b
> WHERE a.name = b.name
>
> Besides, all that JOIN stuff makes my head hurt.
>
> Cheers,
>
> tedd
There are various kinds of JOINs. The most common you'll actually use are
INNER JOIN and LEFT OUTER JOIN.
You should use an explicit INNER JOIN over an implicit join (what you have
above) for two main reasons:
1) It's clearer and more obvious what you're doing.
2) The syntax for implicit joins changed very slightly in MySQL 5, so code
using them *may* in some circumstances, break when you upgrade. (We
discovered this the hard way at work when dealing with some legacy code.)
3) I believe it's more cross-database standardized (nobody expects the Spanish
Inquisition!)
INNER JOINs return rows only if there are matching values in both tables.
LEFT OUTER JOINs return rows if there are matches in just the first (left)
table, and fill in NULL values for the columns from the right table if
nothing matches.
For more information, consult the MySQL manual or a good MySQL forum.
--
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 ---
At 12:56 PM -0500 8/19/07, Larry Garfield wrote:
On Sunday 19 August 2007, tedd wrote:
> Wouldn't this be simpler?
SELECT a.name, b.points
FROM table_name a, table_name_points b
> WHERE a.name = b.name
There are various kinds of JOINs. The most common you'll actually use are
INNER JOIN and LEFT OUTER JOIN.
You should use an explicit INNER JOIN over an implicit join (what you have
above) for two main reasons:
1) It's clearer and more obvious what you're doing.
2) The syntax for implicit joins changed very slightly in MySQL 5, so code
using them *may* in some circumstances, break when you upgrade. (We
discovered this the hard way at work when dealing with some legacy code.)
3) I believe it's more cross-database standardized (nobody expects the Spanish
Inquisition!)
INNER JOINs return rows only if there are matching values in both tables.
LEFT OUTER JOINs return rows if there are matches in just the first (left)
table, and fill in NULL values for the columns from the right table if
nothing matches.
Larry:
Ok, that makes sense. The term "JOIN" means to consider/include the
contents from more than one table. The "INNER" term is for items that
are common between the tables (i.e., intersection) and the "OUTER"
term is to consider the items of one table regardless of their
presence in another.
However, the LEFT and RIGHT will take me a while to figure out.
Thanks, for your explanation.
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
[snip]
However, the LEFT and RIGHT will take me a while to figure out.
[/snip]
FROM table a LEFT OUTER JOIN table b
ON(a.column = b.column)
Just follow the order tedd, a is on the left and b is on the right
LEFT OUTER -> a -> b (what may be in a might not be in b)
a <- b <- RIGHT OUTER (what may be in b might not be in a)
FROM table a INNER JOIN table b
ON(a.column = b.column)
a -> INNER JOIN -> b (only where in a and b)
--- End Message ---
--- Begin Message ---
Hi
I would like to render some fonts into images, for captions on a site.
What tools should I use to get the best looking render? Do you guys use
the built-in tools PHP has, or are there third party libraries that does
a better job?
Thanks!
Kind regards Emil
--- End Message ---
--- Begin Message ---
Take a look at the PHP Imagick library API for Imagemagick.
Imagemagick will create as good quality fonts as you like. Here is an example
of one I've done in a test file. http://www.ridersite.org/imagemagick/Imagick.php
Emil Edeholt wrote:
Hi
I would like to render some fonts into images, for captions on a site.
What tools should I use to get the best looking render? Do you guys use
the built-in tools PHP has, or are there third party libraries that does
a better job?
Thanks!
Kind regards Emil
--- End Message ---
--- Begin Message ---
I would like to render some fonts into images, for captions on a site.
What tools should I use to get the best looking render? Do you guys
use the built-in tools PHP has, or are there third party libraries
that does a better job?
...............
http://www.educar.pro.br/en/a/gdlib/
--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
----------------------------------------------------------
You must hear, always, one second opinion! In all cases.
----------------------------------------------------------
Let the people know if this info was useful for you!
----------------------------------------------------------
--- End Message ---
--- Begin Message ---
Hi Emil,
Just an alternative solution you may want to consider..
Rather than converting your captions/headings to images, you can also use
the sIFR Image replacement technique.
Quote from the the author's description:
----------------
"sIFR is meant to replace short passages of plain browser text with text
rendered in your typeface of choice, regardless of whether or not your
users have that font installed on their systems. It accomplishes this by
using a combination of javascript, CSS, and Flash."
----------------
You can find more details on: http://www.mikeindustries.com/sifr/ and a demo
page is located at http://www.mikeindustries.com/blog/files/sifr/2.0/ .
Regards,
Hamza
"Emil Edeholt" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi
>
> I would like to render some fonts into images, for captions on a site.
> What tools should I use to get the best looking render? Do you guys use
> the built-in tools PHP has, or are there third party libraries that does a
> better job?
>
> Thanks!
>
> Kind regards Emil
--- End Message ---
--- Begin Message ---
On 8/18/07, Yashesh Bhatia <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Here's an interesting observation i noticed while using foreach to
> iterate on arrays using
> references for it's values.
>
>
> -----------------------------------------------------------------------------------------------------------------
> PHP version
> $ php -v
> PHP 5.2.3 (cli) (built: Jun 8 2007 14:31:21)
> Copyright (c) 1997-2007 The PHP Group
> Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
> -----------------------------------------------------------------------------------------------------------------
> Source code
> <?php
>
> // initialize array
> $cat1 = array();
> $cat1[15] = array('tid' => 15, 'ar_needed' => 'no');
> $cat1[16] = array('tid' => 16, 'ar_needed' => 'no');
> $cat1[17] = array('tid' => 17, 'ar_needed' => 'no');
>
> // print it
> print "\n\$cat1 = ";
> print_r($cat1);
> print "\n";
>
> // iterate using foreach and reference
> foreach ($cat1 as $k => &$v) {
> if ($k == 15) {
> $v['ar_needed'] = 'yes'; // dummy change
> }
> }
>
> // print array
> print "\n\$cat1 = ";
> print_r($cat1);
> print "\n";
At this point, $v is still a reference to $cat1[17]. Try:
unset($v);
> // reiterate
> foreach ($cat1 as $k => $v) {
> print "\$k = $k\n";
> print "\$v = ";
> print_r($v);
> print "\n";
> }
> ?>
> -----------------------------------------------------------------------------------------------------------------
> OUTPUT
> $cat1 = Array
> (
> [15] => Array
> (
> [tid] => 15
> [ar_needed] => no
> )
> [16] => Array
> (
> [tid] => 16
> [ar_needed] => no
> )
> [17] => Array
> (
> [tid] => 17
> [ar_needed] => no
> )
> )
>
> $cat1 = Array
> (
> [15] => Array
> (
> [tid] => 15
> [ar_needed] => yes
> )
> [16] => Array
> (
> [tid] => 16
> [ar_needed] => no
> )
> [17] => Array
> (
> [tid] => 17
> [ar_needed] => no
> )
> )
>
> $k = 15
> $v = Array
> (
> [tid] => 15
> [ar_needed] => yes
> )
>
> $k = 16
> $v = Array
> (
> [tid] => 16
> [ar_needed] => no
> )
>
> $k = 17
> $v = Array
> (
> [tid] => 16
> [ar_needed] => no
> )
> -----------------------------------------------------------------------------------------------------------------
>
> As seen in the above output all the print statements give expected
> output except the last
> set in the 2nd iteration
> $k = 17
> $v = Array
> (
> [tid] => 16
> [ar_needed] => no
> )
>
> the $k looks fine but the $v is not correct for some reason. Any clue
> what could be wrong
> here ?. Also, in the 2nd iteration of the name of the variable is
> changed from $v to $v1
> it displays correctly
> $k = 17
> $v1 = Array
> (
> [tid] => 17
> [ar_needed] => no
> )
After the first loop, $v is still a reference to $cat1[17]. Each time
around the last loop, assigning again to $v will overwrite $cat1[17].
--- End Message ---
--- Begin Message ---
Hi,
I want to introduce you to a new phone service that I'm using. It's called
VoIPTelCo and it transforms your high speed Internet connection into a regular
phone line. It works just like your current telephone service except it's 40% -
60% cheaper. You get features like Call Waiting, Caller ID Display, Voicemail,
3-Way calling, Call Forwarding and many more for a fraction of what you're
paying now. You can even keep your existing number if you decide to switch to
their service.
With VoIPTelCo, I also save money on long distance calling. Unlike a regular
phone line, VoIPTelCo is "portable", which means I can get phone service
anywhere in the world. All I need is high speed Internet access. For example, I
use my VoIPTelCo service when I travel and there are no long distance fees
because these calls are considered "local". I save so much money just on this
alone.
Right now, VoIPTelCo is offering a ONE MONTH FREE trial period to friends and
families of their customers. There is no obligation and it is completely free.
If you'd like to try them out, just click on the link below and you will
receive a 30 days trial period, free of charge:
http://www.voiptelco.net
Hope you'll find this useful.
--- End Message ---