php-general Digest 21 Jul 2010 13:05:01 -0000 Issue 6857
Topics (messages 307040 through 307062):
exec output to mySQL, How?
307040 by: Tom Sparks
307050 by: Nilesh Govindarajan
307053 by: Per Jessen
307055 by: Tom Sparks
307056 by: Nilesh Govindarajan
307057 by: Nilesh Govindarajan
307059 by: Ashley Sheridan
307060 by: Per Jessen
php array in different OS
307041 by: fyang
307042 by: fyang
307043 by: fyang
307044 by: fyang
307045 by: fyang
307046 by: fyang
307047 by: fyang
307048 by: fyang
307061 by: Bob McConnell
Re: eval and HEREDOC
307049 by: Sorin Buturugeanu
307051 by: Peter Lind
307054 by: Sorin Buturugeanu
Re: MySQL select matching
307052 by: Simcha Younger
MySQL+PHP
307058 by: Diana Wu
PDO and UPDATE problem
307062 by: Sky Gunning
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
How do I take the output from a command line program and update a MYSQL
database with it?
tom_a_sparks
Light travels faster then sound, which is why some people appear bright, until
you hear them speak
--- End Message ---
--- Begin Message ---
On Wed, Jul 21, 2010 at 8:49 AM, Tom Sparks <tom_a_spa...@yahoo.com.au> wrote:
> How do I take the output from a command line program and update a MYSQL
> database with it?
>
> tom_a_sparks
> Light travels faster then sound, which is why some people appear bright,
> until you hear them speak
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
$cmdop=shell_exec('cmd');
$con=new mysqli(...);
// Check connection error
// Refer to php.net/mysqli
$con->multi_query($cmdop);
--
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
--- End Message ---
--- Begin Message ---
Tom Sparks wrote:
> How do I take the output from a command line program and update a
> MYSQL database with it?
<command line program> | mysql -u user -p -Ddatabase
--
Per Jessen, Zürich (22.6°C)
--- End Message ---
--- Begin Message ---
--- On Wed, 21/7/10, Nilesh Govindarajan <li...@itech7.com> wrote:
> On Wed, Jul 21, 2010 at 8:49 AM, Tom
> Sparks <tom_a_spa...@yahoo.com.au>
> wrote:
> > How do I take the output from a command line program
> and update a MYSQL database with it?
> >
> > tom_a_sparks
> > Light travels faster then sound, which is why some
> people appear bright, until you hear them speak
> >
>
> $cmdop=shell_exec('cmd');
> $con=new mysqli(...);
> // Check connection error
> // Refer to php.net/mysqli
> $con->multi_query($cmdop);
ok, thanks the program I am using reports a estimated time to completion, I
understand I need a loop, but I cant work out how I would do this
run program
while program is running {
sleep 60 seconds
update mySQL with ET from program
}
tom
--- End Message ---
--- Begin Message ---
On Wed, Jul 21, 2010 at 12:29 PM, Per Jessen <p...@computer.org> wrote:
> Tom Sparks wrote:
>
>> How do I take the output from a command line program and update a
>> MYSQL database with it?
>
> <command line program> | mysql -u user -p -Ddatabase
>
>
>
> --
> Per Jessen, Zürich (22.6°C)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I don't think this is what he needs? Otherwise why would he post on a
PHP list lol.
--
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
--- End Message ---
--- Begin Message ---
On Wed, Jul 21, 2010 at 12:39 PM, Tom Sparks <tom_a_spa...@yahoo.com.au> wrote:
> --- On Wed, 21/7/10, Nilesh Govindarajan <li...@itech7.com> wrote:
>> On Wed, Jul 21, 2010 at 8:49 AM, Tom
>> Sparks <tom_a_spa...@yahoo.com.au>
>> wrote:
>> > How do I take the output from a command line program
>> and update a MYSQL database with it?
>> >
>> > tom_a_sparks
>> > Light travels faster then sound, which is why some
>> people appear bright, until you hear them speak
>> >
>>
>> $cmdop=shell_exec('cmd');
>> $con=new mysqli(...);
>> // Check connection error
>> // Refer to php.net/mysqli
>> $con->multi_query($cmdop);
> ok, thanks the program I am using reports a estimated time to completion, I
> understand I need a loop, but I cant work out how I would do this
>
> run program
> while program is running {
> sleep 60 seconds
> update mySQL with ET from program
> }
>
> tom
>
>
>
>
You want to calculate how much time the query takes?
--
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
--- End Message ---
--- Begin Message ---
On Wed, 2010-07-21 at 12:57 +0530, Nilesh Govindarajan wrote:
> On Wed, Jul 21, 2010 at 12:29 PM, Per Jessen <p...@computer.org> wrote:
> > Tom Sparks wrote:
> >
> >> How do I take the output from a command line program and update a
> >> MYSQL database with it?
> >
> > <command line program> | mysql -u user -p -Ddatabase
> >
> >
> >
> > --
> > Per Jessen, Zürich (22.6°C)
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> I don't think this is what he needs? Otherwise why would he post on a
> PHP list lol.
>
> --
> Regards,
> Nilesh Govindarajan
> Facebook: http://www.facebook.com/nilesh.gr
> Twitter: http://twitter.com/nileshgr
> Website: http://www.itech7.com
>
Because many people wouldn't know that Linux can happily deal with this
on the command line, so would assume they would have to use a scripting
language to perform the task.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Nilesh Govindarajan wrote:
> On Wed, Jul 21, 2010 at 12:29 PM, Per Jessen <p...@computer.org> wrote:
>> Tom Sparks wrote:
>>
>>> How do I take the output from a command line program and update a
>>> MYSQL database with it?
>>
>> <command line program> | mysql -u user -p -Ddatabase
>>
>
> I don't think this is what he needs? Otherwise why would he post on a
> PHP list lol.
Who knows, but I answered his question. Besides, he doesn't need PHP to
do mysql updates with output from a command line program.
--
Per Jessen, Zürich (23.3°C)
--- End Message ---
--- Begin Message ---
Dear all,
I have a simple test code in different OS ,but it give me a different
result.
the code as follows:
<?php
$n= 50000;
for($i=0;$i<$n;$i++)
{
$data[]=array("",$i,$i/1000);
echo $i," ",$data[$i][1],"<br>";
}
echo "count:",count($data);
?>
OS1: Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result: the result is correct,it can display 50000 data and
count:50000.
OS2: CentOS release 5.4
Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and it
can not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.
good luck,
Yang Fei
2010-7-20
--- End Message ---
--- Begin Message ---
Dear all,
I have a simple test code in different OS ,but it give me a different
result.
the code as follows:
<?php
$n= 50000;
for($i=0;$i<$n;$i++)
{
$data[]=array("",$i,$i/1000);
echo $i," ",$data[$i][1],"<br>";
}
echo "count:",count($data);
?>
OS1: Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result: the result is correct,it can display 50000 data and
count:50000.
OS2: CentOS release 5.4
Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and it
can not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.
good luck,
Yang Fei
2010-7-20
--- End Message ---
--- Begin Message ---
Dear all,
I have a simple test code in different OS ,but it give me a different
result.
the code as follows:
<?php
$n= 50000;
for($i=0;$i<$n;$i++)
{
$data[]=array("",$i,$i/1000);
echo $i," ",$data[$i][1],"<br>";
}
echo "count:",count($data);
?>
OS1: Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result: the result is correct,it can display 50000 data and
count:50000.
OS2: CentOS release 5.4
Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and it
can not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.
good luck,
Yang Fei
2010-7-20
--- End Message ---
--- Begin Message ---
Dear all,
I have a simple test code in different OS ,but it give me a different
result.
the code as follows:
<?php
$n= 50000;
for($i=0;$i<$n;$i++)
{
$data[]=array("",$i,$i/1000);
echo $i," ",$data[$i][1],"<br>";
}
echo "count:",count($data);
?>
OS1: Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result: the result is correct,it can display 50000 data and
count:50000.
OS2: CentOS release 5.4
Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and it
can not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.
good luck,
Yang Fei
2010-7-20
--- End Message ---
--- Begin Message ---
Dear all,
I have a simple test code in different OS ,but it give me a different
result.
the code as follows:
<?php
$n= 50000;
for($i=0;$i<$n;$i++)
{
$data[]=array("",$i,$i/1000);
echo $i," ",$data[$i][1],"<br>";
}
echo "count:",count($data);
?>
OS1: Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result: the result is correct,it can display 50000 data and
count:50000.
OS2: CentOS release 5.4
Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and it
can not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.
good luck,
Yang Fei
2010-7-20
--- End Message ---
--- Begin Message ---
Dear all,
I have a simple test code in different OS ,but it give me a different
result.
the code as follows:
<?php
$n= 50000;
for($i=0;$i<$n;$i++)
{
$data[]=array("",$i,$i/1000);
echo $i," ",$data[$i][1],"<br>";
}
echo "count:",count($data);
?>
OS1: Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result: the result is correct,it can display 50000 data and
count:50000.
OS2: CentOS release 5.4
Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and it
can not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.
good luck,
Yang Fei
2010-7-20
--- End Message ---
--- Begin Message ---
Dear all,
I have a simple test code in different OS ,but it give me a different
result.
the code as follows:
<?php
$n= 50000;
for($i=0;$i<$n;$i++)
{
$data[]=array("",$i,$i/1000);
echo $i," ",$data[$i][1],"<br>";
}
echo "count:",count($data);
?>
OS1: Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result: the result is correct,it can display 50000 data and
count:50000.
OS2: CentOS release 5.4
Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and it
can not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.
good luck,
Yang Fei
2010-7-20
--- End Message ---
--- Begin Message ---
Dear all,
I have a simple test code in different OS ,but it give me a different
result.
the code as follows:
<?php
$n= 50000;
for($i=0;$i<$n;$i++)
{
$data[]=array("",$i,$i/1000);
echo $i," ",$data[$i][1],"<br>";
}
echo "count:",count($data);
?>
OS1: Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result: the result is correct,it can display 50000 data and
count:50000.
OS2: CentOS release 5.4
Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and it can
not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.
good luck,
Yang Fei
2010-7-20
--- End Message ---
--- Begin Message ---
From: fyang
> I have a simple test code in different OS ,but it give me a
different
> result.
> the code as follows:
> <?php
> $n= 50000;
> for($i=0;$i<$n;$i++)
> {
> $data[]=array("",$i,$i/1000);
> echo $i," ",$data[$i][1],"<br>";
> }
> echo "count:",count($data);
> ?>
> OS1: Red Hat Enterprise Linux Server release 5.1
> Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
> test result: the result is correct,it can display 50000 data and
> count:50000.
>
> OS2: CentOS release 5.4
> Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
> test result: the result is wrong,it can only display 31148 data and
it
> can not display count value.
> I'm not sure the result relate to array capacity in different OS.
> Please give me some tips,thanks in advance.
Did you really have to post the same message eight times?
CentOS is Red Hat minus the proprietary elements, so you actually have
two releases of the same OS here. The bigger question is what version of
PHP are you running on each of them and how are they configured?
Bob McConnell
--- End Message ---
--- Begin Message ---
@Vincent: no, the short tags are not off.
@Jim: This seamns to work fine:
$template = file_get_contents(pathTemplates.$this->dir.$this->tpl);
ob_start();
$template = eval('?>'.$template);
$template = ob_get_clean();
Thanks!
Best wishes!
Sorin
--
Sorin Buturugeanu
http://www.soin.ro
On Wed, Jul 21, 2010 at 1:45 AM, <li...@cmsws.com> wrote:
>
>
>
> On Wed, 21 Jul 2010 01:04:12 +0300, Sorin Buturugeanu <m...@soin.ro> wrote:
>> Hello Vincent and thank you for your reply :).
>>
>> That's true, I forgot to explain how I got to using HEREDOC, so ..
>>
>> Using eval(file_get_contents($file)) just outputs the result on the
>> spot and I need
>> to get the whole output (without echoing it) and do some more things with
>> it.
>>
>> require_once() doesn't fit here (from what I can tell), because it
>> would still just
>> include the file in echo the output.
>>
>> I think there must be a solution, but I'm missing something here ..
>
>
> Check out the ob_* functions
>
> You could do this
>
> ob_start();
>
> include "/your/file.php";
>
> $output = ob_get_clean();
>
> echo $output;
>
> Jim
>
>>
>> Thanks again!
>>
>> --
>> Sorin Buturugeanu
>> http://www.soin.ro
>>
>>
>> On Wed, Jul 21, 2010 at 12:49 AM, Daevid Vincent <dae...@daevid.com>
>> wrote:
>>>
>>> > -----Original Message-----
>>> > From: Sorin Buturugeanu [mailto:m...@soin.ro]
>>> > Sent: Tuesday, July 20, 2010 2:11 PM
>>> > To: php-gene...@lists.php.net
>>> > Subject: [PHP] eval and HEREDOC
>>> >
>>> > Hello,
>>> >
>>> > I am having trouble with a part of my templating script. I'll
>>> > try to explain:
>>> >
>>> > The template itself is HTML with PHP code inside it, like:
>>> >
>>> > <div><?=strtoupper($user['name']);?></div>
>>> >
>>> > And I have the following code as part of the templating engine:
>>> >
>>> > $template = file_get_contents($file);
>>> > $template = "return <<<TEMPLATE\n".$template."\nTEMPLATE;\n";
>>> > $template = eval($template);
>>> >
>>> > The problem is that the eval() HEREDOC combination gives the
>>> > following output:
>>> >
>>> > <?=strtoupper(Array['time']);?>
>>> >
>>> > If in the HTML file (template) I use
>>> >
>>> > <div><?=strtoupper({$user['name']});?></div>
>>> >
>>> > I get <?=strtoupper(username);?> as an output.
>>> >
>>> > I have tried closing the php tag like this:
>>> >
>>> > $template = "return <<<TEMPLATE\n?>".$template."\nTEMPLATE;\n";
>>> >
>>> > but the extra ?> only gets outputed as HTML.
>>> >
>>> > This is my first post to this mailing list, so I great you
>>> > all and thank you for any kind of solution to my problem.
>>>
>>> Why are you using HEREDOC to begin with? I personally find them to be
>> ugly
>>> and more trouble than they're worth.
>>>
>>> You can write the same thing as this I think (untested):
>>>
>>> $template = eval(file_get_contents($file));
>>>
>>> But you might also consider using "include_once" or "require_once"
>> instead
>>> of this "eval()" business.
>>>
>>> Also note, that a string can span more than one line and have variables
>> in
>>> it. It can even be used with code, so HEREDOC is again useless for most
>>> situations:
>>>
>>> $foo = "
>>> Hello $name,\n
>>> \n
>>> Today is ".date('Y-m-d')."\n
>>> \n
>>> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
>>> \n
>>> Nulla eros purus, pharetra a blandit non, pellentesque et leo. In augue
>>> metus, mattis a sollicitudin in, placerat vitae elit.
>>> \n
>>> Quisque elit mauris, varius sit amet cursus sed, eleifend a mauris.
>>> ";
>>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On 21 July 2010 06:46, Sorin Buturugeanu <m...@soin.ro> wrote:
> @Vincent: no, the short tags are not off.
>
> @Jim: This seamns to work fine:
>
> $template = file_get_contents(pathTemplates.$this->dir.$this->tpl);
> ob_start();
> $template = eval('?>'.$template);
> $template = ob_get_clean();
>
> Thanks!
>
> Best wishes!
>
> Sorin
>
>
> --
> Sorin Buturugeanu
> http://www.soin.ro
>
>
>
>
> On Wed, Jul 21, 2010 at 1:45 AM, <li...@cmsws.com> wrote:
>>
>>
>>
>> On Wed, 21 Jul 2010 01:04:12 +0300, Sorin Buturugeanu <m...@soin.ro> wrote:
>>> Hello Vincent and thank you for your reply :).
>>>
>>> That's true, I forgot to explain how I got to using HEREDOC, so ..
>>>
>>> Using eval(file_get_contents($file)) just outputs the result on the
>>> spot and I need
>>> to get the whole output (without echoing it) and do some more things with
>>> it.
>>>
>>> require_once() doesn't fit here (from what I can tell), because it
>>> would still just
>>> include the file in echo the output.
>>>
>>> I think there must be a solution, but I'm missing something here ..
>>
>>
>> Check out the ob_* functions
>>
>> You could do this
>>
>> ob_start();
>>
>> include "/your/file.php";
>>
>> $output = ob_get_clean();
>>
>> echo $output;
>>
>> Jim
>>
>>>
>>> Thanks again!
>>>
>>> --
>>> Sorin Buturugeanu
>>> http://www.soin.ro
>>>
>>>
>>> On Wed, Jul 21, 2010 at 12:49 AM, Daevid Vincent <dae...@daevid.com>
>>> wrote:
>>>>
>>>> > -----Original Message-----
>>>> > From: Sorin Buturugeanu [mailto:m...@soin.ro]
>>>> > Sent: Tuesday, July 20, 2010 2:11 PM
>>>> > To: php-gene...@lists.php.net
>>>> > Subject: [PHP] eval and HEREDOC
>>>> >
>>>> > Hello,
>>>> >
>>>> > I am having trouble with a part of my templating script. I'll
>>>> > try to explain:
>>>> >
>>>> > The template itself is HTML with PHP code inside it, like:
>>>> >
>>>> > <div><?=strtoupper($user['name']);?></div>
>>>> >
>>>> > And I have the following code as part of the templating engine:
>>>> >
>>>> > $template = file_get_contents($file);
>>>> > $template = "return <<<TEMPLATE\n".$template."\nTEMPLATE;\n";
>>>> > $template = eval($template);
>>>> >
>>>> > The problem is that the eval() HEREDOC combination gives the
>>>> > following output:
>>>> >
>>>> > <?=strtoupper(Array['time']);?>
>>>> >
>>>> > If in the HTML file (template) I use
>>>> >
>>>> > <div><?=strtoupper({$user['name']});?></div>
>>>> >
>>>> > I get <?=strtoupper(username);?> as an output.
>>>> >
>>>> > I have tried closing the php tag like this:
>>>> >
>>>> > $template = "return <<<TEMPLATE\n?>".$template."\nTEMPLATE;\n";
>>>> >
>>>> > but the extra ?> only gets outputed as HTML.
>>>> >
>>>> > This is my first post to this mailing list, so I great you
>>>> > all and thank you for any kind of solution to my problem.
>>>>
>>>> Why are you using HEREDOC to begin with? I personally find them to be
>>> ugly
>>>> and more trouble than they're worth.
>>>>
>>>> You can write the same thing as this I think (untested):
>>>>
>>>> $template = eval(file_get_contents($file));
>>>>
>>>> But you might also consider using "include_once" or "require_once"
>>> instead
>>>> of this "eval()" business.
>>>>
>>>> Also note, that a string can span more than one line and have variables
>>> in
>>>> it. It can even be used with code, so HEREDOC is again useless for most
>>>> situations:
>>>>
>>>> $foo = "
>>>> Hello $name,\n
>>>> \n
>>>> Today is ".date('Y-m-d')."\n
>>>> \n
>>>> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
>>>> \n
>>>> Nulla eros purus, pharetra a blandit non, pellentesque et leo. In augue
>>>> metus, mattis a sollicitudin in, placerat vitae elit.
>>>> \n
>>>> Quisque elit mauris, varius sit amet cursus sed, eleifend a mauris.
>>>> ";
>>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
1) heredoc is great for not caring about escaping ' or ". Whether or
not you like the syntax it's not hard to use in any way.
2) stay away from eval. Just don't use it unless you have no other choice
3) the include+output buffering solution is much better. Another
option would be to use markers in your templates and then just replace
them with content. Whether or not that would suit you depends on what
kinds of templates you're making and for what purpose
Regards
Peter
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>
--- End Message ---
--- Begin Message ---
Hi Peter!
In the first version of the template engine I had markers but now I
need more complex conditions or operations inside the template files,
like array of arrays and so on. I really like the freedom to be able
to just open a PHP tag <? ?> and use a foreach() or whatever PHP
function as I please.
Thanks again to all of you for your support! :)
Sorin
--
Sorin Buturugeanu
http://www.soin.ro
On Wed, Jul 21, 2010 at 9:47 AM, Peter Lind <peter.e.l...@gmail.com> wrote:
> On 21 July 2010 06:46, Sorin Buturugeanu <m...@soin.ro> wrote:
>> @Vincent: no, the short tags are not off.
>>
>> @Jim: This seamns to work fine:
>>
>> $template = file_get_contents(pathTemplates.$this->dir.$this->tpl);
>> ob_start();
>> $template = eval('?>'.$template);
>> $template = ob_get_clean();
>>
>> Thanks!
>>
>> Best wishes!
>>
>> Sorin
>>
>>
>> --
>> Sorin Buturugeanu
>> http://www.soin.ro
>>
>>
>>
>>
>> On Wed, Jul 21, 2010 at 1:45 AM, <li...@cmsws.com> wrote:
>>>
>>>
>>>
>>> On Wed, 21 Jul 2010 01:04:12 +0300, Sorin Buturugeanu <m...@soin.ro> wrote:
>>>> Hello Vincent and thank you for your reply :).
>>>>
>>>> That's true, I forgot to explain how I got to using HEREDOC, so ..
>>>>
>>>> Using eval(file_get_contents($file)) just outputs the result on the
>>>> spot and I need
>>>> to get the whole output (without echoing it) and do some more things with
>>>> it.
>>>>
>>>> require_once() doesn't fit here (from what I can tell), because it
>>>> would still just
>>>> include the file in echo the output.
>>>>
>>>> I think there must be a solution, but I'm missing something here ..
>>>
>>>
>>> Check out the ob_* functions
>>>
>>> You could do this
>>>
>>> ob_start();
>>>
>>> include "/your/file.php";
>>>
>>> $output = ob_get_clean();
>>>
>>> echo $output;
>>>
>>> Jim
>>>
>>>>
>>>> Thanks again!
>>>>
>>>> --
>>>> Sorin Buturugeanu
>>>> http://www.soin.ro
>>>>
>>>>
>>>> On Wed, Jul 21, 2010 at 12:49 AM, Daevid Vincent <dae...@daevid.com>
>>>> wrote:
>>>>>
>>>>> > -----Original Message-----
>>>>> > From: Sorin Buturugeanu [mailto:m...@soin.ro]
>>>>> > Sent: Tuesday, July 20, 2010 2:11 PM
>>>>> > To: php-gene...@lists.php.net
>>>>> > Subject: [PHP] eval and HEREDOC
>>>>> >
>>>>> > Hello,
>>>>> >
>>>>> > I am having trouble with a part of my templating script. I'll
>>>>> > try to explain:
>>>>> >
>>>>> > The template itself is HTML with PHP code inside it, like:
>>>>> >
>>>>> > <div><?=strtoupper($user['name']);?></div>
>>>>> >
>>>>> > And I have the following code as part of the templating engine:
>>>>> >
>>>>> > $template = file_get_contents($file);
>>>>> > $template = "return <<<TEMPLATE\n".$template."\nTEMPLATE;\n";
>>>>> > $template = eval($template);
>>>>> >
>>>>> > The problem is that the eval() HEREDOC combination gives the
>>>>> > following output:
>>>>> >
>>>>> > <?=strtoupper(Array['time']);?>
>>>>> >
>>>>> > If in the HTML file (template) I use
>>>>> >
>>>>> > <div><?=strtoupper({$user['name']});?></div>
>>>>> >
>>>>> > I get <?=strtoupper(username);?> as an output.
>>>>> >
>>>>> > I have tried closing the php tag like this:
>>>>> >
>>>>> > $template = "return <<<TEMPLATE\n?>".$template."\nTEMPLATE;\n";
>>>>> >
>>>>> > but the extra ?> only gets outputed as HTML.
>>>>> >
>>>>> > This is my first post to this mailing list, so I great you
>>>>> > all and thank you for any kind of solution to my problem.
>>>>>
>>>>> Why are you using HEREDOC to begin with? I personally find them to be
>>>> ugly
>>>>> and more trouble than they're worth.
>>>>>
>>>>> You can write the same thing as this I think (untested):
>>>>>
>>>>> $template = eval(file_get_contents($file));
>>>>>
>>>>> But you might also consider using "include_once" or "require_once"
>>>> instead
>>>>> of this "eval()" business.
>>>>>
>>>>> Also note, that a string can span more than one line and have variables
>>>> in
>>>>> it. It can even be used with code, so HEREDOC is again useless for most
>>>>> situations:
>>>>>
>>>>> $foo = "
>>>>> Hello $name,\n
>>>>> \n
>>>>> Today is ".date('Y-m-d')."\n
>>>>> \n
>>>>> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
>>>>> \n
>>>>> Nulla eros purus, pharetra a blandit non, pellentesque et leo. In augue
>>>>> metus, mattis a sollicitudin in, placerat vitae elit.
>>>>> \n
>>>>> Quisque elit mauris, varius sit amet cursus sed, eleifend a mauris.
>>>>> ";
>>>>>
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> 1) heredoc is great for not caring about escaping ' or ". Whether or
> not you like the syntax it's not hard to use in any way.
> 2) stay away from eval. Just don't use it unless you have no other choice
> 3) the include+output buffering solution is much better. Another
> option would be to use markers in your templates and then just replace
> them with content. Whether or not that would suit you depends on what
> kinds of templates you're making and for what purpose
>
> Regards
> Peter
>
> --
> <hype>
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: http://twitter.com/kafe15
> </hype>
>
--- End Message ---
--- Begin Message ---
On Mon, 19 Jul 2010 10:36:40 -0600
"Ashley M. Kirchner" <ash...@pcraft.com> wrote:
> mysql> select * from table where id='00001';
> +-------+-----+-----+---+
> | 00001 | 123 | 0.0 | C |
> | 00001 | 234 | 0.1 | D |
> | 00001 | 345 | 0.0 | D |
> | 00001 | 456 | 0.1 | C |
> | 00001 | 567 | 0.1 | G |
> +-------+-----+-----+---+
>
> Now, I have to find other IDs that match the above result. In the
> table, that would be ID '00003' (and in the entire DB, there may be
> others as well - I need to find all those IDs.) But, notice how ID 0003
> isn't in the same order as ID 00001, but the data is still the same.
>
select distinct id from `table` where concat(`b`, `c`, `d`) in (select
concat(`b`,`c`,`d` from `table` where id = '0001') AND id != '0001';
(untested)
--
Simcha Younger <sim...@syounger.com>
--- End Message ---
--- Begin Message ---
Dear all,
I'm a newbie, need your help.
Now I am building a databasea using MySQL and PHP, I want to put two tables
in one searching, the two are in one database.
$query = "SELECT SQL_CALC_FOUND_ROWS * FROM table1 WHERE ".implode(" AND
", $data);
$number = "SELECT FOUND_ROWS()";
How can I change this if I want to put table2 in it.
Thank you.
Best wishes,
diana
2010-7-21
--- End Message ---
--- Begin Message ---
Hello
I have a problem with a update using PDO.
(learning atm and updating a php class to use PDO)
private function updateUser($id)
{
$date = mktime();
$DB = Db::getInstance();
$stmt = $DB->prepare('"UPDATE '. TBL_USERS .' SET
date_last_action=:updateDate WHERE id=:userId');
$stmt->bindParam(":updateDate", $date);
$stmt->bindParam(":userId", $id);
$stmt->execute();
}
It does not work.
I get this :
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error
in your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near '"UPDATE mf_Users SET
date_last_action='1279717039' WHERE id='1'' at line 1' in
/public_html/forum/includes/classes/Auth.class.php on line *157*
PDO works and is fine with my SELECT request's. Does not seam to work with
this simple UPDATE. I tested the request in PHPMyAdmin and it works. (UPDATE
mf_Users SET date_last_action='1279717039' WHERE id='1')
Thx,
Sky
--- End Message ---