php-general Digest 8 Apr 2010 11:42:47 -0000 Issue 6681

2010-04-08 Thread php-general-digest-help

php-general Digest 8 Apr 2010 11:42:47 - Issue 6681

Topics (messages 303875 through 303891):

Re: mysql query returning slowly
303875 by: David  Murphy

Re: Howto send command over ssh using sockets
303876 by: Thomas Anderson

Greate day for you,
303877 by: Chris G
303878 by: Daniel Brown
303879 by: Nilesh Govindarajan
303880 by: Bruno Fajardo
303881 by: Kevin Kinsey
303882 by: HallMarc Websites

Sort two coupled arrays
303883 by: tedd
303884 by: Piero Steinger
303885 by: Mattias Thorslund
303886 by: Paul M Foster
303887 by: Andrew Ballard
303888 by: Hans Åhlin

Re: Sort two coupled arrays {my solution]
303889 by: tedd
303890 by: Ryan Sun

Beginner's question: How to run a PHP web application locally?
303891 by: Bastien Helders

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


--
---BeginMessage---
Nathan,


The profiling I included proved that was not the case.

Mysql run the query and return the single column single  row result in under
1 second but  PHP's mysql-query waited much longer than that to return.  If
it was a big result set I could  see some slow down in parsing the results
into memory but  this wasn't the case. Updates/Deletes have similar random
timing  issues , and using mysql profiling, I can see its not transit or
lock or  clean up time from mysql - php , it is purely inside the php
mysql functions  the slow down seems to be occurs , but I can dive into
those as they are compiled modules not  userland functions.

-Original Message-

-Original Message-
From: Nathan Rixham [mailto:nrix...@gmail.com] 
Sent: Tuesday, April 06, 2010 6:35 PM
To: David Murphy
Cc: php-gene...@lists.php.net
Subject: Re: mysql query returning slowly

David Murphy wrote:
  
 This is from our application 
 I enabled profile in mysql to determine why an update took 20seconds.  As
 you can see  MySQL reported no where near that amount of duration took
 place. 
 Is there any way I can dig into php and determine why  mysql client libs
are
 so slow (this is not using mysqlnd but  mysql-client-libs on CentOS using
 5.3.2)
  
  
 04/06/2010 14:54:54 20.6899s

maybe it was waiting to acquire a lock

---End Message---
---BeginMessage---
phpseclib does SSH without PECL extension and only with fsockopen:

http://phpseclib.sourceforge.net/

On Sun Apr  4 21:09:54 2010, Hans_Åhlin wrote:
 Instead of ssh, you could use telnet to connect to the Cisco router
 (which incidentally runs on port 23, but is likely to be disabled on
 the cisco router, unless you have a pre-SSH capable IOS running on it
 (like my old cisco crap :( ) ), because i strongly doubt you have
 written or are willing to write your own encryption libraries for this
 project, you might also want to read IETF RFC 854
 [http://tools.ietf.org/html/rfc854] about the telnet protocol, as you
 are writing your own client, and not using a pre-made one, judging
 from your script.
 Or if you do not like the idea of sending clear-text passwords to the
 router, you might want to learn about proc_open() (or popen()) and use
 the native ssh utility that most likely is present on the server,
 taking great care to READ THE MANUAL for the ssh command, because you
 most likely do _not_ want it to spit out ANSI-escapes to you script.

 Kind regards from
 Johan Lidström
 Örnsköldsvik, Sweden
 irc://irc.freenode.net/Dr_Kao
 frozendude+php...@gmail.com

 P.S. currently borrowing a friends account.

 2010/4/5 Radek Krejča radek.kre...@starnet.cz:
 Hello,

 I am trying send command to remote host over ssh with sockets. But I need to 
 set up username/password. I am trying to modify this script (from 
 www.php.net - function fsockopen), but I dont know, where set 
 username/password because I got this message:
 Bad protocol version identification 'password' from ip

 Library ssh2 is not currentu userfull for me, because I am not admin of 
 server.

 Thank you
 Radek


 ?php
 /
 * Author: Richard Lajaunie
 * Mail : richard.lajau...@cote-azur.cci.fr
 *
 * subject : this script retreive all mac-addresses on all ports
 * of a Cisco 3548 Switch by a telnet connection
 *
 * base on the script by: xbensemhoun at t-systems dot fr on the same page
 **/

 if ( array_key_exists(1, $argv) ){
   $cfgServer = $argv[1];
 }else{
   echo ex: 'php test.php 10.0.0.0' \n;
   exit;
 }

 $cfgPort    = 23;                //port, 22 if SSH
 $cfgTimeOut = 10;

 $usenet = fsockopen($cfgServer, $cfgPort, $errno, $errstr), $cfgTimeOut);

 if(!$usenet){
       echo 

[PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Bastien Helders
Hi List,

The other day, I read an article that mentioned about a tool that would
permit to simulate a web environment for PHP, so that testing could be made
before uploading the page on the server. Unfortunately, I don't seem to find
the article again.

So here am I with this question: What should I need to set my test
environment? I'm working on Windows, but I'm all ears for solution on Linux
systems.

Best Regards,
Bastien


Re: [PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 13:42 +0200, Bastien Helders wrote:

 Hi List,
 
 The other day, I read an article that mentioned about a tool that would
 permit to simulate a web environment for PHP, so that testing could be made
 before uploading the page on the server. Unfortunately, I don't seem to find
 the article again.
 
 So here am I with this question: What should I need to set my test
 environment? I'm working on Windows, but I'm all ears for solution on Linux
 systems.
 
 Best Regards,
 Bastien


The easiest thing is to set up a local web server on your machine to
test with. This isn't as daunting as it sounds, as there are a lot of
ways you can get this set up with a minimum of fuss. The easiest to use
software I've used for Windows was EasyPHP, which is basically a WAMP
stack that is GUI all the way, allows easy add/drop of extra modules,
and now ever comes with an English installer (it used to be all in
French which made it a little tricky to understand!)

Otherwise, if you want to try the Linux route you can set this up on a
second machine, dual-boot with Windows or run inside a virtual machine
(Virtual Machine OSE is open source and free to use). I've not seen a
Linux distribution yet that didn't offer Apache and PHP. Generally a web
server will run something like Fedora, RedHat or CentOS, so using one of
those will get you a very similar set-up.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Midhun Girish
The best option in windows would be xampp or wamp same goes true
with linux.


Midhun Girish



On Thu, Apr 8, 2010 at 5:12 PM, Bastien Helders eldroskan...@gmail.com wrote:
 Hi List,

 The other day, I read an article that mentioned about a tool that would
 permit to simulate a web environment for PHP, so that testing could be made
 before uploading the page on the server. Unfortunately, I don't seem to find
 the article again.

 So here am I with this question: What should I need to set my test
 environment? I'm working on Windows, but I'm all ears for solution on Linux
 systems.

 Best Regards,
 Bastien


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



Re: [PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 17:24 +0530, Midhun Girish wrote:

 The best option in windows would be xampp or wamp same goes true
 with linux.
 
 
 Midhun Girish
 
 
 
 On Thu, Apr 8, 2010 at 5:12 PM, Bastien Helders eldroskan...@gmail.com 
 wrote:
  Hi List,
 
  The other day, I read an article that mentioned about a tool that would
  permit to simulate a web environment for PHP, so that testing could be made
  before uploading the page on the server. Unfortunately, I don't seem to find
  the article again.
 
  So here am I with this question: What should I need to set my test
  environment? I'm working on Windows, but I'm all ears for solution on Linux
  systems.
 
  Best Regards,
  Bastien
 
 


I'm not too sure that WAMP would be the best option for Linux :p

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread Andrew Ballard
On Wed, Apr 7, 2010 at 6:46 PM, Ryan Sun ryansu...@gmail.com wrote:
 On Wed, Apr 7, 2010 at 6:29 PM, tedd tedd.sperl...@gmail.com wrote:

[snip]


 Let's look at the problem again (a vote collection problem):

 Array 1
 (
    [1] = 75
    [2] = 31
    [3] = 31
    [4] = 31
    [5] = 40
 )

 Array 1 is an array that contains the count of votes ($votes[] ) for the
 index. IOW, index 1 received 75 votes.

 Array 2
 (
    [1] = Personal Email
    [2] = Personal Phone
    [3] = Web site
    [4] = Text Message
    [5] = USPS mail
 )

 Array 2 is an array that contains the names for the items ($items[] ) voted
 upon. As such, index 1 (Personal Email) received 75 votes.

[snip]

 rsort(array_combine(array2, array1));

 you should expect array(
  'Personal Email' = 75,
  'USPS mail' = 40,
  'Personal Phone' = 31,
  'Web site' = 31,
  'Text Message' = 31
 )

 logically, the items are your key but not the count of votes


That's the ticket. The solution is pretty simple now that we
understand the nature of the problem.  :-)

Andrew

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



Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread tedd

At 6:46 PM -0400 4/7/10, Ryan Sun wrote:

rsort(array_combine(array2, array1));

you should expect array(
  'Personal Email' = 75,
  'USPS mail' = 40,
  'Personal Phone' = 31,
  'Web site' = 31,
  'Text Message' = 31
)

logically, the items are your key but not the count of votes



Logically, combine_array() will work to combine the two arrays as you 
said, as shown here:


http://www.webbytedd.com//array-combine/

I've tried rsort(), but is does not solve the problem presented, 
which was to sort the items depending upon their values.


Thus far, my solution is the only one that works.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread tedd

At 8:28 AM -0400 4/8/10, Andrew Ballard wrote:

On Wed, Apr 7, 2010 at 6:46 PM, Ryan Sun ryansu...@gmail.com wrote:

 

 rsort(array_combine(array2, array1));

 you should expect array(
  'Personal Email' = 75,
  'USPS mail' = 40,
  'Personal Phone' = 31,
  'Web site' = 31,
  'Text Message' = 31
 )

 logically, the items are your key but not the count of votes



That's the ticket. The solution is pretty simple now that we
understand the nature of the problem.  :-)

Andrew


Andrew:

Half the solution is understanding the problem.

However, the above solution only solves half the problem.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Beginner's question: How to run a PHP web application locally?

2010-04-08 Thread Tom Calpin
 Hi List,

 

 The other day, I read an article that mentioned about a tool that would

 permit to simulate a web environment for PHP, so that testing could be
made

 before uploading the page on the server. Unfortunately, I don't seem to
find

 the article again.

 

 So here am I with this question: What should I need to set my test

 environment? I'm working on Windows, but I'm all ears for solution on
Linux

 systems.

 

 Best Regards,

 Bastien

 

 

A couple of IDEs have web servers built in (NuSphere PhpED is the only one I
can remember at the moment) which can generally be used to preview your
applications offline, although you might struggle to get it running if it
requires a database connection, depending on your hosting config (my hosting
will only allow local connections to the DB). 

 

Alternatively, something like EasyPHP http://www.easyphp.org/ makes it very
easy to get a LAMP server set-up going on your machine, so you could drop
your app into the www folder and navigate to localhost on your web browser
to view it. Stick some dummy data in the db and you have a fully functional
version of your app running on your machine.



Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread Andrew Ballard
On Thu, Apr 8, 2010 at 9:55 AM, tedd tedd.sperl...@gmail.com wrote:
 At 8:28 AM -0400 4/8/10, Andrew Ballard wrote:

 On Wed, Apr 7, 2010 at 6:46 PM, Ryan Sun ryansu...@gmail.com wrote:

  

  rsort(array_combine(array2, array1));

  you should expect array(
  'Personal Email' = 75,
  'USPS mail' = 40,
  'Personal Phone' = 31,
  'Web site' = 31,
  'Text Message' = 31
  )

  logically, the items are your key but not the count of votes


 That's the ticket. The solution is pretty simple now that we
 understand the nature of the problem.  :-)

 Andrew

 Andrew:

 Half the solution is understanding the problem.

 However, the above solution only solves half the problem.

 Cheers,

 tedd
 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com


Yes, but looking for alternative array sorts in the manual will lead
you to arsort().  :-)

?php

$a = array
(
  1 = '75',
  2 = '31',
  3 = '31',
  4 = '31',
  5 = '40',
);

$b = array
(
  1 = 'Personal Email',
  2 = 'Personal Phone',
  3 = 'Web site',
  4 = 'Text Message',
  5 = 'USPS mail',
);

$x = array_combine($b, $a);
var_export($x);
/*
array (
  'Personal Email' = '75',
  'Personal Phone' = '31',
  'Web site' = '31',
  'Text Message' = '31',
  'USPS mail' = '40',
)
*/

echo \n;

arsort($x);

var_export($x);
/*
array (
  'Personal Email' = '75',
  'USPS mail' = '40',
  'Text Message' = '31',
  'Web site' = '31',
  'Personal Phone' = '31',
)
*/

?

Andrew

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



[PHP] Little php code - error

2010-04-08 Thread Juan
Hi guys,
I'm having trouble with the following little php code [0]. The output
from the server is : 
* Parse error: syntax error, unexpected '{' in file.php on line 27 *

Let's assume that file.php is the file that is giving me some troubles.

The structure is pretty easy to understand, however I'm not able to
solve this. Could you tell me why I'm not able to run this code.

I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you could see.

Thanks a lot,
Juan

[0] http://pastebin.com/xC4pFbfH

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



Re: [PHP] Little php code - error

2010-04-08 Thread Devendra Jadhav
Can you paste your code somewhere?

On Thu, Apr 8, 2010 at 7:51 PM, Juan j...@rodriguezmonti.com.ar wrote:

 Hi guys,
 I'm having trouble with the following little php code [0]. The output
 from the server is : 
 * Parse error: syntax error, unexpected '{' in file.php on line 27 *

 Let's assume that file.php is the file that is giving me some troubles.

 The structure is pretty easy to understand, however I'm not able to
 solve this. Could you tell me why I'm not able to run this code.

 I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you could see.

 Thanks a lot,
 Juan

 [0] http://pastebin.com/xC4pFbfH

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




-- 
Devendra Jadhav
देवेंद्र जाधव


Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread Robert Cummings

tedd wrote:

At 8:28 AM -0400 4/8/10, Andrew Ballard wrote:

On Wed, Apr 7, 2010 at 6:46 PM, Ryan Sun ryansu...@gmail.com wrote:

 

 rsort(array_combine(array2, array1));

 you should expect array(
  'Personal Email' = 75,
  'USPS mail' = 40,
  'Personal Phone' = 31,
  'Web site' = 31,
  'Text Message' = 31
 )

 logically, the items are your key but not the count of votes


That's the ticket. The solution is pretty simple now that we
understand the nature of the problem.  :-)

Andrew


Andrew:

Half the solution is understanding the problem.

However, the above solution only solves half the problem.


Maybe I'm confused... but can't the following be used?

?php

array_multisort( $votes, SORT_DESC, $items, SORT_DESC );
$final = array_combine( $items, $votes );

print_r( $final );

?

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Little php code - error

2010-04-08 Thread Dan Joseph
On Thu, Apr 8, 2010 at 10:21 AM, Juan j...@rodriguezmonti.com.ar wrote:

 Hi guys,
 I'm having trouble with the following little php code [0]. The output
 from the server is : 
 * Parse error: syntax error, unexpected '{' in file.php on line 27 *

 Let's assume that file.php is the file that is giving me some troubles.

 The structure is pretty easy to understand, however I'm not able to
 solve this. Could you tell me why I'm not able to run this code.

 I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you could see.



Its your if's, elseif's, else's.  You have and, change that to .

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code NEWTHINGS for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Little php code - error

2010-04-08 Thread Dan Joseph
On Thu, Apr 8, 2010 at 10:21 AM, Juan j...@rodriguezmonti.com.ar wrote:

 Hi guys,
 I'm having trouble with the following little php code [0]. The output
 from the server is : 
 * Parse error: syntax error, unexpected '{' in file.php on line 27 *


Sorry, I gave you bad information...

Its the else line.  else doesn't take a condition after it.  it should just
be else {.

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code NEWTHINGS for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Little php code - error

2010-04-08 Thread David Otton
On 8 April 2010 15:21, Juan j...@rodriguezmonti.com.ar wrote:

 The structure is pretty easy to understand, however I'm not able to
 solve this. Could you tell me why I'm not able to run this code.

Your else has a condition on it

} else (empty($b) and empty($c)) {

Should be

} else {

BTW, the and is fine.

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



Re: [PHP] Little php code - error

2010-04-08 Thread Peter Lind
On 8 April 2010 16:30, David Otton phpm...@jawbone.freeserve.co.uk wrote:
 On 8 April 2010 15:21, Juan j...@rodriguezmonti.com.ar wrote:

 The structure is pretty easy to understand, however I'm not able to
 solve this. Could you tell me why I'm not able to run this code.

 Your else has a condition on it

 } else (empty($b) and empty($c)) {

 Should be

 } else {

Unless he actually wants to do something with that condition, in which
case it should be an elseif.

 BTW, the and is fine.

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





-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP] Little php code - error

2010-04-08 Thread Richard Quadling
On 8 April 2010 15:21, Juan j...@rodriguezmonti.com.ar wrote:
 Hi guys,
 I'm having trouble with the following little php code [0]. The output
 from the server is : 
 * Parse error: syntax error, unexpected '{' in file.php on line 27 *

 Let's assume that file.php is the file that is giving me some troubles.

 The structure is pretty easy to understand, however I'm not able to
 solve this. Could you tell me why I'm not able to run this code.

 I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you could see.

 Thanks a lot,
 Juan

 [0] http://pastebin.com/xC4pFbfH

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



http://pastebin.com/diff.php?i=2QbANWnS

-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Little php code - error

2010-04-08 Thread Richard Quadling
On 8 April 2010 15:21, Juan j...@rodriguezmonti.com.ar wrote:
 Hi guys,
 I'm having trouble with the following little php code [0]. The output
 from the server is : 
 * Parse error: syntax error, unexpected '{' in file.php on line 27 *

 Let's assume that file.php is the file that is giving me some troubles.

 The structure is pretty easy to understand, however I'm not able to
 solve this. Could you tell me why I'm not able to run this code.

 I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you could see.

 Thanks a lot,
 Juan

 [0] http://pastebin.com/xC4pFbfH

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



http://pastebin.com/sUf2pxnW

-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Little php code - error

2010-04-08 Thread Juan
2010/4/8 Richard Quadling rquadl...@googlemail.com:
 On 8 April 2010 15:21, Juan j...@rodriguezmonti.com.ar wrote:
 Hi guys,
 I'm having trouble with the following little php code [0]. The output
 from the server is : 
 * Parse error: syntax error, unexpected '{' in file.php on line 27 *

 Let's assume that file.php is the file that is giving me some troubles.

 The structure is pretty easy to understand, however I'm not able to
 solve this. Could you tell me why I'm not able to run this code.

 I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you could see.

 Thanks a lot,
 Juan

 [0] http://pastebin.com/xC4pFbfH

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



 http://pastebin.com/diff.php?i=2QbANWnS

Thanks a lot people!.

It's solved.

Juan

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



Re: [PHP] Little php code - error

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 12:17 -0300, Juan wrote:

 2010/4/8 Richard Quadling rquadl...@googlemail.com:
  On 8 April 2010 15:21, Juan j...@rodriguezmonti.com.ar wrote:
  Hi guys,
  I'm having trouble with the following little php code [0]. The output
  from the server is : 
  * Parse error: syntax error, unexpected '{' in file.php on line 27 *
 
  Let's assume that file.php is the file that is giving me some troubles.
 
  The structure is pretty easy to understand, however I'm not able to
  solve this. Could you tell me why I'm not able to run this code.
 
  I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you could see.
 
  Thanks a lot,
  Juan
 
  [0] http://pastebin.com/xC4pFbfH
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
  http://pastebin.com/diff.php?i=2QbANWnS
 
 Thanks a lot people!.
 
 It's solved.
 
 Juan
 


The easiest way to spot these sorts of problems is by indenting the code
so that the opening brace matches up with the closing one:

function
{
if(condition)
{
statement
}
else
{
foreach(var as var2)
{
more statements
}
}
}

Yes, it takes up a lot more lines, but a few line break characters
aren't going to impact on the size of the file, and all the while it's
very easy to read. If you've accidentally missed out a closing brace
you'll spot it immediately.

It's called the Allman style and has another advantage. Consider:

if(condition)
{
statement
}

You can comment out the if statement and the braces won't cause an
error:

//if(condition)
{
statement
}

Whereas doing the same with the BSD KNF style that many favour you would
hit a problem of mismatched braces:

//if(condition){
statement
}


Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Little php code - error

2010-04-08 Thread Paul M Foster
On Thu, Apr 08, 2010 at 04:26:08PM +0100, Ashley Sheridan wrote:

 On Thu, 2010-04-08 at 12:17 -0300, Juan wrote:
 
  2010/4/8 Richard Quadling rquadl...@googlemail.com:
   On 8 April 2010 15:21, Juan j...@rodriguezmonti.com.ar wrote:
   Hi guys,
   I'm having trouble with the following little php code [0]. The output
   from the server is : 
   * Parse error: syntax error, unexpected '{' in file.php on line 27 *
  
   Let's assume that file.php is the file that is giving me some troubles.
  
   The structure is pretty easy to understand, however I'm not able to
   solve this. Could you tell me why I'm not able to run this code.
  
   I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you
 could see.
  
   Thanks a lot,
   Juan
  
   [0] http://pastebin.com/xC4pFbfH
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
   http://pastebin.com/diff.php?i=2QbANWnS
 
  Thanks a lot people!.
 
  It's solved.
 
  Juan
 
 
 
 The easiest way to spot these sorts of problems is by indenting the code
 so that the opening brace matches up with the closing one:
 
 function
 {
 if(condition)
 {
 statement
 }
 else
 {
 foreach(var as var2)
 {
 more statements
 }
 }
 }
 
 Yes, it takes up a lot more lines, but a few line break characters
 aren't going to impact on the size of the file, and all the while it's
 very easy to read. If you've accidentally missed out a closing brace
 you'll spot it immediately.
 
 It's called the Allman style and has another advantage. Consider:

While we all love Ash, he is a blasphemer, as he argues against the One
True Style, which is KR. (Please forgive him, Lords Kernighan and
Richie). ;-}

In the OP's case, his error was syntax (a condition after an else
clause). But I don't know that even a syntax-highlighting editor would
have caught his error.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Little php code - error

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 12:00 -0400, Paul M Foster wrote:

 On Thu, Apr 08, 2010 at 04:26:08PM +0100, Ashley Sheridan wrote:
 
  On Thu, 2010-04-08 at 12:17 -0300, Juan wrote:
  
   2010/4/8 Richard Quadling rquadl...@googlemail.com:
On 8 April 2010 15:21, Juan j...@rodriguezmonti.com.ar wrote:
Hi guys,
I'm having trouble with the following little php code [0]. The output
from the server is : 
* Parse error: syntax error, unexpected '{' in file.php on line 27 *
   
Let's assume that file.php is the file that is giving me some troubles.
   
The structure is pretty easy to understand, however I'm not able to
solve this. Could you tell me why I'm not able to run this code.
   
I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you
  could see.
   
Thanks a lot,
Juan
   
[0] http://pastebin.com/xC4pFbfH
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   
   
   
http://pastebin.com/diff.php?i=2QbANWnS
  
   Thanks a lot people!.
  
   It's solved.
  
   Juan
  
  
  
  The easiest way to spot these sorts of problems is by indenting the code
  so that the opening brace matches up with the closing one:
  
  function
  {
  if(condition)
  {
  statement
  }
  else
  {
  foreach(var as var2)
  {
  more statements
  }
  }
  }
  
  Yes, it takes up a lot more lines, but a few line break characters
  aren't going to impact on the size of the file, and all the while it's
  very easy to read. If you've accidentally missed out a closing brace
  you'll spot it immediately.
  
  It's called the Allman style and has another advantage. Consider:
 
 While we all love Ash, he is a blasphemer, as he argues against the One
 True Style, which is KR. (Please forgive him, Lords Kernighan and
 Richie). ;-}
 
 In the OP's case, his error was syntax (a condition after an else
 clause). But I don't know that even a syntax-highlighting editor would
 have caught his error.
 
 Paul
 
 -- 
 Paul M. Foster
 


Blaspheme is a little strong :p

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] contant /

2010-04-08 Thread Jack
I get a couple of errors like this one for undefined variable:

PHP Notice:  Undefined variable: s_company_name

And this one for undefined contstant

PHP Notice:  Use of undefined constant account_type - assumed 'account_type'

 

I am putting a piece of code from each so that hopefully someone can explain
what I need to do to correct this, I know it still runs OK, but want to
eliminate error/warnings as much as possible.

 

 

CONSTANT CODE:

if($_POST) {

 

 

   if($username  $password)

  {

  f_db_open();

  $q = mysql_query(SELECT * FROM uas_users WHERE
user_email='$username');

  $auth = mysql_fetch_array($q);

 

  if($auth['user_password'] == $password  $auth['user_email'] ==
$username  $auth['account_status'] == Approved)

 {

 

 

 $type = $auth['account_type'];

 

   mysql_query(INSERT INTO logon_log (user, date, time)
VALUES ('$username', NOW(), NOW()));

 

 
f_put_cookie($auth[user_name],$auth[user_email],$auth[account_type],$auth[co
mpany_name]);

 

 

VARIABLE CODE:

function f_option_menu($status_message ) {

global $s_url, $s_logo, $s_logo_h, $s_logo_w;

 

echo 

table border='0' width='100%' cellpadding='0' cellspacing='0'

  tr

td

  img border=0 src='images/.$s_logo.' width=.$s_logo_w.
height=.$s_logo_h.

  font face='Verdana, Arial' size='3'b.$s_company_name.
.$status_message./b/font

 

 

THANKS

 

 

 

Thanks!

Jack

 



Re: [PHP] contant /

2010-04-08 Thread Dan Joseph
On Thu, Apr 8, 2010 at 12:26 PM, Jack jacklistm...@gmail.com wrote:

 I get a couple of errors like this one for undefined variable:

 PHP Notice:  Undefined variable: s_company_name

 And this one for undefined contstant

 PHP Notice:  Use of undefined constant account_type - assumed
 'account_type'


f_put_cookie($auth[user_name],$auth[user_email],$auth[account_type],$auth[co
mpany_name]);

That's your culprit.  You'll need quotes around those.  $auth[username],
user_email, account_type, company_name

Otherwise, it thinks they are constants that haven't been defined:
php.net/define

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code NEWTHINGS for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] contant /

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 12:26 -0400, Jack wrote:

 I get a couple of errors like this one for undefined variable:
 
 PHP Notice:  Undefined variable: s_company_name
 
 And this one for undefined contstant
 
 PHP Notice:  Use of undefined constant account_type - assumed 'account_type'
 
  
 
 I am putting a piece of code from each so that hopefully someone can explain
 what I need to do to correct this, I know it still runs OK, but want to
 eliminate error/warnings as much as possible.
 
  
 
 
 
 CONSTANT CODE:
 
 if($_POST) {
 
  
 
 
 
if($username  $password)
 
   {
 
   f_db_open();
 
   $q = mysql_query(SELECT * FROM uas_users WHERE
 user_email='$username');
 
   $auth = mysql_fetch_array($q);
 
  
 
   if($auth['user_password'] == $password  $auth['user_email'] ==
 $username  $auth['account_status'] == Approved)
 
  {
 
  
 
 
 
  $type = $auth['account_type'];
 
  
 
mysql_query(INSERT INTO logon_log (user, date, time)
 VALUES ('$username', NOW(), NOW()));
 
  
 
 
 f_put_cookie($auth[user_name],$auth[user_email],$auth[account_type],$auth[co
 mpany_name]);
 
  
 
 
 
 VARIABLE CODE:
 
 function f_option_menu($status_message ) {
 
 global $s_url, $s_logo, $s_logo_h, $s_logo_w;
 
  
 
 echo 
 
 table border='0' width='100%' cellpadding='0' cellspacing='0'
 
   tr
 
 td
 
   img border=0 src='images/.$s_logo.' width=.$s_logo_w.
 height=.$s_logo_h.
 
   font face='Verdana, Arial' size='3'b.$s_company_name.
 .$status_message./b/font
 
  
 
 
 
 THANKS
 
  
 
 
 
 
 
 Thanks!
 
 Jack
 
  
 

Your function f_option_menu() includes some global variables but nowhere
in that function is s_company_name ever declared, so PHP is throwing an
undefined warning at you.

Also, it appears that you are referencing $_POST variables as globals.
It's recommended that you turn off register_globals, as this can be a
massive security risk if someone overrides one of your variables by
sending their own data at your form. The preferred way is to reference
the variables as $_POST['variable_name']

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] contant /

2010-04-08 Thread Andre Polykanine
Hello Jack,

I have tons of errors like this and now I'm eliminating them, so I'll
tell what to do:
1. Put apostrophes (single quotes) around the array item:
$auth['company_name'] instead of $auth[company_name];
2. (Just a suggestion) It's better to put the SQL tables and
fields between grave accents (backquotes).

-- 
With best regards from Ukraine,
Andre
Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

- Original message -
From: Jack jacklistm...@gmail.com
To: php-general@lists.php.net php-general@lists.php.net
Date: Thursday, April 8, 2010, 7:26:56 PM
Subject: [PHP] contant /

I get a couple of errors like this one for undefined variable:

PHP Notice:  Undefined variable: s_company_name

And this one for undefined contstant

PHP Notice:  Use of undefined constant account_type - assumed 'account_type'

 

I am putting a piece of code from each so that hopefully someone can explain
what I need to do to correct this, I know it still runs OK, but want to
eliminate error/warnings as much as possible.

 

 

CONSTANT CODE:

if($_POST) {

 

 

   if($username  $password)

  {

  f_db_open();

  $q = mysql_query(SELECT * FROM uas_users WHERE
user_email='$username');

  $auth = mysql_fetch_array($q);

 

  if($auth['user_password'] == $password  $auth['user_email'] ==
$username  $auth['account_status'] == Approved)

 {

 

 

 $type = $auth['account_type'];

 

   mysql_query(INSERT INTO logon_log (user, date, time)
VALUES ('$username', NOW(), NOW()));

 

 
f_put_cookie($auth[user_name],$auth[user_email],$auth[account_type],$auth[co
mpany_name]);

 

 

VARIABLE CODE:

function f_option_menu($status_message ) {

global $s_url, $s_logo, $s_logo_h, $s_logo_w;

 

echo 

table border='0' width='100%' cellpadding='0' cellspacing='0'

  tr

td

  img border=0 src='images/.$s_logo.' width=.$s_logo_w.
height=.$s_logo_h.

  font face='Verdana, Arial' size='3'b.$s_company_name.
.$status_message./b/font

 

 

THANKS

 

 

 

Thanks!

Jack

 



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



Re: [PHP] contant /

2010-04-08 Thread John Black

On 04/08/2010 06:51 PM, Andre Polykanine wrote:
 2. (Just a suggestion) It's better to put the SQL tables and
 fields between grave accents (backquotes).

But if you do that then you will have to remove them again when you 
decide to switch or support PostgreSQL.


--
John
After coming into contact with a religious man I always feel I must wash 
my hands.

[Friedrich Nietzsche]

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



[PHP] No notices for undefined index

2010-04-08 Thread Shawn McKenzie
So the first two print statements generate NO notices, while the second
obviously generates:

Notice: Undefined offset:  1 in /home/shawn/www/test.php on line 11

Notice: Undefined index:  test in /home/shawn/www/test.php on line 12

This sucks.  A bug???

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


$a = 5;
print $a[1];
print $a['test'];

$a = array();
print $a[1];
print $a['test'];

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

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



Re: [PHP] No notices for undefined index

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 12:36 -0500, Shawn McKenzie wrote:

 So the first two print statements generate NO notices, while the second
 obviously generates:
 
 Notice: Undefined offset:  1 in /home/shawn/www/test.php on line 11
 
 Notice: Undefined index:  test in /home/shawn/www/test.php on line 12
 
 This sucks.  A bug???
 
 error_reporting(E_ALL);
 ini_set('display_errors', '1');
 
 
 $a = 5;
 print $a[1];
 print $a['test'];
 
 $a = array();
 print $a[1];
 print $a['test'];
 
 -- 
 Thanks!
 -Shawn
 http://www.spidean.com
 


I think this goes back to the C style strings, where a string is just a
collection of characters. I've noticed that in PHP you can treat a
string as if it were an array of characters, so I guess in both cases
above, it would be trying to return the second character, which is the
termination character or a chr(0).

In the second example, you've explicitely declared $a to be an array, so
PHP creates a proper index for it, and then when you ask for an element
that is not in that index list, it throws a notice at you.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] No notices for undefined index

2010-04-08 Thread Andre Polykanine
Hello Shawn,

Hm... isn't it expected behavior? Since you haven't defined a
$a['test'] item, PHP throws a notice... or I'm wrong?
-- 
With best regards from Ukraine,
Andre
Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

- Original message -
From: Shawn McKenzie nos...@mckenzies.net
To: php-general@lists.php.net php-general@lists.php.net
Date: Thursday, April 8, 2010, 8:36:21 PM
Subject: [PHP] No notices for undefined index

So the first two print statements generate NO notices, while the second
obviously generates:

Notice: Undefined offset:  1 in /home/shawn/www/test.php on line 11

Notice: Undefined index:  test in /home/shawn/www/test.php on line 12

This sucks.  A bug???

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


$a = 5;
print $a[1];
print $a['test'];

$a = array();
print $a[1];
print $a['test'];

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

-- 
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



RE: [PHP] No notices for undefined index

2010-04-08 Thread Bob McConnell
In the first case, $a=5 creates a multi-typed variable. The interpreter
makes its best guess how the next two expressions should be interpreted.
In both cases, they look a lot like an index into a character array
(string), and 'test' evaluates numerically to zero. Both are valid
offsets for a string, so no messages are generated.

In the second case, $a is explicitly declared as an array. This give the
interpreter a lot more detail to work from. The two expressions are now
an index and a key for the array. But both of them evaluate to offsets
that have not been assigned, which raises a flag and creates the
warnings.

Such are the joys of loosely typed languages.

Bob McConnell

-Original Message-
From: Andre Polykanine [mailto:an...@oire.org] 
Sent: Thursday, April 08, 2010 1:45 PM
To: Shawn McKenzie
Cc: php-general@lists.php.net
Subject: Re: [PHP] No notices for undefined index

Hello Shawn,

Hm... isn't it expected behavior? Since you haven't defined a
$a['test'] item, PHP throws a notice... or I'm wrong?
-- 
With best regards from Ukraine,
Andre
Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

- Original message -
From: Shawn McKenzie nos...@mckenzies.net
To: php-general@lists.php.net php-general@lists.php.net
Date: Thursday, April 8, 2010, 8:36:21 PM
Subject: [PHP] No notices for undefined index

So the first two print statements generate NO notices, while the second
obviously generates:

Notice: Undefined offset:  1 in /home/shawn/www/test.php on line 11

Notice: Undefined index:  test in /home/shawn/www/test.php on line 12

This sucks.  A bug???

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


$a = 5;
print $a[1];
print $a['test'];

$a = array();
print $a[1];
print $a['test'];

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

-- 
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



Re: [PHP] Little php code - error

2010-04-08 Thread Jim Lucas
Paul M Foster wrote:
 On Thu, Apr 08, 2010 at 04:26:08PM +0100, Ashley Sheridan wrote:
 
 On Thu, 2010-04-08 at 12:17 -0300, Juan wrote:

 2010/4/8 Richard Quadling rquadl...@googlemail.com:
 On 8 April 2010 15:21, Juan j...@rodriguezmonti.com.ar wrote:
 Hi guys,
 I'm having trouble with the following little php code [0]. The output
 from the server is : 
 * Parse error: syntax error, unexpected '{' in file.php on line 27 *

 Let's assume that file.php is the file that is giving me some troubles.

 The structure is pretty easy to understand, however I'm not able to
 solve this. Could you tell me why I'm not able to run this code.

 I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you
 could see.
 Thanks a lot,
 Juan

 [0] http://pastebin.com/xC4pFbfH

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


 http://pastebin.com/diff.php?i=2QbANWnS
 Thanks a lot people!.

 It's solved.

 Juan


 The easiest way to spot these sorts of problems is by indenting the code
 so that the opening brace matches up with the closing one:

 function
 {
 if(condition)
 {
 statement
 }
 else
 {
 foreach(var as var2)
 {
 more statements
 }
 }
 }

 Yes, it takes up a lot more lines, but a few line break characters
 aren't going to impact on the size of the file, and all the while it's
 very easy to read. If you've accidentally missed out a closing brace
 you'll spot it immediately.

 It's called the Allman style and has another advantage. Consider:
 
 While we all love Ash, he is a blasphemer, as he argues against the One
 True Style, which is KR. (Please forgive him, Lords Kernighan and
 Richie). ;-}
 
 In the OP's case, his error was syntax (a condition after an else
 clause). But I don't know that even a syntax-highlighting editor would
 have caught his error.
 
 Paul
 

The syntax highlighters that I use didn't recognize it as a problem.  They
styled it right up...
-- 
Jim Lucas
NOC Manager
541-323-9113
BendTel, Inc.
http://www.bendtel.com

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



[PHP] APC with horde/imp: 99.9% miss rate and only one cached file

2010-04-08 Thread Derek Chen-Becker
I suspect I've either done something horribly wrong or found a weird
bug, probably the former. I'm running PHP 5.2.13 on Solaris 10 under
Apache 2.2.14. Memory usage is 98.8% free (default 1 slice of 30MB).
Here are stats on the cache:

Cached Files1 (288.2 KBytes)
Hits4146
Misses  3579033
Request Rate (hits, misses) 358.68 cache requests/second
Hit Rate0.42 cache requests/second
Miss Rate   358.26 cache requests/second
Insert Rate 0.00 cache requests/second
Cache full count0

And here is my config in php.ini:

extension=apc.so
error_reporting = E_ALL ^ E_DEPRECATED
apc.report_autofilter = 1
log_errors = 1

If I restart apache, a different file gets cached each time (it rotates
between a very small subset of all of the PHP files in horde).
Sometimes, 2 or even 3 files get cached, but I've never had it go above
3. I've been googling around and reading the list archives but I can't
find anything that seems to be related to this. Am I misunderstanding
the purpose of APC? I thought that it would attempt to cache all PHP
files that are requested.

I turned on the report_autofilter in an attempt to diagnose the issue,
but nothing shows up in the error log. Here is the config as shown by
apc.php:

apc.cache_by_default1
apc.canonicalize1
apc.coredump_unmap  0
apc.enable_cli  0
apc.enabled 1
apc.file_md50
apc.file_update_protection  2
apc.filters 
apc.gc_ttl  3600
apc.include_once_override   0
apc.lazy_classes0
apc.lazy_functions  0
apc.max_file_size   1M
apc.mmap_file_mask  
apc.num_files_hint  1000
apc.preload_path
apc.report_autofilter   1
apc.rfc1867 0
apc.rfc1867_freq0
apc.rfc1867_nameAPC_UPLOAD_PROGRESS
apc.rfc1867_prefix  upload_
apc.rfc1867_ttl 3600
apc.shm_segments1
apc.shm_size30
apc.stat1
apc.stat_ctime  0
apc.ttl 0
apc.use_request_time1
apc.user_entries_hint   4096
apc.user_ttl0
apc.write_lock  1


Any help would be greatly appreciated.

Thanks,

Derek

-- 
--
Derek Chen-Becker
Senior Network Engineer, Security Architect
CPI Corp, Inc.
1706 Washington Ave
St. Louis, MO 63103
Phone: 314-231-7711 x6455
Fax:   314-613-6724
dbec...@cpicorp.com
PGP Key available from public key servers
Fingerprint: E4C4 26C0 8588 E80A C29F  636D 1FBE 0FE3 2871 4AE8
--

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



Re: [PHP] No notices for undefined index

2010-04-08 Thread Shawn McKenzie
Andre Polykanine wrote:
 Hello Shawn,
 
 Hm... isn't it expected behavior? Since you haven't defined a
 $a['test'] item, PHP throws a notice... or I'm wrong?

Yes it is expected.  I'm saying the opposite that it doesn't in the
first case.

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

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



Re: [PHP] No notices for undefined index

2010-04-08 Thread Shawn McKenzie
Bob McConnell wrote:
 In the first case, $a=5 creates a multi-typed variable. The interpreter
 makes its best guess how the next two expressions should be interpreted.
 In both cases, they look a lot like an index into a character array
 (string), and 'test' evaluates numerically to zero. Both are valid
 offsets for a string, so no messages are generated.
 
 In the second case, $a is explicitly declared as an array. This give the
 interpreter a lot more detail to work from. The two expressions are now
 an index and a key for the array. But both of them evaluate to offsets
 that have not been assigned, which raises a flag and creates the
 warnings.
 
 Such are the joys of loosely typed languages.
 
 Bob McConnell

Yes, this is what I was thinking as well, however:

$a=5;
print $a[0];   // if it is index 0 then it should print 5 yes?
print $a[100]; // there is no index 100 so why no notice?

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

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



Re: [PHP] No notices for undefined index

2010-04-08 Thread Shawn McKenzie
Shawn McKenzie wrote:
 Bob McConnell wrote:
 In the first case, $a=5 creates a multi-typed variable. The interpreter
 makes its best guess how the next two expressions should be interpreted.
 In both cases, they look a lot like an index into a character array
 (string), and 'test' evaluates numerically to zero. Both are valid
 offsets for a string, so no messages are generated.

 In the second case, $a is explicitly declared as an array. This give the
 interpreter a lot more detail to work from. The two expressions are now
 an index and a key for the array. But both of them evaluate to offsets
 that have not been assigned, which raises a flag and creates the
 warnings.

 Such are the joys of loosely typed languages.

 Bob McConnell
 
 Yes, this is what I was thinking as well, however:
 
 $a=5;
 print $a[0];   // if it is index 0 then it should print 5 yes?
 print $a[100]; // there is no index 100 so why no notice?
 

$a='5';
print $a[0];   // prints 5
print $a[100]; // Notice: Uninitialized string offset:  100

So it seems, in the first case with the integer 5 that the interpreter
is saying:

- Since $a is not an array I'll treat $a[0] and $a[100] as a string
offset, but since $a is not a string I won't do anything.

Just seems stupid IMHO.

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

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



Re: [PHP] Who uses Mantis, please help!

2010-04-08 Thread Jonathan Vivero
Review your mantis mail settings. If I remember well, there are two
possibilities, direct (pop3) mail or phpmailer. In www.mantisbt.org you can
find all information you need. I've been in the same situation, and found
out how to resolve it with success.


2010/4/7 Paul M Foster pa...@quillandmouse.com

 On Wed, Apr 07, 2010 at 03:37:07PM +0300, Andre Polykanine wrote:

  Hello everyone,
  I decided to use Mantis before I'll be able to use something like Trac
  :-).
  The problem is: I'm not getting mail about issues reported by my
  testers, only by myself. The preferences are set correctly (all the
  checkboxes are checked).
  Could you help me please?
  Thanks!

 Isn't there a Mantis list or forum?

 Paul

 --
 Paul M. Foster

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




Re: [PHP] No notices for undefined index

2010-04-08 Thread Ashley Sheridan
On Thu, 2010-04-08 at 15:22 -0500, Shawn McKenzie wrote:

 Shawn McKenzie wrote:
  Bob McConnell wrote:
  In the first case, $a=5 creates a multi-typed variable. The interpreter
  makes its best guess how the next two expressions should be interpreted.
  In both cases, they look a lot like an index into a character array
  (string), and 'test' evaluates numerically to zero. Both are valid
  offsets for a string, so no messages are generated.
 
  In the second case, $a is explicitly declared as an array. This give the
  interpreter a lot more detail to work from. The two expressions are now
  an index and a key for the array. But both of them evaluate to offsets
  that have not been assigned, which raises a flag and creates the
  warnings.
 
  Such are the joys of loosely typed languages.
 
  Bob McConnell
  
  Yes, this is what I was thinking as well, however:
  
  $a=5;
  print $a[0];   // if it is index 0 then it should print 5 yes?
  print $a[100]; // there is no index 100 so why no notice?
  
 
 $a='5';
 print $a[0];   // prints 5
 print $a[100]; // Notice: Uninitialized string offset:  100
 
 So it seems, in the first case with the integer 5 that the interpreter
 is saying:
 
 - Since $a is not an array I'll treat $a[0] and $a[100] as a string
 offset, but since $a is not a string I won't do anything.
 
 Just seems stupid IMHO.
 
 -- 
 Thanks!
 -Shawn
 http://www.spidean.com
 


I think it just returns null if the offset goes beyond the length of the
string. In C and C++ doing something like this would take you beyond
that variables memory allocation into neighbouring variables. I believe
PHP is trying to prevent problems where that might occur by returning
null instead.

This is only conjecture as I don't know exactly what happens, and I
can't find anything in the manual that explains what should happen when
you treat a string like an array in PHP. However, throwing some sort of
error or notice would be nice, but could be worked around by checking
the array type and length (the count() function returns the string
length I believe as well as the array size) as it does seem that PHP is
treating a string like a special sort of array.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] No notices for undefined index

2010-04-08 Thread kranthi
 print $a[0];   // prints 5
 print $a[100]; // Notice: Uninitialized string offset:  100
Yup, this should happen when 5 is treated as an array of characters.
In other words as a string.
$a = '5';
echo $a[0];
echo $a[100];
gives you the expected result

regarding the original question, i think that the interpreter is
prefilling the variable with null

$a = 5;
var_dump(isset($a[0]));
var_dump($a[0]);

since $a[0] is already assigned (to null) the interpreter is not
throwing a notice

$b = null;
var_dump(isset($b));
var_dump($b);

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



[PHP] Forgot what to install

2010-04-08 Thread David McGlone
Hey guys, quick question. I had to re-install my Ubuntu, and I forgot
what package I needed so firefox will display the php files and not ask
me to if I want to download them. I've done installed PHP5, mysql, and
php-mysql. What did I miss. I know the package name, but it's completely
slipping my mind right now.

Thanks
David M.


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



Re: [PHP] Forgot what to install

2010-04-08 Thread kranthi
you forgot httpd
KK.



On Fri, Apr 9, 2010 at 08:32, David McGlone da...@dmcentral.net wrote:
 Hey guys, quick question. I had to re-install my Ubuntu, and I forgot
 what package I needed so firefox will display the php files and not ask
 me to if I want to download them. I've done installed PHP5, mysql, and
 php-mysql. What did I miss. I know the package name, but it's completely
 slipping my mind right now.

 Thanks
 David M.


 --
 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



Re: [PHP] Forgot what to install

2010-04-08 Thread viraj
it's apache2 module for php

#apt-cache search php5 apache
libapache2-mod-php5 - server-side, HTML-embedded scripting language
(Apache 2 module)

~viraj

On Fri, Apr 9, 2010 at 8:32 AM, David McGlone da...@dmcentral.net wrote:
 Hey guys, quick question. I had to re-install my Ubuntu, and I forgot
 what package I needed so firefox will display the php files and not ask
 me to if I want to download them. I've done installed PHP5, mysql, and
 php-mysql. What did I miss. I know the package name, but it's completely
 slipping my mind right now.

 Thanks
 David M.


 --
 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



Re: [PHP] No notices for undefined index

2010-04-08 Thread shiplu
Hello Shawn,
Why dont you report a bug? When we know the expected behavior or the
way it SHOULD behave. and its not behaving that way. Its certainly a
bug.. Only then we can know the real reason why the novicas are not
showing up.

On 4/8/10, Shawn McKenzie nos...@mckenzies.net wrote:
 So the first two print statements generate NO notices, while the second
 obviously generates:

 Notice: Undefined offset:  1 in /home/shawn/www/test.php on line 11

 Notice: Undefined index:  test in /home/shawn/www/test.php on line 12

 This sucks.  A bug???

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


 $a = 5;
 print $a[1];
 print $a['test'];

 $a = array();
 print $a[1];
 print $a['test'];

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

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



-- 
Sent from my mobile device

Shiplu Mokaddim
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

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



Re: [PHP] Forgot what to install

2010-04-08 Thread shiplu
A tip for you. If you have internet access, type in
sudo apt-get install phpmyadmin
This will install all the dependencies and your server will be ready.

On 4/9/10, David McGlone da...@dmcentral.net wrote:
 Hey guys, quick question. I had to re-install my Ubuntu, and I forgot
 what package I needed so firefox will display the php files and not ask
 me to if I want to download them. I've done installed PHP5, mysql, and
 php-mysql. What did I miss. I know the package name, but it's completely
 slipping my mind right now.

 Thanks
 David M.


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



-- 
Sent from my mobile device

Shiplu Mokaddim
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

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