php-general Digest 27 Oct 2008 12:03:30 -0000 Issue 5758
Topics (messages 282460 through 282485):
Re: clear a mysql table
282460 by: Bastien Koert
question about using sql server with php
282461 by: Sudhakar
282462 by: Chris
Dynamically creating multi-array field
282463 by: Martin Zvarík
282464 by: Jim Lucas
282465 by: Martin Zvarík
282466 by: Martin Zvarík
282467 by: Jim Lucas
282468 by: Jim Lucas
282469 by: Robert Cummings
282470 by: Robert Cummings
282475 by: Martin Zvarík
282479 by: Lars Torben Wilson
282480 by: Martin Zvarík
282481 by: Lars Torben Wilson
282485 by: tedd
create/write to psd file
282471 by: vuthecuong
282472 by: Ashley Sheridan
282473 by: vuthecuong
282474 by: Ashley Sheridan
282476 by: vuthecuong
282477 by: Martin Zvarík
282478 by: Ashley Sheridan
Re: Interactive canvas example
282482 by: Richard Heyes
Executing a .jar from a php script
282483 by: Bastien Helders
Re: Flags package for PHP?
282484 by: Waynn Lue
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 ---
>
>
> truncate cash;
>
Hey, my wife does that all the time!
--
Bastien
Cat, the other other white meat
--- End Message ---
--- Begin Message ---
i have a question about how to use sql database with php instead of using my
sql database
when i use my sql database the php code to connect to the my sql database is
=
$conn = mysql_connect($hostname, $user, $password);
if(!$conn)
{
echo "Unable to connect to Database";
}
else
{
mysql_select_db($database, $conn);
$query = mysql_query($selectquery);
mysql_close($conn);
}
if i have to connect to a sql databse instead of my sql database as some
companies use sql database, how can i change the php code to connect, run a
query and close connection to the sql database.
apart from changing the code to connect to sql database is there something
else i need to do.
please advice.
thanks
--- End Message ---
--- Begin Message ---
if i have to connect to a sql databse instead of my sql database as some
companies use sql database, how can i change the php code to connect, run a
query and close connection to the sql database.
apart from changing the code to connect to sql database is there something
else i need to do.
RTFM?
http://www.php.net/mssql
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
PHP Version 5.2.4
<?
$node = '[5][1][]';
${'tpl'.$node} = 'some text';
print_r($tpl); // null
?>
I really don't like to use the EVAL function, but do I have choice??
This sucks.
--- End Message ---
--- Begin Message ---
Martin Zvarík wrote:
PHP Version 5.2.4
<?
$node = '[5][1][]';
${'tpl'.$node} = 'some text';
print_r($tpl); // null
?>
I really don't like to use the EVAL function, but do I have choice??
This sucks.
You should print the results that you are looking for!
Are you looking for something like this?
Array
(
[5] => Array
(
[1] => Array
(
[0] => some text
)
)
)
how is the $node string being created?
--- End Message ---
--- Begin Message ---
No offense, but I thought it's obvious what I want to print.
print_r() shows null, and it should print what you just wrote = array field.
It works when first defining with eval():
eval('$tpl'.$node.'=array();');
I guess that's the only way.
Anyway, I appreciate your quick reply,
Martin
Jim Lucas napsal(a):
Martin Zvarík wrote:
PHP Version 5.2.4
<?
$node = '[5][1][]';
${'tpl'.$node} = 'some text';
print_r($tpl); // null
?>
I really don't like to use the EVAL function, but do I have choice??
This sucks.
You should print the results that you are looking for!
Are you looking for something like this?
Array
(
[5] => Array
(
[1] => Array
(
[0] => some text
)
)
)
how is the $node string being created?
--- End Message ---
--- Begin Message ---
Nope, you have to use the eval() everytime for read/write.
Martin Zvarík napsal(a):
No offense, but I thought it's obvious what I want to print.
print_r() shows null, and it should print what you just wrote = array
field.
It works when first defining with eval():
eval('$tpl'.$node.'=array();');
I guess that's the only way.
Anyway, I appreciate your quick reply,
Martin
Jim Lucas napsal(a):
Martin Zvarík wrote:
PHP Version 5.2.4
<?
$node = '[5][1][]';
${'tpl'.$node} = 'some text';
print_r($tpl); // null
?>
I really don't like to use the EVAL function, but do I have choice??
This sucks.
You should print the results that you are looking for!
Are you looking for something like this?
Array
(
[5] => Array
(
[1] => Array
(
[0] => some text
)
)
)
how is the $node string being created?
--- End Message ---
--- Begin Message ---
Martin Zvarík wrote:
Nope, you have to use the eval() everytime for read/write.
Wrong. Their is always more then one way to skin a cat!
<?php
$node = '[5][1][]';
$text = 'some text';
preg_match_all('|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER);
$recursive = $matches[1];
$recursive = array_reverse($recursive);
$index = array_shift($recursive);
$in = array((int)$index => $text);
$out = array();
foreach ( $recursive AS $index ) {
$out = array();
$out[(int)$index] = $in;
$in = $out;
}
print_r($out);
?>
--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
Martin Zvarík wrote:
Nope, you have to use the eval() everytime for read/write.
Wrong. Their is always more then one way to skin a cat!
<?php
$node = '[5][1][]';
$text = 'some text';
preg_match_all('|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER);
$recursive = $matches[1];
$recursive = array_reverse($recursive);
$index = array_shift($recursive);
$in = array((int)$index => $text);
$out = array();
foreach ( $recursive AS $index ) {
$out = array();
$out[(int)$index] = $in;
$in = $out;
}
print_r($out);
?>
Even slimmer
<?php
$node = '[5][1][]';
$text = 'some text';
preg_match_all('|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER);
$recursive = $matches[1];
$recursive = array_reverse($recursive);
foreach ( $recursive AS $index ) {
$out = array();
$out[(int)$index] = $text;
$text = $out;
}
print_r($out);
?>
--- End Message ---
--- Begin Message ---
On Sun, 2008-10-26 at 22:39 -0700, Jim Lucas wrote:
>
> Even slimmer
>
> <?php
>
> $node = '[5][1][]';
> $text = 'some text';
>
> preg_match_all('|\[([^\]\[]*)\]|', $node, $matches,
> PREG_PATTERN_ORDER);
>
> $recursive = $matches[1];
>
> $recursive = array_reverse($recursive);
>
> foreach ( $recursive AS $index ) {
>
> $out = array();
>
> $out[(int)$index] = $text;
>
> $text = $out;
>
> }
>
> print_r($out);
> ?>
It's buggy... you need to test for an blank string to properly handle
the append to array case when the index is blank [].
<?php
$node = '[5][1][]';
$text = 'some text';
preg_match_all(
'|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER );
$recursive = $matches[1];
$recursive = array_reverse($recursive);
foreach( $recursive AS $index )
{
$out = array();
if( trim( $index ) === '' )
{
$out[] = $text;
}
else
{
$out[$index] = $text;
}
$text = $out;
}
print_r( $out );
?>
I also removed the (int) cast since integer keys will be cast
automatically by PHP and then it will have support for text keys also.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
On Mon, 2008-10-27 at 02:09 -0400, Robert Cummings wrote:
> On Sun, 2008-10-26 at 22:39 -0700, Jim Lucas wrote:
> >
> > Even slimmer
> >
> > <?php
> >
> > $node = '[5][1][]';
> > $text = 'some text';
> >
> > preg_match_all('|\[([^\]\[]*)\]|', $node, $matches,
> > PREG_PATTERN_ORDER);
> >
> > $recursive = $matches[1];
> >
> > $recursive = array_reverse($recursive);
> >
> > foreach ( $recursive AS $index ) {
> >
> > $out = array();
> >
> > $out[(int)$index] = $text;
> >
> > $text = $out;
> >
> > }
> >
> > print_r($out);
> > ?>
>
> It's buggy... you need to test for an blank string to properly handle
> the append to array case when the index is blank [].
>
> <?php
>
> $node = '[5][1][]';
> $text = 'some text';
>
> preg_match_all(
> '|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER );
>
> $recursive = $matches[1];
> $recursive = array_reverse($recursive);
>
> foreach( $recursive AS $index )
> {
> $out = array();
>
> if( trim( $index ) === '' )
I probably shouldn't trim... since we're not supporting quotes in any
way, it might be desirable to have a key that is one or more spaces...
for whatever reason :)
Personally, I have a similar implementation I use all the time, but I
use forward slashes to separate keys.
<?php
hashPathSet( $hash, 'this/is/the/hash/path', $value )
?>
Cheers,
Rob.
> {
> $out[] = $text;
> }
> else
> {
> $out[$index] = $text;
> }
>
> $text = $out;
> }
>
> print_r( $out );
>
> ?>
>
> I also removed the (int) cast since integer keys will be cast
> automatically by PHP and then it will have support for text keys also.
>
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
:-D :-D :-D :-D :-D :-D :-D :-D
ok :)
Robert Cummings napsal(a):
On Mon, 2008-10-27 at 02:09 -0400, Robert Cummings wrote:
On Sun, 2008-10-26 at 22:39 -0700, Jim Lucas wrote:
Even slimmer
<?php
$node = '[5][1][]';
$text = 'some text';
preg_match_all('|\[([^\]\[]*)\]|', $node, $matches,
PREG_PATTERN_ORDER);
$recursive = $matches[1];
$recursive = array_reverse($recursive);
foreach ( $recursive AS $index ) {
$out = array();
$out[(int)$index] = $text;
$text = $out;
}
print_r($out);
?>
It's buggy... you need to test for an blank string to properly handle
the append to array case when the index is blank [].
<?php
$node = '[5][1][]';
$text = 'some text';
preg_match_all(
'|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER );
$recursive = $matches[1];
$recursive = array_reverse($recursive);
foreach( $recursive AS $index )
{
$out = array();
if( trim( $index ) === '' )
I probably shouldn't trim... since we're not supporting quotes in any
way, it might be desirable to have a key that is one or more spaces...
for whatever reason :)
Personally, I have a similar implementation I use all the time, but I
use forward slashes to separate keys.
<?php
hashPathSet( $hash, 'this/is/the/hash/path', $value )
?>
Cheers,
Rob.
{
$out[] = $text;
}
else
{
$out[$index] = $text;
}
$text = $out;
}
print_r( $out );
?>
I also removed the (int) cast since integer keys will be cast
automatically by PHP and then it will have support for text keys also.
--- End Message ---
--- Begin Message ---
2008/10/26 Martin Zvarík <[EMAIL PROTECTED]>:
> PHP Version 5.2.4
>
> <?
> $node = '[5][1][]';
> ${'tpl'.$node} = 'some text';
>
> print_r($tpl); // null
> ?>
>
>
> I really don't like to use the EVAL function, but do I have choice??
> This sucks.
Hi there,
While this question can spur some neat solutions, it raises a red flag
in that if you need to do this, you probably need to rethink things a
bit.
In cases like this it is easier for people to help if you describe the
actual problem you are trying to solve, not how you think it needs to
be solved. It could be that you don't really need weird (but
beautiful, like Jim's idea) solutions. If you explain why you believe
that you need to do this in the first place, maybe someone can suggest
something else which doesn't require a weird solution (however
beautiful).
Torben
--- End Message ---
--- Begin Message ---
2008/10/26 Martin Zvarík <[EMAIL PROTECTED]>:
PHP Version 5.2.4
<?
$node = '[5][1][]';
${'tpl'.$node} = 'some text';
print_r($tpl); // null
?>
I really don't like to use the EVAL function, but do I have choice??
This sucks.
Hi there,
While this question can spur some neat solutions, it raises a red flag
in that if you need to do this, you probably need to rethink things a
bit.
In cases like this it is easier for people to help if you describe the
actual problem you are trying to solve, not how you think it needs to
be solved. It could be that you don't really need weird (but
beautiful, like Jim's idea) solutions. If you explain why you believe
that you need to do this in the first place, maybe someone can suggest
something else which doesn't require a weird solution (however
beautiful).
Torben
Hi, I am aware of this, but explaining my problem in this case would
take me an hour --- and eventually would lead to a) misunderstanding, b)
weird solution, c) no solution...
--- End Message ---
--- Begin Message ---
2008/10/27 Martin Zvarík <[EMAIL PROTECTED]>:
>
> Hi, I am aware of this, but explaining my problem in this case would take me
> an hour --- and eventually would lead to a) misunderstanding, b) weird
> solution, c) no solution...
Forgive me if I misunderstand, but it seems like you are willing to
trade off an hour at the beginning of the project at the expense of
perhaps many hours of pain later on. Has this thread not already taken
more than an hour?
I find that often if I have a weird question, just taking the time to
formulate and write a good descriptive post to explain the problem
helps me understand why I'm going at it the wrong way to start with.
I remember years ago being faced with the same problem you now have.
It turned out that the most elegant solution was to change the design
so that I didn't need to solve the problem at all.
Torben
--- End Message ---
--- Begin Message ---
At 12:33 AM -0700 10/27/08, Lars Torben Wilson wrote:
2008/10/27 Martin Zvarík <[EMAIL PROTECTED]>:
Hi, I am aware of this, but explaining my problem in this case would take me
an hour --- and eventually would lead to a) misunderstanding, b) weird
solution, c) no solution...
Forgive me if I misunderstand, but it seems like you are willing to
trade off an hour at the beginning of the project at the expense of
perhaps many hours of pain later on. Has this thread not already taken
more than an hour?
I find that often if I have a weird question, just taking the time to
formulate and write a good descriptive post to explain the problem
helps me understand why I'm going at it the wrong way to start with.
I remember years ago being faced with the same problem you now have.
It turned out that the most elegant solution was to change the design
so that I didn't need to solve the problem at all.
Torben
I agree with Torben.
Quite often when I formulate a question for this
group, the answer appears before I send the
question. One needs to fully understand the
problem themselves and preparing the right
question helps in finding a solution.
Of course, you can do like so many others do and
just don't worry about it -- expose your
ignorance to the group and hope for some magical
code. Despite my own advice, I've done that
several times. That works too, but has it's
downside.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Hi all
Is there a way to create/read/write to psd file? (photoshop format)
I would like to hear opinion form you:
Do you recommend gd2 or imageMagick to perform this task? and why
thanks in advanced
--
View this message in context:
http://www.nabble.com/create-write-to-psd-file-tp20182477p20182477.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
On Sun, 2008-10-26 at 23:34 -0700, vuthecuong wrote:
> Hi all
> Is there a way to create/read/write to psd file? (photoshop format)
>
> I would like to hear opinion form you:
> Do you recommend gd2 or imageMagick to perform this task? and why
> thanks in advanced
> --
> View this message in context:
> http://www.nabble.com/create-write-to-psd-file-tp20182477p20182477.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
Off the top of my head, I don't think this is possible. A quick Google
yields nothing either. I'm assuming it has to be a PSD for the layers?
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Ashley Sheridan-3 wrote:
>
> Off the top of my head, I don't think this is possible. A quick Google
> yields nothing either. I'm assuming it has to be a PSD for the layers?
>
Sure. I woudd like to read PSd files with multiple layes, and of course when
I write to it,
I should keep it's layers state also.
Is there any point to resource in some where please?
please help me. I need your help.
Thanks in advanced.
--
View this message in context:
http://www.nabble.com/create-write-to-psd-file-tp20182477p20182544.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
On Sun, 2008-10-26 at 23:45 -0700, vuthecuong wrote:
>
>
> Ashley Sheridan-3 wrote:
> >
> > Off the top of my head, I don't think this is possible. A quick Google
> > yields nothing either. I'm assuming it has to be a PSD for the layers?
> >
> Sure. I woudd like to read PSd files with multiple layes, and of course when
> I write to it,
> I should keep it's layers state also.
> Is there any point to resource in some where please?
> please help me. I need your help.
> Thanks in advanced.
>
> --
> View this message in context:
> http://www.nabble.com/create-write-to-psd-file-tp20182477p20182544.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
You want me to point you in the direction of a resource, even though
I've said I couldn't find one...?
The closest I can find is a class which will read a PSD in, although I'm
betting it'll only be a very, very old PSD.
It might be possible to do what you need by using the Gimp, but I'm just
not sure how much is possible with it over the command line.
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Ashley Sheridan-3 wrote:
>
> On Sun, 2008-10-26 at 23:45 -0700, vuthecuong wrote:
>>
>>
>> Ashley Sheridan-3 wrote:
>> >
>> > Off the top of my head, I don't think this is possible. A quick Google
>> > yields nothing either. I'm assuming it has to be a PSD for the layers?
>> >
>> Sure. I woudd like to read PSd files with multiple layes, and of course
>> when
>> I write to it,
>> I should keep it's layers state also.
>> Is there any point to resource in some where please?
>> please help me. I need your help.
>> Thanks in advanced.
>>
>> --
>> View this message in context:
>> http://www.nabble.com/create-write-to-psd-file-tp20182477p20182544.html
>> Sent from the PHP - General mailing list archive at Nabble.com.
>>
>>
> You want me to point you in the direction of a resource, even though
> I've said I couldn't find one...?
>
> The closest I can find is a class which will read a PSD in, although I'm
> betting it'll only be a very, very old PSD.
>
> It might be possible to do what you need by using the Gimp, but I'm just
> not sure how much is possible with it over the command line.
>
>
> Ash
> www.ashleysheridan.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
Thank you for useful info.
Anyway I will check it out.
regards,
--
View this message in context:
http://www.nabble.com/create-write-to-psd-file-tp20182477p20182592.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
What I know is that you can control GIMP over the command line = you can
use PHP to do this.
Though I guess GIMP doesn't support PSD files, I had to express myself
anyways.
vuthecuong napsal(a):
Hi all
Is there a way to create/read/write to psd file? (photoshop format)
I would like to hear opinion form you:
Do you recommend gd2 or imageMagick to perform this task? and why
thanks in advanced
--- End Message ---
--- Begin Message ---
On Mon, 2008-10-27 at 07:55 +0100, Martin Zvarík wrote:
> What I know is that you can control GIMP over the command line = you can
> use PHP to do this.
>
> Though I guess GIMP doesn't support PSD files, I had to express myself
> anyways.
>
>
> vuthecuong napsal(a):
> > Hi all
> > Is there a way to create/read/write to psd file? (photoshop format)
> >
> > I would like to hear opinion form you:
> > Do you recommend gd2 or imageMagick to perform this task? and why
> > thanks in advanced
>
The Gimp does support PSD files, but it has real trouble with the layer
effects that CS introduced. Also, the Gimp cannot natively handle CMYK
images.
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
> great job, i can see uses for this in lots of applications
Thanks. I'm hoping the bandwidth and load saving will be quite an incentive.
--
Richard Heyes
HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated October 25th)
--- End Message ---
--- Begin Message ---
Hi,
I would like to execute a jar file using exec('java -jar JARNAME <option>'),
but so far, my web application didn't gave me any hint that it did anything
(I tried to echo the result of the function, but nothing), and in fact I
don't think anything was done.
The jar file is in the same folder as the php scripts, so I don't know what
I did wrong.
Best Regards,
Bastien
--
haXe - an open source web programming language
http://haxe.org
--- End Message ---
--- Begin Message ---
Thanks for the advice! I had initially tried it and couldn't seem to get
getopt2 working (and getopt was supposedly deprecated), but eventually found
a good example here: http://www.sitepoint.com/article/php-command-line-1/3/
On Thu, Oct 16, 2008 at 10:31 AM, Jim Lucas <[EMAIL PROTECTED]> wrote:
> Waynn Lue wrote:
> > I'm running some command-line scripts that are taking more and more
> > arguments, and I'm wondering whether anyone's used a good flags package
> for
> > PHP? Support for string/int/boolean arguments would be nice, otherwise
> I'll
> > just hack together my own.
> >
> > Thanks for any advice,
> > Waynn
> >
>
> I would maybe look into using a standard ini file and then use the
> parse_ini_file [1] function to bring it all together again.
>
> 1 - http://us2.php.net/manual/en/function.parse-ini-file.php
>
> --
> 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 ---