[PHP] Re: problem with session_write_close

2011-07-14 Thread Tamara Temple
I'm having a problem with a brand new installation of pmwiki. I've not  
encountered this before so I'm unsure why this is happening. The  
following two warnings are presented at the top of each page:


Warning: session_write_close() [function.session-write-close]: open(/ 
var/lib/php/session/sess_sh3dvs4pgiuq04vmj1tfmkqvj1, O_RDWR) failed:  
Permission denied (13) in/var/www/vhosts/mouseha.us/httpdocs/ 
pmwiki-2.2.27/pmwiki.php on line 2012


Warning: session_write_close() [function.session-write-close]: Failed  
to write session data (files). Please verify that the current setting  
of session.save_path is correct (/var/lib/php/session) in/var/www/ 
vhosts/mouseha.us/httpdocs/pmwiki-2.2.27/pmwiki.php on line 2012


There are plenty of other session files in that directory with the  
owner/group apache:apache. I don't know why it can't deal with this.


(Cross-posted between pmwiki-users and php-general.)

Update: I found out what was happening -- nothing to do with php in  
general. My lovely server management software (Plesk) has started  
adding a new line to it's vhost http include file:


SuexecUserGroup mouse psacln

which means apache is running under the local user/group for  
permissions. The file in question above was left over from a previous  
incarnation of the site (I blew it away and recreated it to start  
fresh - hah!) so the session file was left over from the previous  
session (not at all clear why it didn't get a new one) and had the  
wrong permissions set. Resetting the permissions solved the problem.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] is_null() and is_string() reversed when using in switch case statements... [SOLVED]

2011-07-14 Thread Daevid Vincent
> -Original Message-
> From: Simon J Welsh [mailto:si...@welsh.co.nz]
> Sent: Thursday, July 14, 2011 7:29 PM
> To: Daevid Vincent
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] is_null() and is_string() reversed when using in switch
> case statements...
> 
> On 15/07/2011, at 1:58 PM, Daevid Vincent wrote:
> 
> > function test($v)
> > {
> > var_dump($v);
> >
> > if (is_string($v)) echo "FOUND A STRING.\n";
> > if (is_null($v)) echo "FOUND A NULL.\n";
> >
> > switch ($v)
> > {
> > case is_string($v):
> > echo "I think v is a string, so this is broken.\n";
> > break;
> > case is_null($v):
> > echo "I think v is null, so this is broken.\n";
> > break;
> > case is_object($v):
> > $v = '{CLASS::'.get_class($v).'}';
> > echo "I think v is a class $v\n";
> > break;
> >
> > case is_bool($v):
> > $v = ($v) ? '{TRUE}' : '{FALSE}';
> > echo "I think v is boolean $v\n";
> > break;
> > case is_array($v):
> > $v = '['.implode(',',$v).']';
> > echo "I think v is an array $v\n";
> > break;
> > case is_numeric($v):
> > echo "I think v is a number $v\n";
> > break;
> > }
> > }
> 
> In both cases, $v is equivalent to false, so is_string(NULL) = false ==
NULL
> == $v, likewise for is_null($v);
> 
> You're most likely after switch(true) { . } rather than switch($v)
> ---
> Simon Welsh
> Admin of http://simon.geek.nz/

Ah! Thanks Simon! That is exactly right. Doh! I should have thought of
that... *smacks head*

Here is the fruit of my labor (and your fix)...

/**
 * Useful for debugging functions to see parameter names, etc.
 * Based upon http://www.php.net/manual/en/function.func-get-args.php#103296
 *
 * function anyfunc($arg1, $arg2, $arg3)
 * {
 *   debug_func(__FUNCTION__, '$arg1, $arg2, $arg3', func_get_args());
 *   //do useful non-debugging stuff
 * }
 *
 * @access  public
 * @return  string
 * @param   string $function_name __FUNCTION__ of the root function as
passed into this function
 * @param   string $arg_names the ',,,' encapsulated parameter list of
the root function
 * @param   array $arg_vals the result of func_get_args() from the root
function passed into this function
 * @param   boolean $show_empty_params (FALSE)
 * @author  Daevid Vincent
 * @date  2011-17-14
 * @see func_get_args(), func_get_arg(), func_num_args()
 */
function debug_func($function_name, $arg_names, $arg_vals,
$show_empty_params=FALSE)
{
$params = array();
echo $function_name.'(';
$arg_names_array = explode(',', $arg_names);
//var_dump($arg_names, $arg_names_array, $arg_vals );
foreach($arg_names_array as $k => $parameter_name)
{
 $v = $arg_vals[$k];
 //echo "k = $parameter_name = $k and v = arg_vals[k] = $v\n";
switch(true)
{
case is_string($v): if ($show_empty_params) $v = "'".$v."'"
; break;
case is_null($v): if ($show_empty_params) $v = '{NULL}';
break;
case is_bool($v): $v = ($v) ? '{TRUE}' : '{FALSE}'; break;
case is_array($v): (count($v) < 10) ? $v =
'['.implode(',',$v).']' : $v = '[ARRAY]'; break;
case is_object($v): $v = '{CLASS::'.get_class($v).'}';
break;
case is_numeric($v): break;
}

if ($show_empty_params || $v) $params[$k] = trim($parameter_name).':
'.$v;
}
echo implode(', ',$params).")\n";
}



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] is_null() and is_string() reversed when using in switch case statements...

2011-07-14 Thread Simon J Welsh
On 15/07/2011, at 1:58 PM, Daevid Vincent wrote:

> function test($v)
> {
>   var_dump($v);
> 
>   if (is_string($v)) echo "FOUND A STRING.\n";
>   if (is_null($v)) echo "FOUND A NULL.\n";
> 
>   switch ($v)
>   {
>   case is_string($v):
>   echo "I think v is a string, so this is broken.\n";
>   break;
>   case is_null($v):
>   echo "I think v is null, so this is broken.\n";
>   break;
>   case is_object($v):
>   $v = '{CLASS::'.get_class($v).'}';
>   echo "I think v is a class $v\n";
>   break;
> 
>   case is_bool($v):
>   $v = ($v) ? '{TRUE}' : '{FALSE}';
>   echo "I think v is boolean $v\n";
>   break;
>   case is_array($v):
>   $v = '['.implode(',',$v).']';
>   echo "I think v is an array $v\n";
>   break;
>   case is_numeric($v):
>   echo "I think v is a number $v\n";
>   break;
>   }
> }

In both cases, $v is equivalent to false, so is_string(NULL) = false == NULL == 
$v, likewise for is_null($v);

You're most likely after switch(true) { … } rather than switch($v)
---
Simon Welsh
Admin of http://simon.geek.nz/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] is_null() and is_string() reversed when using in switch case statements...

2011-07-14 Thread Daevid Vincent
Can someone double check me here, but I think I found a bug...

 int 1
  1 => int 2
  2 => int 3
  3 => int 4
  4 => int 5
I think v is an array [1,2,3,4,5]
 */
?>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] Your language sucks because...

2011-07-14 Thread Micky Hulse
On Thu, Jul 14, 2011 at 4:19 PM, George Langley  wrote:
> He gave you a beautiful hint:

:: slaps self on forehead ::

I should've known!!! :D

Thanks!
Micky

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] Your language sucks because...

2011-07-14 Thread George Langley
- Original Message -
From: Micky Hulse 

> On Thu, Jul 14, 2011 at 4:02 AM, Richard Quadling 
>  wrote:
> > My daughter (6 or 7 at the time) came up with T, M and E. I was
> > abso-bloody-lutely amazed she managed to find a word starting 
> with T,
> > M and E.
> 
> What was the word?
--
He gave you a beautiful hint:

tmesis |təˈmēsis|
noun ( pl. -ses |-sēz|)
the separation of parts of a compound word by an intervening word or words, 
heard mainly in informal speech (e.g., a whole nother story; shove it back 
any-old-where in the pile).
ORIGIN mid 16th cent.: from Greek tmēsis ‘cutting,’ from temnein ‘to cut.’

George

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: str_replace around a character??

2011-07-14 Thread Shawn McKenzie
On 07/13/2011 04:03 PM, Karl DeSaulniers wrote:
> 
> Thanks Shawn,
> I had actually found the same thing myself..
> 
> $subCc = array_map('trim',explode(",",$subCc));
> 
> But I could not find my post last night to make a new comment about it.
> Thank you for yours though.. I did not think of the implode part.
> 
> Best,
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
> 

You probably want the array_filter() in there also, because commas at
the beginning or end or other issues can leave you with empty array
elements that will still be imploded resulting in just a comma.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Variable scope

2011-07-14 Thread Karl DeSaulniers

Lol.. thanks Shawn..
You just caught me trying to hide my actually variable names.
guess I missed some. :P
They are actually the same in my code

*blushing*

Any clue why the if(){ statement would make the variables $email and  
$reply loose their value?

That was the chunk of it. Thanks for the error reporting code.


Best,
Karl


On Jul 14, 2011, at 4:17 PM, Shawn McKenzie wrote:


On 07/14/2011 03:54 PM, Karl DeSaulniers wrote:

Can anyone explain this to me.


I can't read through all that crap, but I notice multiple times  
that you
use undefined variables, due to typo or just not remembering what  
they are.


You pass in $subjField but later try and use $subjectField.  You  
pass in

$e_cc but try and use $_email_cc, etc, etc, etc...

Develop with:

error_reporting(E_ALL);
ini_set('display_errors', '1');

This will tell you about all of those undefined variables.

--
Thanks!
-Shawn
http://www.spidean.com


Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variable scope

2011-07-14 Thread Tamara Temple


On Jul 14, 2011, at 3:54 PM, Karl DeSaulniers wrote:


Can anyone explain this to me.

function sendEmail($uname,$subjField,$firstname,$lastname,$email, 
$reply,$e_cc,$e_bcc,$comments,$ip,$Date,$time){


   $uname = trim($uname);
   $subjField = trim($subjField);
   $firstname = trim($firstname);
   $lastname = trim($lastname);
   $email = trim($email);
   $reply = trim($reply);
   $e_cc = trim($e_cc);
   $e_bcc = trim($e_bcc);
   $comments = trim($comments);
   $ip = trim($ip);
   $Date = trim($Date);
   $time = trim($time);

//If I trace here email, reply and the CCs are ok

	if(($firstname && strlen($firstname = trim($firstname)) > 2) &&  
($lastname && strlen($lastname = trim($lastname)) > 2)) {

$fullname = $firstname." ".$lastname;
} else {
$fullname = "Member";
}
$fullname = trim($fullname);
$To = "";
$from = "";
$headerTXT = "";
$bounce_email = CO_NAME." <".BOUNCE_ADDR.">";
$subject = $subjectField;
$bulk = false;
   //What kind of email is being sent
   //Email exists, no Cc or Bcc
   if(!empty($email) && empty($_email_cc) && empty($_email_bcc)) {
$To = $fullname." <".$email.">";
$from = "Member <".$reply.">";
$headerTXT = "New message from ".CO_NAME." member ".$uname;
$bulk = false;
}
   //Email empty, Cc exists no Bcc
   else if(empty($email) && !empty($e_cc) && empty($e_bcc)) {
$To = $bounce_email;
$from = "Member <".$reply.">";
$headerTXT = "New message from ".CO_NAME." member ".$uname;
$bulk = true;
}
...

//If I trace here $To, $from have everything except the "<(anything  
between)>", so for instance..

$To = John Doe ;
$from = Member ;


Have you looked at the output in the page source? The <> may be  
getting eaten by the browser. You may want to use htmlentities on your  
trace output (but not the actual variables).





not

$To = John Doe  ;
$from = Member ;

So $email and $reply are loosing their value/scope

But the ".CO_NAME." and ".BOUNCE_ADDR." are working!?!?


I assume these are defined constants, which don't have scope (or,  
perhaps more accurately, always have global scope).


This is also in a page with many other email functions just like  
this one and they work.
Only difference is the $To and $from are not inside an if()  
{ statement.

How did my variables loose scope???

One other note, if I put..
$To = htmlspecialchars($fullname." <".$email.">");
then $To is correct when I trace..
$To = John Doe  ;
but it wont send because the smtp mail will not send to
$To = John Doe 

I MUST be doing something wrong.
Also, I did read about using Name  but the other  
email functions work fine with those, so I'm not sure what's going on.

TIA,
Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Variable scope

2011-07-14 Thread Shawn McKenzie
On 07/14/2011 03:54 PM, Karl DeSaulniers wrote:
> Can anyone explain this to me.

I can't read through all that crap, but I notice multiple times that you
use undefined variables, due to typo or just not remembering what they are.

You pass in $subjField but later try and use $subjectField.  You pass in
$e_cc but try and use $_email_cc, etc, etc, etc...

Develop with:

error_reporting(E_ALL);
ini_set('display_errors', '1');

This will tell you about all of those undefined variables.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] problem with session_write_close

2011-07-14 Thread Tamara Temple
I'm having a problem with a brand new installation of pmwiki. I've not  
encountered this before so I'm unsure why this is happening. The  
following two warnings are presented at the top of each page:


Warning: session_write_close() [function.session-write-close]: open(/ 
var/lib/php/session/sess_sh3dvs4pgiuq04vmj1tfmkqvj1, O_RDWR) failed:  
Permission denied (13) in/var/www/vhosts/mouseha.us/httpdocs/ 
pmwiki-2.2.27/pmwiki.php on line 2012


Warning: session_write_close() [function.session-write-close]: Failed  
to write session data (files). Please verify that the current setting  
of session.save_path is correct (/var/lib/php/session) in/var/www/ 
vhosts/mouseha.us/httpdocs/pmwiki-2.2.27/pmwiki.php on line 2012


There are plenty of other session files in that directory with the  
owner/group apache:apache. I don't know why it can't deal with this.


(Cross-posted between pmwiki-users and php-general.)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Variable scope

2011-07-14 Thread Karl DeSaulniers

Can anyone explain this to me.

function sendEmail($uname,$subjField,$firstname,$lastname,$email, 
$reply,$e_cc,$e_bcc,$comments,$ip,$Date,$time){


$uname = trim($uname);
$subjField = trim($subjField);
$firstname = trim($firstname);
$lastname = trim($lastname);
$email = trim($email);
$reply = trim($reply);
$e_cc = trim($e_cc);
$e_bcc = trim($e_bcc);
$comments = trim($comments);
$ip = trim($ip);
$Date = trim($Date);
$time = trim($time);

//If I trace here email, reply and the CCs are ok

	if(($firstname && strlen($firstname = trim($firstname)) > 2) &&  
($lastname && strlen($lastname = trim($lastname)) > 2)) {

$fullname = $firstname." ".$lastname;
} else {
$fullname = "Member";
}
$fullname = trim($fullname);
$To = "";
$from = "";
$headerTXT = "";
$bounce_email = CO_NAME." <".BOUNCE_ADDR.">";
$subject = $subjectField;
$bulk = false;
//What kind of email is being sent
//Email exists, no Cc or Bcc
if(!empty($email) && empty($_email_cc) && empty($_email_bcc)) {
$To = $fullname." <".$email.">";
$from = "Member <".$reply.">";
$headerTXT = "New message from ".CO_NAME." member ".$uname;
$bulk = false;
}
//Email empty, Cc exists no Bcc
else if(empty($email) && !empty($e_cc) && empty($e_bcc)) {
$To = $bounce_email;
$from = "Member <".$reply.">";
$headerTXT = "New message from ".CO_NAME." member ".$uname;
$bulk = true;
}
...

//If I trace here $To, $from have everything except the "<(anything  
between)>", so for instance..

$To = John Doe ;
$from = Member ;

not

$To = John Doe  ;
$from = Member ;

So $email and $reply are loosing their value/scope

But the ".CO_NAME." and ".BOUNCE_ADDR." are working!?!?
This is also in a page with many other email functions just like this  
one and they work.

Only difference is the $To and $from are not inside an if() { statement.
How did my variables loose scope???

One other note, if I put..
$To = htmlspecialchars($fullname." <".$email.">");
then $To is correct when I trace..
$To = John Doe  ;
but it wont send because the smtp mail will not send to
$To = John Doe 

I MUST be doing something wrong.
Also, I did read about using Name  but the other  
email functions work fine with those, so I'm not sure what's going on.

TIA,
Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com



Re: Re: [PHP] Your language sucks because...

2011-07-14 Thread Micky Hulse
On Thu, Jul 14, 2011 at 4:02 AM, Richard Quadling  wrote:
> My daughter (6 or 7 at the time) came up with T, M and E. I was
> abso-bloody-lutely amazed she managed to find a word starting with T,
> M and E.

What was the word?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: IF stream lining

2011-07-14 Thread Shawn McKenzie
On 07/13/2011 11:20 PM, Ron Piggott wrote:
> 
> Is there a way to stream line this:
> 
> if ( ( $val <> "with" ) AND ( $val <> "from" ) ) {
> 
> Ron
> 
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info  
> 

Depends on what you mean by streamlined.  If it were longer, this might
be useful:

if(!in_array($val, array('with','from','to','against','mom','dad')) {

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP 5.3.7RC3 Released for Testing

2011-07-14 Thread Ilia Alshanetsky
The third and hopefully final release candidate of 5.3.7 was just
released for testing and can be downloaded here:

https://downloads.php.net/ilia/php-5.3.7RC3.tar.bz2 (md5sum:
0ad46340ca3d4319ab10eac4a3978ae0)
https://downloads.php.net/ilia/php-5.3.7RC3.tar.gz (md5sum:
eab0329078f74f6c8fe5abcf6943b262)

The Windows binaries are available at: http://windows.php.net/qa/

Given the volume of fixes since RC2 it was deemed necessary to make
another to ensure that there are no regressions. The intent is that
this is the final release candidate before the final release, which if
all goes well will follow in 2 weeks. PHP 5.3.7 is focused on
improving the stability and security. To ensure that the release is
solid, please test this RC against your code base and report any
problems that you encounter.

To find out what was changed since the last release please refer to
the NEWS file found within the archive or on
http://svn.php.net/viewvc/php/php-src/tags/php_5_3_7RC3/NEWS?revision=HEAD&view=markup

Windows users please mind that we don't provide VS6 builds anymore
since PHP 5.3.6.

Ilia Alshanetsky

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Your language sucks because...

2011-07-14 Thread George Langley
On 2011-07-14, at 4:36 AM, Ashley Sheridan wrote:

> 
> That's a massive pet hate of mine, along with using here/hear in the wrong 
> way and those who have no idea of the difference between "there", "their" & 
> "they're". Makes me want to beat them upside the head with a dictionary :)

Mine are it's and its (Remember: it's its!), people who say "people 
that" (It should be "People WHO!") and the complete lack of regard to plural 
versus singular verbs ("There's lots?" "No, there ARE lots of examples of that 
out there!").
As far as the original list:

http://wiki.theory.org/YourLanguageSucks#PHP_sucks_because:

it's just a tongue-in-cheek way to point out inconsistencies in the various 
languages. However, is kind of out-dated, referring to PHP 4 and CSS 2, so am 
wondering how many of the entries have been rectified? (For instance, CSS 3 
does have multiple background images.) As well, I suspect that some of them may 
actually make sense if analyzed as to why they are that way, instead of how the 
author has grouped them.


George Langley
Multimedia Developer



Re: [PHP] What is a label?

2011-07-14 Thread Daniel Brown
On Wed, Jul 13, 2011 at 16:57, Tim Streater  wrote:
> Looking over the definition of a function today I see:
>
>    Function names follow the same rules as other labels in PHP.
>
> but I can't find the definition of a label anywhere. I can't see it listed in 
> the contents - have I overlooked it? If not, how can I request the the doccy 
> be updated?

In this context, a label refers to the human-readable text
referencing the underlying bits and bytes.  Variables, function names,
class definitions, et cetera, are all considered labels, or - in
another way of explaining it - an alias to the corresponding program
address.

The second part of your message is simple: look at the top-right
section of any document entry and you'll see, just to the left of the
"last updated" string, an [edit] link.  Click that, and you're on your
way.  The documentation won't update immediately, and your changes
will have to be reviewed by someone here on the Docs team, of course,
but you're certainly welcome - and encouraged - to contribute if you'd
like.

-- 

Network Infrastructure Manager
http://www.php.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Serveside Printing w/ PHP

2011-07-14 Thread Marc Guay
> 4 - And just found it. WordPad comes with Windows, so, maybe
> PHP+COM+WordPad
> (http://msdn.microsoft.com/en-us/library/51y8h3tk(v=vs.80).aspx) could
> be another option here. I think WordPad is just a visual wrapper for
> the RichEdit20 ActiveX component which is controllable via COM.
>
> By using templates, you could create appropriate files manually in
> WordPad and then just do a search/replace in PHP, load into RichEdit
> and print. Theoretically, a simple process.

This is the solution I'm working with except instead of WordPad I'm
using Internet Explorer and letting it parse the HTML and print.
Required a bit of fudging around with Apache permissions on the
server, probably giving it more power than it should, but for this
project it's a one-off local-only website so it shouldn't be a
problem.

I followed the first example in this article:
http://thefrozenfire.com/2011/02/using-the-windows-com-in-php/

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] What is a label?

2011-07-14 Thread Richard Quadling
On 14 July 2011 13:37, Steve Staples  wrote:
>> A valid variable name starts with a letter or underscore
>
> If I am not mistaken, $_1 is not a valid variable name.

[2011-07-14 13:19:18] [Z:\] [\\richardquadling\scratch$ ] >php -r "$_1
= 'one'; echo $_1;"
one

It starts with an undercore and is, therefore, just fine!

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] What is a label?

2011-07-14 Thread Steve Staples
On Thu, 2011-07-14 at 13:39 +0100, Stuart Dallas wrote:
> On Thu, Jul 14, 2011 at 1:37 PM, Steve Staples  wrote:
> 
> > On Wed, 2011-07-13 at 23:27 +0100, Tim Streater wrote:
> > > A valid variable name starts with a letter or underscore
> >
> > If I am not mistaken, $_1 is not a valid variable name.
> 
> 
> You are mistaken. Try it.
> 
> -Stuart
> 

You're right... I have like 100 php scripts open in my Komodo IDE, and I
tried it before I posted out of curiosity.  I put it in the wrong
script, therefore, when it didn't do anything I assumed it didn't work.

Thanks Stuart, for pointing that out!  I've never used a number as the
first character after the $_, and I still probably never will... force
of habit I guess :)

Steve.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] What is a label?

2011-07-14 Thread Stuart Dallas
On Thu, Jul 14, 2011 at 1:37 PM, Steve Staples  wrote:

> On Wed, 2011-07-13 at 23:27 +0100, Tim Streater wrote:
> > A valid variable name starts with a letter or underscore
>
> If I am not mistaken, $_1 is not a valid variable name.


You are mistaken. Try it.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


Re: Re: [PHP] What is a label?

2011-07-14 Thread Steve Staples
On Wed, 2011-07-13 at 23:27 +0100, Tim Streater wrote:
> On 13 Jul 2011 at 22:39, Micky Hulse  wrote: 
> 
> > They must mean labels as in "general naming convention rules for
> > programming"... Like not naming a variable/function "label" with a number at
> > the front.
> >
> > Here's a page about variables:
> >
> > http://www.php.net/manual/en/language.variables.basics.php
> >
> > Variable names follow the same rules as other labels in PHP. A valid
> > variable name starts with a letter or underscore, followed by any
> > number of letters, numbers, or underscores. As a regular expression,
> > it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
> 
> Except that variables are case-sensitive whereas function names are not. And 
> if there's going to be a formal or "programmatic" definition, then I think 
> I'd prefer BNF to a regexp.
> 
> --
> Cheers  --  Tim
> 

Isn't that statement a little misleading?

> A valid variable name starts with a letter or underscore

If I am not mistaken, $_1 is not a valid variable name.  

Steve.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] Your language sucks because...

2011-07-14 Thread Richard Quadling
> On 14 July 2011 11:36, Ashley Sheridan  wrote:
> Makes me want to beat them upside the head with a dictionary :)

In our house, our Big Red Book _IS_ a massive Oxford Dictionary.

We play a game with the kids. Think of 3 random letters and find a
word starting with it.

My daughter (6 or 7 at the time) came up with T, M and E. I was
abso-bloody-lutely amazed she managed to find a word starting with T,
M and E.

Richard.

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] Your language sucks because...

2011-07-14 Thread Richard Quadling
On 14 July 2011 11:36, Ashley Sheridan  wrote:
> That's a massive pet hate of mine, along with using here/hear in the wrong 
> way and those who have no idea of the difference between "there", "their" & 
> "they're". Makes me want to beat them upside the head with a dictionary :)
> Thanks,
> Ash

Its all a matter of perspective isnt it? ;-) (here fishy fishy)

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] Your language sucks because...

2011-07-14 Thread Ashley Sheridan



>Particularly as it's written by a fathead who thinks that "lose" is
>spelt "loose".
>
>--
>Cheers  --  Tim
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

That's a massive pet hate of mine, along with using here/hear in the wrong way 
and those who have no idea of the difference between "there", "their" & 
"they're". Makes me want to beat them upside the head with a dictionary :)
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP control structure

2011-07-14 Thread Richard Quadling
On 14 July 2011 05:15, Negin Nickparsa  wrote:
> if the problem is only the assigning it's an example:
> in mysql you can have this one:
> create table store_list(id_markets int auto_increment,store_type int,primary
> key(id_markets));
>
> and for page this one:
>
> 
>
> 
> Store
> 
> 
>  $connection=Mysql_connect('localhost','admin','123');
> Mysql_select_db('net',$connection);
> if(array_key_exists('sub',$_POST))
> if(isset($_POST['store_type']) )
> {
> $Type =$_POST['store_type'];
> $ID=$_POST['id'];
>  $sql ="update store_list set store_type=$Type where id_markets=$ID";
> $res = mysql_query($sql,$connection);
> }
> ?>
> 
> store type
> corporate
> standard
> 
> ID:
> 
> 
> 
>
> also I didn't understand your code that you have 'id_store' and 'id_markets'
> it's confusing for me
>
> if it wasn't your problem please clarify your question maybe I can help.
>

I'd do this in the SQL...


SELECT DISTINCT
store_type,
CASE store_type
WHEN 1 THEN 'Corporate'
WHEN 2 THEN 'Standard'
ELSE 'Unknown store_type ' + CAST(store_type AS VARCHAR())
END AS store_type_desc
FROM
store_list
WHERE
id_markets=$_POST[id];

Though for the text, I'd probably have a store_types table so I can
label them there and hold additional data about the store types if
needed.

SELECT DISTINCT
store_type,
COALESCE(store_type_desc, 'Unknown store_type ' + CAST(store_type AS
VARCHAR())) AS store_type_desc
FROM
store_list
LEFT OUTER JOIN
store_types ON store_list.store_type = store_types.store_type
WHERE
id_markets=$_POST[id];


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Serveside Printing w/ PHP

2011-07-14 Thread Richard Quadling
On 12 July 2011 18:45, Marc Guay  wrote:
> Hi folks,
>
> I'm working on a project that will only be run locally on a WAMP
> server.  A mobile browser/app will call a certain page which should
> silently trigger a print job to a printer connected to the printer.
> Does anyone have advice on how to accomplish this?  I've seen
> implementations involving Crystal Reports which will be available on
> the server, but perhaps someone has a solutions that won't involve 3rd
> party software.
>
> Marc

Several options come to mind.

1 - Use Crystal Reports Developer Edition (or an app that comes with
Crystal Reports RunTime and a non developer edition of CR). Maximum
version is XI R2. After that, there is no COM interface, only .NET and
Java - and I can't get the .NET interface to operate in the same way
as I can the COM interface.

2 - Create PDF files and use Acrobat Reader or some other PDF print
driver (CutePDF maybe) - ideally something that can be unattended. The
fpdf class (http://fpdf.org is what I use).

3 - If you are already using Windows, then maybe you have MS Office?
Another COM solution could be to use MS Word or MS Excel (depending
upon the nature of the reports you need.

4 - And just found it. WordPad comes with Windows, so, maybe
PHP+COM+WordPad
(http://msdn.microsoft.com/en-us/library/51y8h3tk(v=vs.80).aspx) could
be another option here. I think WordPad is just a visual wrapper for
the RichEdit20 ActiveX component which is controllable via COM.

By using templates, you could create appropriate files manually in
WordPad and then just do a search/replace in PHP, load into RichEdit
and print. Theoretically, a simple process.

Richard.
-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Report generation as pdf and csv in php application for huge record set

2011-07-14 Thread George Langley

On 2011-07-14, at 12:50 AM, Midhun Girish wrote:

> 
> 
> On Thu, Jul 14, 2011 at 11:18 AM, George Langley  
> wrote:
> On 2011-07-13, at 11:20 PM, Midhun Girish wrote:
> 
> > Hi,
> >
> >
> > - Browsers generally have a 5 minute time-out. If you send the PDF directly 
> > to the browser and reach the limit, it will be lost. It is therefore 
> > advised for very big documents to generate them in a file, and to send some 
> > data to the browser from time to time (with a call to flush() to force the 
> > output). When the document is finished, you can send a redirection to it or 
> > create a link.
> > Remark: even if the browser times out, the script may continue to run on 
> > the server.
> >
> >
> > When it comes to the user end, they wont wait for more than 1 min. So 
> > redirection after generating the report is not possible. But creating link 
> > may be a good idea. How can it be done? I mean shouldn't there be a service 
> > running in the server to process these request after the execution of the 
> > php script is completed? Also shouldn't we post all the report generation 
> > request to a database so that serial processing can be done?
> ---
>We're helping each other here, as I'm facing a similar situation! Read 
> up on how to store as a file here:
> 
> 
> 
> You should then be able to generate an email notification to send once the 
> file is complete, with the link to the newly-created file.
> 
> 
> George Langley
> Multimedia Developer
> 
> 
> Suppose we are using this tool at sever side. We have set up the php page so 
> that all request will be saved in a db. And based on the conditions in 
> request a pdf CAN be generated by this tool. My question is how will we give 
> the trigger for generating this pdf? We cant do it in the php script due to 
> the timeout problem. The only solution i can think of is a cron which is 
> repeated every 5 min or so which fetches records from the db and generates 
> the pdf. But even with a cron we will face the timeout problem. Is there any 
> alternative to a cron like a server side service or something?
> 
> 
> Midhun Girish
--
As I understand it, the "server-side" timeout can be increased in the 
php.ini setting. So the PHP script can run as long as required if that is set 
sufficiently high enough. As long as you send something to the browser to 
confirm that the process has started, the browser-side timeout will not be a 
problem and your user will know to wait until notified by email that the file 
is ready. Once the script has completed, it stores the final db record and 
sends the email.

George

Re: Re: [PHP] Your language sucks because...

2011-07-14 Thread Tim Streater
On 14 Jul 2011 at 01:59, Lester Caine  wrote: 

> Daevid Vincent wrote:
>> (at the risk of starting another $h!t storm like the last time)
>>
>> http://wiki.theory.org/YourLanguageSucks#PHP_sucks_because:
>
> Perhaps when they get around to checking the facts ... most of the content
> will
> be deleted? A number of the -ve's I'd personally flag as +ve's and complain if
> anybody changed them ...
> Generally I'd say the whole page simply sucks :)

Particularly as it's written by a fathead who thinks that "lose" is spelt 
"loose".

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] IF stream lining

2011-07-14 Thread tamouse mailing lists
That's already pretty streamlined...
On Jul 13, 2011 11:22 PM, "Ron Piggott" 
wrote:
>
> Is there a way to stream line this:
>
> if ( ( $val <> "with" ) AND ( $val <> "from" ) ) {
>
> Ron
>
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info