php-general Digest 2 Nov 2007 05:52:15 -0000 Issue 5105
Topics (messages 263937 through 263956):
Re: Function variables in classes
263937 by: Robert Cummings
Re: Help with OOPHP (SOLVED)
263938 by: Andrew Peterson
Re: Transfer query result to another script
263939 by: David Giragosian
263942 by: Jim Lucas
Re: Perl style chomp()
263940 by: mike
263941 by: Jim Lucas
Re: PHP Won't Access Files Outside Web Root (Leopard/MacOS X 10.5)
263943 by: Rahul Sitaram Johari
263953 by: Jim Lucas
Threads
263944 by: Stéphane Boisvert
263946 by: Stut
263951 by: Instruct ICC
263956 by: Jochem Maas
Re: Foreign Key Problem
263945 by: mlists
Generating HTML table from MySQL table based on some criteria
263947 by: Sudheer Satyanarayana
263948 by: Jay Blanchard
263949 by: Wolf
263950 by: Jim Lucas
Including GD inside HTML code
263952 by: Alberto García Gómez
263954 by: Jim Lucas
263955 by: Instruct ICC
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 Thu, 2007-11-01 at 17:16 +0100, Jochem Maas wrote:
> Robert Cummings wrote:
> > On Thu, 2007-11-01 at 16:10 +0100, Jochem Maas wrote:
> >> I've completely lost track of the state of the exact OO rules in any
> >> given version of php5)
> >
> > Haha, you too eh!?
> >
> > BTW, I finally bothered to download PHP 5.2.4 last night and checked it
> > out. This is the first time I've seen a speed improvement over PHP4 for
> > my work. Most of my pages gained a 10% to 20% load time improvement. One
> > thing that was odd though was when I built a few sites from the shell
> > using InterJinn's template engine, the time spent doubled. So I guess I
> > win some and lose some :) Page load time is more important since I don't
> > often build whole sites from scratch. Still perplexing though what could
> > have slowed down so much... I'll have to dig into it with a profiler
> > sometime when I have more free time.
>
> interesting info - thanks for the heads up.
Yeah, I'm going to make it my default development version now :)
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................
--- End Message ---
--- Begin Message ---
I've figured it out :)
Thanks for the help, I just need to walk away for a minute and come
back to it.
all I need to do is this:
myClass.php
----------------------
<?PHP
require mySecondClass.php;
class myClass
{
/*
Now I can create/edit/maninpulate/etc new and old instances of
"mySecondClass"
*/
}
?>
mySecondClass.php
-------------------
<?PHP
mySecondClass
{
//constuct, functions, etc....
}
?>
On Nov 1, 2007, at 7:35 AM, Sebastian Hopfe wrote:
Dear Andrew,
I think normaly it isn't possible to use another class in a class,
without using extends. But you should use your array as a
container. After you use as a container, you can make new instance
into a array field.
Now you can use the content of the container to administrate the
instances of the complete class. I just changed some things at your
example. Please have a look and ask if you have any questions.
<?php
class fruitBasket ext
{
private $fruits = array(); //this is a class Container
public function addFruit($newFruit)
{
$this->fruits[] = new fruit($newFruit);
}
public function makeAllApples()
{
foreach($this->fruits AS $fruit)
{
$fruit->changeName("apple");
}
}
public function showAllFruits()
{
foreach($this->fruits AS $fruit)
{
echo $fruit->showFruit()."<br>";
}
}
}
class fruit
{
private $name;
public function __construct($name)
{
$this->name = $name;
}
public function changeName($newName)
{
$this->name = $newName;
}
public function showFruit()
{
return $this->name;
}
}
$Cls = new fruitBasket();
$Cls->addFruit("test1");
$Cls->addFruit("test2");
$Cls->addFruit("test3");
$Cls->addFruit("test4");
$Cls->addFruit("test5");
$Cls->addFruit("test6");
$Cls->makeAllApples();
$Cls->showAllFruits();
?>
"Andrew Peterson" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
I'm hoping you guys can help me out.
I'm not sure if you can do this, but i'm trying to create a class
that is build of another class. I also want to be able to do
functions on the class1 from within class2.
example:
class fruitBasket{
private $fuit = array(); //this is a class
public function addFruit($newFruit)
{
$this->fruitBasket[] = $newFruit();
}
public makeAllApples()
{
foreach($this->fruit AS $value)
{ $value->changeName("apple");
} }
}
class fruit{
private $name;
public __construct($name)
{
$this->name = $name;
}
public changeName($newName)
{
$this->name = $newName;
}
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On 11/1/07, C.R.Vegelin <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> Q: Is it possible to transfer a query result to another script ?
> For example with (fragments of) the following 2 scripts:
>
> Engine.php
> ----------------
> $result = mysqli_query($connect, $myquery);
> if (!$result) error ...
> if (mysqli_num_rows($result) == 0) error ...
> $_SESSION['result'] = $result;
> header("Location: Report.php");
>
> Report.php
> ----------------
> $result = $_SESSION['result'];
> while ($row = mysqli_fetch_array($result)) ...
>
> This last line gives "Couldn't fetch mysqli_result".
> Is this because the result set is local to Engine.php ?
>
> TIA, Cor
Cor,
Do you have session_start() at the top of Report.php?
The manual shows an example of passing a php created class object using a
session variable, with the caveat of needing to include the class definition
on each page.
It may be different for a mysql result object though.
Why do you need the query on a different page than the result?
David
--- End Message ---
--- Begin Message ---
C.R.Vegelin wrote:
Hi All,
Q: Is it possible to transfer a query result to another script ?
For example with (fragments of) the following 2 scripts:
Engine.php
----------------
$result = mysqli_query($connect, $myquery);
if (!$result) error ...
if (mysqli_num_rows($result) == 0) error ...
$_SESSION['result'] = $result;
header("Location: Report.php");
Report.php
----------------
$result = $_SESSION['result'];
while ($row = mysqli_fetch_array($result)) ...
This last line gives "Couldn't fetch mysqli_result".
Is this because the result set is local to Engine.php ?
TIA, Cor
You cannot transfer the Result ID itself, but you could loop through the results, create an array or
object with all the returned data. Then store that in the $_SESSION['results'] variable in the
first page. Then pull the data out of the $_SESSION array on the second page.
But, the result id / mysql result handler is only available within the lifetime
of the current script.
When the script ends, the all resource handlers get removed!
The only thing that my help, is if you use persistent connections in mysql
using mysql_pconnect()
--
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 11/1/07, Jim Lucas <[EMAIL PROTECTED]> wrote:
> I noticed, while perusing the chop() manual page, that some people were
> giving examples of Perl's
> chop() and chomp() functions. Comments made about both said the examples
> were good, but not correct.
what about trim(), rtrim() and ltrim() ? seems unnecessary to reinvent
the wheel. if you want an array one, just make it recurse like you
did.
- mike
--- End Message ---
--- Begin Message ---
mike wrote:
On 11/1/07, Jim Lucas <[EMAIL PROTECTED]> wrote:
I noticed, while perusing the chop() manual page, that some people were giving
examples of Perl's
chop() and chomp() functions. Comments made about both said the examples were
good, but not correct.
what about trim(), rtrim() and ltrim() ? seems unnecessary to reinvent
the wheel. if you want an array one, just make it recurse like you
did.
- mike
the functions that you mentioned do not do the same thing as what this function
does.
it alters a reference to the variable that you passed it and returns what it
removed.
The above listed functions return the altered string.
Just a little difference. But, if you are comfortable using the Perl's chomp() function, then I
think I created the PHP equivalent.
--
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 11/1/07 12:43 PM, "Daniel Brown" <[EMAIL PROTECTED]> wrote:
> On 11/1/07, Rahul Sitaram Johari <[EMAIL PROTECTED]> wrote:
>
>> Is there a Terminal way of figuring out the UID/GID of something like admin,
>> apache etcetera?
>>
>> PS: I know it's going OT!
>>
>>
>>
>
> Yes, you'll find those UIDs in /etc/passwd. For example:
> apache:x:48:48:Apache:/var/www:/sbin/nologin
>
> That means my Apache server runs with UID 48 and GID 48, with
> /var/www as the home directory and /sbin/nologin as the shell.
Well, chown is not able to change the User/Group for the mounted files at
all. It simply doesn't change anything at all. I guess the only way to
define a User/Group for a share being mounted is "while" mounting the share,
which was a piece of cake in earlier mac's with mount_smbfs -u UID -g GID
... Of course this was eliminated in Leopard - now I don't know what to do !
--- End Message ---
--- Begin Message ---
Rahul Sitaram Johari wrote:
Ave,
Somehow my PHP won't access, won't even acknowledge the existence of a file
that is outside the /Library/WebServer/Documents folder. This was never a a
problem before in any Mac version - it just started with Leopard.
I don't know what has changed where, in httpd.conf or php.ini or somewhere
else, but something changed that's crippling access to files outside of the
webserver.
This Works in Mac OS X 10.3.9 (i.e., prints File Exists) but the same exact
script does not work in Mac OS X 10.5, and yes, the file is available in
Leopard in the mentioned location - path is exact same - permissions are all
set:
$filename = "/Users/username/Documents/Transfers/test.txt";
if (file_exists($filename)) {
echo "The file $filename exists<br><br>";
} else {
echo "The file $filename does not exist<br><br>";
}
I¹ve already checked safe_mode which is Off and open_basedir which is not
set same settings as php.ini from before.
Any ideas what might be causing this?
Thanks!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.
W: http://www.rahulsjohari.com
E: [EMAIL PROTECTED]
³I morti non sono piu soli ... The dead are no longer lonely²
Sounds like a clear case of Apache being chroot'ed.
This is based off the BSD style setup I believe. Which I believe Mac uses, So, I would check your
startup line for Apache. I did some googling, but I could not find anything to confirm my thinking
that the Mac Apache configuration is anything like the default OpenBSD setup.
I know you can manually start httpd with the -u flag to disable chrooting
Again, I can't find any examples of the Mac setup, but my money would be on
chrooting as the problem.
--
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 ---
Greetings everyone, I was wondering where I could find information on the
status and possibilities of threads being included in PHP. Or if you are
knowledge-able on the status of threads, if it is a planned addition or not
and the reasons as such. I understand PHP is not thread safe, that the core
is thread safe but many required extensions are not. Is there a road map to
this?
Thank you very much for your time.
-Steph
--- End Message ---
--- Begin Message ---
Stéphane Boisvert wrote:
Greetings everyone, I was wondering where I could find information on the
status and possibilities of threads being included in PHP. Or if you are
knowledge-able on the status of threads, if it is a planned addition or not
and the reasons as such. I understand PHP is not thread safe, that the core
is thread safe but many required extensions are not. Is there a road map to
this?
Being thread safe and being able to use threads are two different things.
PHP 5 *is* thread safe, but a great many extensions are not.
PHP is never likely to support threads. Remember that the majority of
PHP usage is in the context of web requests. There are a great many
issues the crop up when you consider adding threading to an Apache
module, and I'm sure the same is true of most of the other SAPIs.
Hope that helps.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
>> Greetings everyone, I was wondering where I could find information on the
>> status and possibilities of threads being included in PHP. Or if you are
>> knowledge-able on the status of threads, if it is a planned addition or not
>> and the reasons as such. I understand PHP is not thread safe, that the core
>> is thread safe but many required extensions are not. Is there a road map to
>> this?
>
> Being thread safe and being able to use threads are two different things.
>
> PHP 5 *is* thread safe, but a great many extensions are not.
>
> PHP is never likely to support threads. Remember that the majority of
> PHP usage is in the context of web requests. There are a great many
> issues the crop up when you consider adding threading to an Apache
> module, and I'm sure the same is true of most of the other SAPIs.
>
> Hope that helps.
Hmm. I was looking into proc_open and pcntl_fork as a way to have a "Manager
application" handle "Worker applications" (or worker threads -- so to speak).
Actually as a quick way to develop in PHP instead of C++. Some of the worker
processes are actually C++ and some are PHP.
Can anyone expound on these alternatives to threads? I'm assuming that neither
"blocks" execution of the spawned process. Is it merely the difference between
processes and threads whereas threads have less overhead? This is for a
command line PHP-GTK app (the Manager Application) and I'm not too concerned
about running out of resources.
I noticed the proc_* methods allow for getting the status and maybe the manager
will kill off some workers if they do not behave as desired.
_________________________________________________________________
Help yourself to FREE treats served up daily at the Messenger Café. Stop by
today.
http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline
--- End Message ---
--- Begin Message ---
Instruct ICC wrote:
>>> Greetings everyone, I was wondering where I could find information on the
>>> status and possibilities of threads being included in PHP. Or if you are
>>> knowledge-able on the status of threads, if it is a planned addition or not
>>> and the reasons as such. I understand PHP is not thread safe, that the core
>>> is thread safe but many required extensions are not. Is there a road map to
>>> this?
>> Being thread safe and being able to use threads are two different things.
>>
>> PHP 5 *is* thread safe, but a great many extensions are not.
>>
>> PHP is never likely to support threads. Remember that the majority of
>> PHP usage is in the context of web requests. There are a great many
>> issues the crop up when you consider adding threading to an Apache
>> module, and I'm sure the same is true of most of the other SAPIs.
>>
>> Hope that helps.
>
> Hmm. I was looking into proc_open and pcntl_fork as a way to have a "Manager
> application" handle "Worker applications" (or worker threads -- so to speak).
>
> Actually as a quick way to develop in PHP instead of C++. Some of the worker
> processes are actually C++ and some are PHP.
>
> Can anyone expound on these alternatives to threads? I'm assuming that
> neither "blocks" execution of the spawned process. Is it merely the
> difference between processes and threads whereas threads have less overhead?
> This is for a command line PHP-GTK app (the Manager Application) and I'm not
> too concerned about running out of resources.
>
> I noticed the proc_* methods allow for getting the status and maybe the
> manager will kill off some workers if they do not behave as desired.
proc_* will give you complete control over spawned/child processes at the OS
level.
overhead is not the only difference, but for your practical purposes child
process spawning
will cover your bases.
> _________________________________________________________________
> Help yourself to FREE treats served up daily at the Messenger Café. Stop by
> today.
> http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline
--- End Message ---
--- Begin Message ---
On Thu, 2007-11-01 at 09:05 -0700, Kulluji wrote:
> Hi Everybody,
>
> I am working in WAMP server for a small project. I am useing mysqlAdmin to
> create my tables. In this version of Mysql I am unable to set foreign key
> constraint. How do we do that?
>
> Thanks.
>
> Francis David Kullu
> --
> View this message in context:
> http://www.nabble.com/Foreign-Key-Problem-tf4732309.html#a13531727
> Sent from the PHP - General mailing list archive at Nabble.com.
Make sure you are using a MySQL storage engine that supports referential
integrity. MyISAM does not, but Innodb does. If you execute SQL to add
a foreign key to a MyISAM table you will not get an error, but it will
also not add the key (only an index).
--- End Message ---
--- Begin Message ---
Hello,
I have a MySQL table with four columns - userid, created_date, username
and path_to_picture. path_to_picture column contains the path to the
image files of those users who have uploaded pictures. An example path
stored in path_to_picture column is picture/username.png. There are
some users that don't have their pictures uploaded. The column contains
nothing for these usernames.
I want to generate an HTML table with 20 recent users who have uploaded
their pictures. Each row in the HTML table should contain 5 columns.
Thus the HTML table would contain 4 rows.
How can I accomplish this?
I hope I have provided enough information to describe my problem. I
would be glad to provide more details if required.
I tried few permutations and combinations with ORDER BY and LIMIT
clauses to no avail. I have been scratching my head from few hours to
get this to work. Any help would be greatly appreciated.
--
With Warm Regards,
Sudheer. S
http://www.binaryvibes.co.in
--- End Message ---
--- Begin Message ---
[snip]
I have a MySQL table with four columns - userid, created_date, username
and path_to_picture. path_to_picture column contains the path to the
image files of those users who have uploaded pictures. An example path
stored in path_to_picture column is picture/username.png. There are
some users that don't have their pictures uploaded. The column contains
nothing for these usernames.
I want to generate an HTML table with 20 recent users who have uploaded
their pictures. Each row in the HTML table should contain 5 columns.
Thus the HTML table would contain 4 rows.
How can I accomplish this?
I hope I have provided enough information to describe my problem. I
would be glad to provide more details if required.
I tried few permutations and combinations with ORDER BY and LIMIT
clauses to no avail. I have been scratching my head from few hours to
get this to work. Any help would be greatly appreciated.
[/snip]
SELECT * FROM table WHERE path_to_picture IS NOT NULL ORDER BY
created_date LIMIT 20
--
With Warm Regards,
Sudheer. S
http://www.binaryvibes.co.in
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Sudheer,
Post the code you are using and we'll better be able to point you in the right
direction to get your code working.
Wolf
---- Sudheer Satyanarayana <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have a MySQL table with four columns - userid, created_date, username
> and path_to_picture. path_to_picture column contains the path to the
> image files of those users who have uploaded pictures. An example path
> stored in path_to_picture column is picture/username.png. There are
> some users that don't have their pictures uploaded. The column contains
> nothing for these usernames.
>
> I want to generate an HTML table with 20 recent users who have uploaded
> their pictures. Each row in the HTML table should contain 5 columns.
> Thus the HTML table would contain 4 rows.
>
> How can I accomplish this?
>
> I hope I have provided enough information to describe my problem. I
> would be glad to provide more details if required.
>
> I tried few permutations and combinations with ORDER BY and LIMIT
> clauses to no avail. I have been scratching my head from few hours to
> get this to work. Any help would be greatly appreciated.
>
>
>
>
> --
> With Warm Regards,
> Sudheer. S
> http://www.binaryvibes.co.in
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
[snip]
I have a MySQL table with four columns - userid, created_date, username
and path_to_picture. path_to_picture column contains the path to the
image files of those users who have uploaded pictures. An example path
stored in path_to_picture column is picture/username.png. There are
some users that don't have their pictures uploaded. The column contains
nothing for these usernames.
I want to generate an HTML table with 20 recent users who have uploaded
their pictures. Each row in the HTML table should contain 5 columns.
Thus the HTML table would contain 4 rows.
How can I accomplish this?
I hope I have provided enough information to describe my problem. I
would be glad to provide more details if required.
I tried few permutations and combinations with ORDER BY and LIMIT
clauses to no avail. I have been scratching my head from few hours to
get this to work. Any help would be greatly appreciated.
[/snip]
SELECT * FROM table WHERE path_to_picture IS NOT NULL ORDER BY
created_date LIMIT 20
Then to take this to the next step
<?php
...
...
$SQL = 'SELECT * FROM table WHERE path_to_picture IS NOT NULL ORDER BY
created_date LIMIT 20';
$results = mysql_query($SQL);
if ( $results && mysql_num_rows($results) > 0 ) {
echo '<table><tr>';
echo '<th> </th>';
echo '<th>User ID</th>';
echo '<th>Date Created</th>';
echo '<th>Username</th>';
echo '<th>Picture</th></tr>';
$id = 1;
while ( list($userid, $created_date, $username, $path) =
mysql_fetch_array($results) ) {
echo '<tr>';
echo '<td>'.($id++).'</td>';
echo '<td>'.$userid.'</td>';
echo '<td>'.$created_date.'</td>';
echo '<td>'.$username.'</td>';
echo '<td><img src="'.$path.'" /></td>';
echo '</tr>';
}
echo '</table>';
} else {
echo 'No results found';
}
--
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 ---
I trying to include some image generate for a function that use GD.
eg.:
function myfunct(){
[MY_CODE]
}
but when I call the function it generate me a lot of symbols, letters and
numbers but no image.
WHAT CAN I DO?
PS.: I actually usgin a iframe to create the iomage in another .php page and
place it using this tag.
Este correo ha sido enviado desde el Politécnico de Informática "Carlos Marx"
de Matanzas.
"La gran batalla se librará en el campo de las ideas"
--- End Message ---
--- Begin Message ---
Alberto García Gómez wrote:
I trying to include some image generate for a function that use GD.
eg.:
function myfunct(){
[MY_CODE]
}
but when I call the function it generate me a lot of symbols, letters and
numbers but no image.
WHAT CAN I DO?
PS.: I actually usgin a iframe to create the iomage in another .php page and
place it using this tag.
Este correo ha sido enviado desde el Politécnico de Informática "Carlos Marx"
de Matanzas.
"La gran batalla se librará en el campo de las ideas"
Sounds like you are trying to output the actual file content of the image in
the HTML.
You should have a separate script generate the img and link to it with your HTML
<img src="generate_image.php?img=someImage" />
Then in the script generate_image.php you create the image and pass it back at
that point.
--
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 ---
> Alberto García Gómez wrote:
> > I trying to include some image generate for a function that use GD.
> >
> > eg.:
> >
> > function myfunct(){
> > [MY_CODE]
> > }
> >
> > but when I call the function it generate me a lot of symbols, letters and
> > numbers but no image.
> >
> > WHAT CAN I DO?
> >
> > PS.: I actually usgin a iframe to create the iomage in another .php page
> > and place it using this tag.
> >
> > Este correo ha sido enviado desde el Politécnico de Informática "Carlos
> > Marx" de Matanzas.
> > "La gran batalla se librará en el campo de las ideas"
> >
>
> Sounds like you are trying to output the actual file content of the image in
> the HTML.
>
> You should have a separate script generate the img and link to it with your
> HTML
>
> <img src="generate_image.php?img=someImage" />
>
> Then in the script generate_image.php you create the image and pass it back
> at that point.
Depending on what is in your myfunct(), you may also need to set a header to
let the browser know what type of content you are outputting.
_________________________________________________________________
Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare!
http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews
--- End Message ---