Re: [PHP] Lasting syntax error when there's none

2013-04-10 Thread Filip Zrůst
It seems the problem was caused by shared folder between host and guest 
systems, respectively by files’ owner and group. When I copied file to 
designated folder, everything started to work. However permissions and other 
things are the same from the point of readability and writability. It’s just 
that files are not shared between systems and are owned by someone else. It is 
strange anyway… And honestly, I see no reason why this is happening.

On Apr 10, 2013, at 12:57 AM, Filip Zrůst fr...@me.com wrote:

 Hi Stephen,
 
 I looked there before but I’ve increased debug level after you suggestion and 
 there’s still nothing helpful I guess. But just to be sure:
 
 Reverse proxy (“load balancer”):
 - error log: nothing
 - access log:
 192.168.60.2 - - [09/Apr/2013:15:25:08 −0700] GET /offer/create HTTP/1.1 
 500 42008 http://localhost:8080/need/create; Mozilla/5.0 (Macintosh; Intel 
 Mac OS X 10_8_3) AppleWebKit/536.28.10 (KHTML, like Gecko) Version/6.0.3 
 Safari/536.28.10
 
 FPM pool:
 - error log:
 [09-Apr-2013 22:25:08 UTC] PHP Parse error:  syntax error, unexpected $end 
 in 
 /mnt/hgfs/vagrant-root/temp/cache/_Nette.FileTemplate/_Offer.create.latte-76106eddfc5f39910a042247bcba6d4f.php
  on line 191
 
 - access log:
 127.0.0.1 -  09/Apr/2013:22:25:08 + “GET /index.php” 200
 
 I’m not sure why FPM access log reports status code 200 but this value might 
 mean something else.
 
 As you can see, there’s really not much in the logs. AFAIK permissions are 
 fine, otherwise applying `touch` on those files wouldn’t resolve a thing. 
 Timezones are also somewhat messed up, but that’s just a configuration issue 
 I guess.
 
 I’ll try running everything on near production system instead of Vagrant 
 which may solve the issue. But I would like know the mechanics behind this 
 issue anyway.
 
 I’m still playing with the idea that application framework we use is behind 
 that, but I see no reason why and why it affects different SAPIs. I also 
 don’t get why touching resolves the problem, because it means some caching is 
 in play. But where can it be configured? Or, is it some OS specific trickery? 
 Don’t know yet…
 
 
 Best,
 -- 
 frzng
 
 On Apr 9, 2013, at 5:10 PM, Stephen stephe...@rogers.com wrote:
 
 You first step is to check the log files.
 
 No matter how sure we are that there is no syntax error, always start with 
 the logs.
 
 It could be a file permission problem.
 
 Stephen
 
 On 13-04-09 11:00 AM, fr...@me.com wrote:
 Hi everyone,
 
 I have some weird problem with PHP compiler or something of this sort of 
 things. We have some PHP files which are generated during the first request 
 to the site. These files are normally executed via PHP then. For some 
 reason PHP thinks that they contain syntax errors (verified using HTTP 
 request, or `php -l`). I've found out it is extremely easy to resolve this 
 issue manually when developing - simply renaming or touching that file 
 resolves the issue. So, apparently those generated PHP files don't contain 
 any syntax error. However, PHP thinks they do even across different SAPIs 
 (CLI and FPM). Since fixing the issue in this manner doesn't seam 
 reasonable even by some script on production, I'd like to know whether do 
 you have any suggestion what settings to tweak or what might be the problem.
 
 Here is some information about the environment (feel free to ask for more):
 - PHP version: 5.3.10-1ubuntu3.6
 - SAPI: FPM and CLI
 - OS: Ubuntu 12.04
 - Software: Ubuntu packages only (updated)
 - HTTP request handling: nginx load balancer → PHP FPM daemon
 - Machine: VMware Fusion (managed by Vagrant) hosted on OS X 10.8.3
 
 
 Thanks,
 
 
 -- 
 Stephen
 
 


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



Re: [PHP] Lasting syntax error when there's none

2013-04-09 Thread Stephen

You first step is to check the log files.

No matter how sure we are that there is no syntax error, always start 
with the logs.


It could be a file permission problem.

Stephen

On 13-04-09 11:00 AM, fr...@me.com wrote:

Hi everyone,

I have some weird problem with PHP compiler or something of this sort 
of things. We have some PHP files which are generated during the first 
request to the site. These files are normally executed via PHP then. 
For some reason PHP thinks that they contain syntax errors (verified 
using HTTP request, or `php -l`). I've found out it is extremely easy 
to resolve this issue manually when developing - simply renaming or 
touching that file resolves the issue. So, apparently those generated 
PHP files don't contain any syntax error. However, PHP thinks they do 
even across different SAPIs (CLI and FPM). Since fixing the issue in 
this manner doesn't seam reasonable even by some script on production, 
I'd like to know whether do you have any suggestion what settings to 
tweak or what might be the problem.


Here is some information about the environment (feel free to ask for 
more):

- PHP version: 5.3.10-1ubuntu3.6
- SAPI: FPM and CLI
- OS: Ubuntu 12.04
- Software: Ubuntu packages only (updated)
- HTTP request handling: nginx load balancer ? PHP FPM daemon
- Machine: VMware Fusion (managed by Vagrant) hosted on OS X 10.8.3


Thanks,





--
Stephen



Re: [PHP] Lasting syntax error when there's none

2013-04-09 Thread Marco Behnke



Am 09.04.2013 17:00, schrieb fr...@me.com:

Hi everyone,

I have some weird problem with PHP compiler or something of this sort of 
things. We have some PHP files which are generated during the first request to 
the site. These files are normally executed via PHP then. For some reason PHP 
thinks that they contain syntax errors (verified using HTTP request, or `php 
-l`). I've found out it is extremely easy to resolve this issue manually when 
developing - simply renaming or touching that file resolves the issue. So, 
apparently those generated PHP files don't contain any syntax error. However, 
PHP thinks they do even across different SAPIs (CLI and FPM). Since fixing the 
issue in this manner doesn't seam reasonable even by some script on production, 
I'd like to know whether do you have any suggestion what settings to tweak or 
what might be the problem.



If touching resolves the error, maybe it is some kind of bytecode cache.
Do you use APC or something like that?

Touch the file after creating it
http://www.php.net/touch



Here is some information about the environment (feel free to ask for more):
- PHP version: 5.3.10-1ubuntu3.6
- SAPI: FPM and CLI
- OS: Ubuntu 12.04
- Software: Ubuntu packages only (updated)
- HTTP request handling: nginx load balancer → PHP FPM daemon
- Machine: VMware Fusion (managed by Vagrant) hosted on OS X 10.8.3


Thanks,



--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] Lasting syntax error when there's none

2013-04-09 Thread Filip Zrůst
Hi Stephen,

I looked there before but I’ve increased debug level after you suggestion and 
there’s still nothing helpful I guess. But just to be sure:

Reverse proxy (“load balancer”):
- error log: nothing
- access log:
 192.168.60.2 - - [09/Apr/2013:15:25:08 −0700] GET /offer/create HTTP/1.1 
 500 42008 http://localhost:8080/need/create; Mozilla/5.0 (Macintosh; Intel 
 Mac OS X 10_8_3) AppleWebKit/536.28.10 (KHTML, like Gecko) Version/6.0.3 
 Safari/536.28.10

FPM pool:
- error log:
 [09-Apr-2013 22:25:08 UTC] PHP Parse error:  syntax error, unexpected $end in 
 /mnt/hgfs/vagrant-root/temp/cache/_Nette.FileTemplate/_Offer.create.latte-76106eddfc5f39910a042247bcba6d4f.php
  on line 191

- access log:
 127.0.0.1 -  09/Apr/2013:22:25:08 + “GET /index.php” 200

I’m not sure why FPM access log reports status code 200 but this value might 
mean something else.

As you can see, there’s really not much in the logs. AFAIK permissions are 
fine, otherwise applying `touch` on those files wouldn’t resolve a thing. 
Timezones are also somewhat messed up, but that’s just a configuration issue I 
guess.

I’ll try running everything on near production system instead of Vagrant which 
may solve the issue. But I would like know the mechanics behind this issue 
anyway.

I’m still playing with the idea that application framework we use is behind 
that, but I see no reason why and why it affects different SAPIs. I also don’t 
get why touching resolves the problem, because it means some caching is in 
play. But where can it be configured? Or, is it some OS specific trickery? 
Don’t know yet…


Best,
-- 
frzng

On Apr 9, 2013, at 5:10 PM, Stephen stephe...@rogers.com wrote:

 You first step is to check the log files.
 
 No matter how sure we are that there is no syntax error, always start with 
 the logs.
 
 It could be a file permission problem.
 
 Stephen
 
 On 13-04-09 11:00 AM, fr...@me.com wrote:
 Hi everyone,
 
 I have some weird problem with PHP compiler or something of this sort of 
 things. We have some PHP files which are generated during the first request 
 to the site. These files are normally executed via PHP then. For some reason 
 PHP thinks that they contain syntax errors (verified using HTTP request, or 
 `php -l`). I've found out it is extremely easy to resolve this issue 
 manually when developing - simply renaming or touching that file resolves 
 the issue. So, apparently those generated PHP files don't contain any syntax 
 error. However, PHP thinks they do even across different SAPIs (CLI and 
 FPM). Since fixing the issue in this manner doesn't seam reasonable even by 
 some script on production, I'd like to know whether do you have any 
 suggestion what settings to tweak or what might be the problem.
 
 Here is some information about the environment (feel free to ask for more):
 - PHP version: 5.3.10-1ubuntu3.6
 - SAPI: FPM and CLI
 - OS: Ubuntu 12.04
 - Software: Ubuntu packages only (updated)
 - HTTP request handling: nginx load balancer → PHP FPM daemon
 - Machine: VMware Fusion (managed by Vagrant) hosted on OS X 10.8.3
 
 
 Thanks,
 
 
 -- 
 Stephen
 


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



Re: [PHP] Preferred Syntax

2011-12-15 Thread Tedd Sperling
On Dec 14, 2011, at 12:09 PM, Peter Ford wrote:
 
 With respect to tedd and Al, you've misread the question: the important 
 PHP-related bit is about whether to embed variables in double-quoted strings 
 or to concatenate them. These are only two of the options, and each has it's 
 pros and cons. There has been (some time ago) plenty of discussion on this 
 list about this sort of thing, including (ISTR) a timed test of the 
 performance implications of various forms - that only really matters in big 
 loops, of course...
 
 Horses for courses. I use whatever I feel like at the time, and mix various 
 styles, as long as it's readable!
 
 Cheers
 Pete
 

I didn't misread the OP's post. Realize that the OP provided two ways of doing 
the task and asked which way was best?

I responded with a recommendation to remove all style elements and my 
recommended solution to his problem.

He can either consider or not.

Cheers,

tedd

_
t...@sperling.com
http://sperling.com




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



Re: [PHP] Preferred Syntax

2011-12-14 Thread Tedd Sperling
On Dec 14, 2011, at 7:59 AM, Rick Dwyer wrote:

 Hello all.
 
 Can someone tell me which of the following is preferred and why?
 
 echo a style='text-align:left;size:14;font-weight:bold' 
 href='/mypage.php/$page_id'$page_name/abr;
 
 echo a style='text-align:left;size:14;font-weight:bold' 
 href='/mypage.php/.$page_id.'.$page_name./abr;
 
 When I come across the above code in line 1, I have been changing it to what 
 you see in line 2 for no other reason than it delineates out better in 
 BBEdit.  Is this just a preference choice or is one method better than the 
 other?
 
 --Rick

Neither.

My advice, take all the style elements out of the anchor tag.

echo(a href='/mypage.php/$page_id'$page_name/a);

Even the 'br' can be (perhaps should be) handled by css.

Cheers,

tedd

_
t...@sperling.com
http://sperling.com





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



Re: [PHP] Preferred Syntax

2011-12-14 Thread Marc Guay
 BBEdit.  Is this just a preference choice or is one method better than the 
 other?

As far as I know it's just preference.  Your choice of editor could
influence your decision; one form might be given nicer highlighting.

Marc

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



Re: [PHP] Preferred Syntax

2011-12-14 Thread David Harkness
On Wed, Dec 14, 2011 at 4:59 AM, Rick Dwyer rpdw...@earthlink.net wrote:

 Can someone tell me which of the following is preferred and why?

  echo a style='text-align:left;size:**14;font-weight:bold'
 href='/mypage.php/$page_id'$**page_name/abr;

  echo a style='text-align:left;size:**14;font-weight:bold'
 href='/mypage.php/.$page_id.**'.$page_name./abr;


On Wed, Dec 14, 2011 at 9:09 AM, Peter Ford p...@justcroft.com wrote:

 Horses for courses. I use whatever I feel like at the time, and mix
 various styles, as long as it's readable!


I agree with Peter here. I would bet that the string with embedded
variables is parsed once when the file is loaded and turned into the same
bytecode as the second form.

If you are going to use the second style above, I would at least switch the
quotes around so you can use the double-quotes in the HTML as that to me
reads nicer and avoids the minor cost of scanning the string for embedded
code. I also put spaces around the dots to make the variable concatenation
easier to spot when skimming it.

echo 'a style=text-align:left;size:**14;font-weight:bold
href=/mypage.php/' . $page_id . '' . $page_name . '/abr';

David


Re: [PHP] Preferred Syntax

2011-12-14 Thread Tamara Temple
Tedd Sperling tedd.sperl...@gmail.com wrote:
 On Dec 14, 2011, at 7:59 AM, Rick Dwyer wrote:
 
  Hello all.
  
  Can someone tell me which of the following is preferred and why?
  
  echo a style='text-align:left;size:14;font-weight:bold' 
  href='/mypage.php/$page_id'$page_name/abr;
  
  echo a style='text-align:left;size:14;font-weight:bold' 
  href='/mypage.php/.$page_id.'.$page_name./abr;
  
  When I come across the above code in line 1, I have been changing it to 
  what you see in line 2 for no other reason than it delineates out better in 
  BBEdit.  Is this just a preference choice or is one method better than the 
  other?
  
  --Rick
 
 Neither.
 
 My advice, take all the style elements out of the anchor tag.
 
 echo(a href='/mypage.php/$page_id'$page_name/a);
 
 Even the 'br' can be (perhaps should be) handled by css.

I think you may have missed the question. The OP was asking whether:

  text $var text 

or

  text .$var. text

was preferrable.

For me, I tend to use the first unless the second makes things clearer
where they need to be. Syntax hilighing can easily be one of those
times.


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



Re: [PHP] Preferred Syntax

2011-12-14 Thread Robert Cummings

On 11-12-14 01:10 PM, David Harkness wrote:

On Wed, Dec 14, 2011 at 4:59 AM, Rick Dwyerrpdw...@earthlink.net  wrote:


Can someone tell me which of the following is preferred and why?

  echo a style='text-align:left;size:**14;font-weight:bold'
href='/mypage.php/$page_id'$**page_name/abr;

  echo a style='text-align:left;size:**14;font-weight:bold'
href='/mypage.php/.$page_id.**'.$page_name./abr;



On Wed, Dec 14, 2011 at 9:09 AM, Peter Fordp...@justcroft.com  wrote:


Horses for courses. I use whatever I feel like at the time, and mix
various styles, as long as it's readable!



I agree with Peter here. I would bet that the string with embedded
variables is parsed once when the file is loaded and turned into the same
bytecode as the second form.

If you are going to use the second style above, I would at least switch the
quotes around so you can use the double-quotes in the HTML as that to me
reads nicer and avoids the minor cost of scanning the string for embedded
code. I also put spaces around the dots to make the variable concatenation
easier to spot when skimming it.

 echo 'a style=text-align:left;size:**14;font-weight:bold
href=/mypage.php/' . $page_id . '' . $page_name .'/abr';


+1 on the use of single quotes instead of double quotes. With a bytecode 
cache it's not really going to make a lick of difference, but using 
double quotes for HTML seems far more palatable to me. I too like to 
pull the variable out into code space. I also like to format my 
attributes for easy reading and commenting:


echo 'a'
.' style=text-align:left;size:**14;font-weight:bold'
.' href=/mypage.php/'.$page_id.''
.''
.$page_name
.'/a'
.'br /';

Although, I usually only do the above for tags that have lots of 
attributes. Otherwise the following is more likely:


echo 'div class=some-class'
.'Something something'
.'/div';

As I said before though, a bytecode cache with any degree of 
optimization should make any particular style have zero impact on 
runtime (beyond original parse) by optimizing the strings into a minimal 
set of operations. For instance 'foo'.'fee' would be coverted to 
'foofee' by the bytecode engine.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



RE: [PHP] Preferred Syntax

2011-12-14 Thread admin
 -Original Message-
 From: Tamara Temple [mailto:tamouse.li...@tamaratemple.com]
 Sent: Wednesday, December 14, 2011 1:40 PM
 To: Tedd Sperling
 Cc: Rick Dwyer; PHP-General
 Subject: Re: [PHP] Preferred Syntax
 
 Tedd Sperling tedd.sperl...@gmail.com wrote:
  On Dec 14, 2011, at 7:59 AM, Rick Dwyer wrote:
 
   Hello all.
  
   Can someone tell me which of the following is preferred and why?
  
   echo a style='text-align:left;size:14;font-weight:bold'
 href='/mypage.php/$page_id'$page_name/abr;
  
   echo a style='text-align:left;size:14;font-weight:bold'
 href='/mypage.php/.$page_id.'.$page_name./abr;
  
   When I come across the above code in line 1, I have been changing
 it to what you see in line 2 for no other reason than it delineates out
 better in BBEdit.  Is this just a preference choice or is one method
 better than the other?
  
   --Rick
 
  Neither.
 
  My advice, take all the style elements out of the anchor tag.
 
  echo(a href='/mypage.php/$page_id'$page_name/a);
 
  Even the 'br' can be (perhaps should be) handled by css.
 
 I think you may have missed the question. The OP was asking whether:
 
   text $var text
 
 or
 
   text .$var. text
 
 was preferrable.
 
 For me, I tend to use the first unless the second makes things clearer
 where they need to be. Syntax hilighing can easily be one of those
 times.
 
 
 --

The key thing to remember here is that this is a preference and not a
performance thing.






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



Re: [PHP] Preferred Syntax

2011-12-14 Thread Adam Richardson
On Wed, Dec 14, 2011 at 7:59 AM, Rick Dwyer rpdw...@earthlink.net wrote:

 Hello all.

 Can someone tell me which of the following is preferred and why?

  echo a style='text-align:left;size:**14;font-weight:bold'
 href='/mypage.php/$page_id'$**page_name/abr;

  echo a style='text-align:left;size:**14;font-weight:bold'
 href='/mypage.php/.$page_id.**'.$page_name./abr;

 When I come across the above code in line 1, I have been changing it to
 what you see in line 2 for no other reason than it delineates out better in
 BBEdit.  Is this just a preference choice or is one method better than the
 other?


I prefer sending arguments to the echo language construct (note, if you
send more than one argument, you can't use parentheses.) I perceive this
usage to be a clean presentation of the code's intent, easy to use in most
IDE's, and it's very fast relative to the other options:

echo a style='text-align:left;size:**14;font-weight:bold'
href='/mypage.php/$page_id'$**page_name/abr;

echo a style='text-align:left;size:**14;font-weight:bold'
href='/mypage.php/.$page_id.**'.$page_name./abr;

echo a style='text-align:left;size:**14;font-weight:bold'
href='/mypage.php/, $page_id, ', $**page_name, /abr;

And, for longer lines, I'll often break it up into separate lines by
argument like below:

echo
a style='text-align:left;size:**14;font-weight:bold'
href='/mypage.php/,
$page_id,
',
$**page_name,
/abr;

That all said, I don't change code that uses another convention, as I think
it's most beneficial to stay with the established conventions in any
codebase (unless you're establishing a new convention and refactoring the
entire code base.) This is just my general preference, and I don't believe
there is consensus as to the most appropriate.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


RE: [PHP] Preferred Syntax

2011-12-14 Thread admin
 -Original Message-
 From: Adam Richardson [mailto:simples...@gmail.com]
 Sent: Wednesday, December 14, 2011 2:19 PM
 To: Rick Dwyer
 Cc: PHP-General
 Subject: Re: [PHP] Preferred Syntax
 
 On Wed, Dec 14, 2011 at 7:59 AM, Rick Dwyer rpdw...@earthlink.net
 wrote:
 
  Hello all.
 
  Can someone tell me which of the following is preferred and why?
 
   echo a style='text-align:left;size:**14;font-weight:bold'
  href='/mypage.php/$page_id'$**page_name/abr;
 
   echo a style='text-align:left;size:**14;font-weight:bold'
  href='/mypage.php/.$page_id.**'.$page_name./abr;
 
  When I come across the above code in line 1, I have been changing it
 to
  what you see in line 2 for no other reason than it delineates out
 better in
  BBEdit.  Is this just a preference choice or is one method better
 than the
  other?
 
 
 I prefer sending arguments to the echo language construct (note, if you
 send more than one argument, you can't use parentheses.) I perceive
 this
 usage to be a clean presentation of the code's intent, easy to use in
 most
 IDE's, and it's very fast relative to the other options:
 
 echo a style='text-align:left;size:**14;font-weight:bold'
 href='/mypage.php/$page_id'$**page_name/abr;
 
 echo a style='text-align:left;size:**14;font-weight:bold'
 href='/mypage.php/.$page_id.**'.$page_name./abr;
 
 echo a style='text-align:left;size:**14;font-weight:bold'
 href='/mypage.php/, $page_id, ', $**page_name, /abr;
 
 And, for longer lines, I'll often break it up into separate lines by
 argument like below:
 
 echo
 a style='text-align:left;size:**14;font-weight:bold'
 href='/mypage.php/,
 $page_id,
 ',
 $**page_name,
 /abr;
 
 That all said, I don't change code that uses another convention, as I
 think
 it's most beneficial to stay with the established conventions in any
 codebase (unless you're establishing a new convention and refactoring
 the
 entire code base.) This is just my general preference, and I don't
 believe
 there is consensus as to the most appropriate.
 
 Adam
 
 --
 Nephtali:  A simple, flexible, fast, and security-focused PHP framework
 http://nephtaliproject.com



Adam,
You are very correct, the last discussions and testing of theories
caused my head to hurt!!! 
Neither side gained ground in testing or discussion.
Having said that to me it is a preference only and not a performance
enhancing or degrading factor in syntax.





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



Re: [PHP] Preferred Syntax

2011-12-14 Thread Rick Dwyer
On Dec 14, 2011, at 1:53 PM, ad...@buskirkgraphics.com ad...@buskirkgraphics.com 
 wrote:


The key thing to remember here is that this is a preference and not a
performance thing.


Thank you... this is basically what I wanted to know.  I was concerned  
that not breaking the VARS out separately from the echo'ed text might  
cause some sort of performance problem or confusion for PHP.   
Therefore, whenever I came across them, I was breaking them out with  
the . $var . technique.  Will no longer do that for existing code, as  
it appears not necessary, but I do prefer it for readability sake...  
expecially in BBEdit.  So will continue to write new code breaking it  
out.  And I too prefer a single quote for PHP and a double for HTML...  
even though the sample I displayed showed otherwise.


Thanks to all who responded.

--Rick



Re: [PHP] PHP syntax - novice question

2011-10-29 Thread Simon J Welsh
On 30/10/2011, at 1:15 PM, Phil Dobbin wrote:

 Hi, all.
 
 I’m new to the list  PHP in general  have a syntax question.
 
 I have a script that calls both DB  MDB2. This is the part of the script 
 where the error occurs:
 
 
 
 if($type == DB)
  {
$db = DB::connect($dsn);
if (PEAR::isError($db)) { die($db-getMessage()); }
$db-setFetchMode(DB_FETCHMODE_ASSOC);
$res = $db-query( 'SELECT * FROM users');
 
if (PEAR::isError($res)) {
  die($res-getMessage());
}
echo ‘pre’;
while( $res-fetchInto( $row ) ) {
  print_R($row);
}
echo ‘/pre’;
  } else if($type == MDB2) {
$mdb2 = MDB2::connect($dsn);
if (PEAR::isError($mdb2)) { die($mdb2-getMessage()); }
 
$res = $mdb2-query( 'SELECT * FROM users');
 
// Always check that result is not an error
if (PEAR::isError($res)) {
  die($res-getMessage());
}
 
echo ‘pre’;
while ($row = $res-fetchRow(MDB2_FETCHMODE_ASSOC)) {
  print_R($row);
}
echo ‘/pre’;
  }
 
 ###
 
 The syntax checker calls the first instance ofecho ‘pre’;   saying 
 unexpected 
 
 I’m at a loss to understand why...
 
 I’m using PHP 5.3.8  PEAR 1.9.4 with MySQL 5.1.59 on Mac OS X 10.6.8.
 
 Any help appreciated.
 
 Cheers,
 
Phil.

It seems as though your editor has changed the normal quotes around pre into 
pretty quotes. Change the ‘s and ’s back to '.
---
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



Re: [PHP] PHP syntax - novice question

2011-10-29 Thread Phil Dobbin
On 30/10/11 at 01:18, si...@welsh.co.nz (Simon J Welsh) wrote:

 It seems as though your editor has changed the normal quotes around pre 
 into pretty 
 quotes. Change the ‘s and ’s back to '.

Hi, Simon.

Thanks for that. Couldn’t see for looking...

Cheers,

Phil.
--
Please consider the environment before reading this email...


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



Re: [PHP] SQL Syntax

2010-06-16 Thread Andrew Ballard
On Tue, Jun 15, 2010 at 8:58 PM, Jan Reiter the-fal...@gmx.net wrote:
 Hi folks!

 I'm kind of ashamed to ask a question, as I haven't followed this list very
 much lately.

 This isn't exactly a PHP question, but since mysql is the most popular
 database engine used with php, I figured someone here might have an idea.

 I have 2 tables. Table A containing 2 fields. A user ID and a picture ID =
 A(uid,pid) and another table B, containing 3 fields. The picture ID, an
 attribute ID and a value for that attribute = B(pid,aid,value).

 Table B contains several rows for a single PID with various AIDs and values.
 Each AID is unique to a PID.  (e.g. AID = 1 always holding the value for the
 image size and AID = 3 always holding a value for the image type)

This is known as an EAV (Entity-Attribute-Value) design. It is usually
(some would say always) a very bad idea to implement this in a
relational database. and this is no exception.

 The goal is now to join table A on table B using pid, and selecting the rows
 based on MULTIPLE  attributes.

 So the result should only contain rows for images, that relate to an
 attribute ID = 1 (size) that is bigger than 100 AND!!! an attribute ID =
 5 that equals 'jpg'.

 I know that there is an easy solution to this, doing it in one query and I
 have the feeling, that I can almost touch it with my fingertips in my mind,
 but I can't go that final step, if you know what I mean. AND THAT DRIVES ME
 CRAZY!!

The easy solution is to redesign the tables. There are a lot of
reasons why this design is usually a very bad idea. For starters, what
should be a simple query is anything but simple, as you have just
discovered. What's more, there is no simple way (if any way at all)
for your design to prevent an image from having a mime-type of 20174
or a size of 'jpg'.

Andrew

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



Re: [PHP] SQL Syntax [improved SQL]

2010-06-16 Thread Jan Reiter
Hi,

this is the solution I came up with, that is over 10 times faster than my
first attemps.

Tested @31,871 entries in table 'picture' and 222,712 entries in table
'picture_attrib_rel'. 

Old Version:

SELECT * FROM picture as p 

INNER JOIN picture_attrib_rel as pr1 
ON (p.pid = pr1.pid)

INNER JOIN  picture_attrib_rel as pr2 
ON (p.pid = pr2.pid and pr2.val_int  1500)

WHERE pr1.aid = 2 AND pr1.val_int = 1500 
AND pr2.aid = 5 AND pr2.val_int  1000

Takes about 1.9 Seconds on average to return.

The version with temporary tables:

DROP temporary table if exists tmp_size;
DROP temporary table if exists tmp_qi;

CREATE temporary table tmp_size
  SELECT pid FROM picture_attrib_rel 
  WHERE aid = 2 AND val_int = 1500;
CREATE temporary table tmp_qi
  SELECT pid FROM picture_attrib_rel 
  WHERE aid = 5 AND val_int  1000;

SELECT pid,uid FROM tmp_size JOIN tmp_qi USING(pid) JOIN pictures
USING(pid);

DROP temporary table if exists tmp_size;
DROP temporary table if exists tmp_qi;

This takes 0.12 seconds to return, which is quite bearable for now. 


Thanks again for all your input!

Regards,
Jan


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



RE: [PHP] SQL Syntax [improved SQL]

2010-06-16 Thread Tommy Pham
 -Original Message-
 From: Jan Reiter [mailto:the-fal...@gmx.net]
 Sent: Wednesday, June 16, 2010 8:55 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] SQL Syntax [improved SQL]
 
 Hi,
 
 this is the solution I came up with, that is over 10 times faster than my
first
 attemps.
 
 Tested @31,871 entries in table 'picture' and 222,712 entries in table
 'picture_attrib_rel'.
 
 Old Version:
 
 SELECT * FROM picture as p
 
 INNER JOIN picture_attrib_rel as pr1
 ON (p.pid = pr1.pid)
 
 INNER JOIN  picture_attrib_rel as pr2
 ON (p.pid = pr2.pid and pr2.val_int  1500)
 
 WHERE pr1.aid = 2 AND pr1.val_int = 1500 AND pr2.aid = 5 AND pr2.val_int

 1000
 
 Takes about 1.9 Seconds on average to return.
 
 The version with temporary tables:
 
 DROP temporary table if exists tmp_size; DROP temporary table if exists
 tmp_qi;
 
 CREATE temporary table tmp_size
   SELECT pid FROM picture_attrib_rel
   WHERE aid = 2 AND val_int = 1500;
 CREATE temporary table tmp_qi
   SELECT pid FROM picture_attrib_rel
   WHERE aid = 5 AND val_int  1000;
 
 SELECT pid,uid FROM tmp_size JOIN tmp_qi USING(pid) JOIN pictures
 USING(pid);
 
 DROP temporary table if exists tmp_size; DROP temporary table if exists
 tmp_qi;
 
 This takes 0.12 seconds to return, which is quite bearable for now.
 
 
 Thanks again for all your input!
 
 Regards,
 Jan

Jan,

What do you get from this query and how fast does it execute? 

SELECT * FROM picture_attrib_rel par INNER JOIN pictures p ON p.pid =
par.pid WHERE (par.aid = 2 AND par.val_int = 1500) OR (par.aid = 5 AND
par.val_int  1000)

Regards,
Tommy


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



Re: [PHP] SQL Syntax

2010-06-15 Thread Daniel Brown
[Top-post.]

You'll probably have much better luck on the MySQL General list.
CC'ed on this email.


On Tue, Jun 15, 2010 at 20:58, Jan Reiter the-fal...@gmx.net wrote:
 Hi folks!

 I'm kind of ashamed to ask a question, as I haven't followed this list very
 much lately.



 This isn't exactly a PHP question, but since mysql is the most popular
 database engine used with php, I figured someone here might have an idea.



 I have 2 tables. Table A containing 2 fields. A user ID and a picture ID =
 A(uid,pid) and another table B, containing 3 fields. The picture ID, an
 attribute ID and a value for that attribute = B(pid,aid,value).



 Table B contains several rows for a single PID with various AIDs and values.
 Each AID is unique to a PID.  (e.g. AID = 1 always holding the value for the
 image size and AID = 3 always holding a value for the image type)



 The goal is now to join table A on table B using pid, and selecting the rows
 based on MULTIPLE  attributes.



 So the result should only contain rows for images, that relate to an
 attribute ID = 1 (size) that is bigger than 100 AND!!! an attribute ID =
 5 that equals 'jpg'.



 I know that there is an easy solution to this, doing it in one query and I
 have the feeling, that I can almost touch it with my fingertips in my mind,
 but I can't go that final step, if you know what I mean. AND THAT DRIVES ME
 CRAZY!!



 I appreciate your thoughts on this.



 Regards,

 Jan





-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

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



Re: [PHP] SQL Syntax

2010-06-15 Thread Ashley Sheridan
On Wed, 2010-06-16 at 02:58 +0200, Jan Reiter wrote:

 Hi folks!
 
 I'm kind of ashamed to ask a question, as I haven't followed this list very
 much lately. 
 
  
 
 This isn't exactly a PHP question, but since mysql is the most popular
 database engine used with php, I figured someone here might have an idea.
 
  
 
 I have 2 tables. Table A containing 2 fields. A user ID and a picture ID =
 A(uid,pid) and another table B, containing 3 fields. The picture ID, an
 attribute ID and a value for that attribute = B(pid,aid,value).
 
  
 
 Table B contains several rows for a single PID with various AIDs and values.
 Each AID is unique to a PID.  (e.g. AID = 1 always holding the value for the
 image size and AID = 3 always holding a value for the image type)
 
  
 
 The goal is now to join table A on table B using pid, and selecting the rows
 based on MULTIPLE  attributes. 
 
  
 
 So the result should only contain rows for images, that relate to an
 attribute ID = 1 (size) that is bigger than 100 AND!!! an attribute ID =
 5 that equals 'jpg'. 
 
  
 
 I know that there is an easy solution to this, doing it in one query and I
 have the feeling, that I can almost touch it with my fingertips in my mind,
 but I can't go that final step, if you know what I mean. AND THAT DRIVES ME
 CRAZY!!
 
  
 
 I appreciate your thoughts on this.
 
  
 
 Regards,
 
 Jan
 


You'll be looking for something like this (untested):

SELECT * FROM a
LEFT JOIN b ON (a.pid = b.pid)
WHERE (b.aid = 1 AND b.value  100) OR (b.aid = 3 AND b.value = 'jpg')

Obviously instead of the * you may have to change to a list of field
names to avoid fieldname collision on the two tables.

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




RE: [PHP] SQL Syntax

2010-06-15 Thread Jan Reiter
Thanks. That was my first attempt, too. Only this will throw out rows, that 
meet only one of the conditions, too. For example, I would get all pictures 
that are bigger than 100, regardless of type, and all pictures that are of type 
jpg, no matter the size. 

Doing it with a view would be an option, but that would immensely decrease 
flexibility.  

I guess I have to keep on cooking my brain on this ;-) 

I think I did it before, a few years ago when MySQL didn't support views yet, 
but I can't find that stuff ... 

@Dan: Thanks for forwarding my mail to the MySQL List!

Regards,
Jan


From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Wednesday, June 16, 2010 3:09 AM
To: Jan Reiter
Cc: php-general@lists.php.net
Subject: Re: [PHP] SQL Syntax

On Wed, 2010-06-16 at 02:58 +0200, Jan Reiter wrote: 

Hi folks!

I'm kind of ashamed to ask a question, as I haven't followed this list very
much lately. 

 

This isn't exactly a PHP question, but since mysql is the most popular
database engine used with php, I figured someone here might have an idea.

 

I have 2 tables. Table A containing 2 fields. A user ID and a picture ID =
A(uid,pid) and another table B, containing 3 fields. The picture ID, an
attribute ID and a value for that attribute = B(pid,aid,value).

 

Table B contains several rows for a single PID with various AIDs and values.
Each AID is unique to a PID.  (e.g. AID = 1 always holding the value for the
image size and AID = 3 always holding a value for the image type)

 

The goal is now to join table A on table B using pid, and selecting the rows
based on MULTIPLE  attributes. 

 

So the result should only contain rows for images, that relate to an
attribute ID = 1 (size) that is bigger than 100 AND!!! an attribute ID =
5 that equals 'jpg'. 

 

I know that there is an easy solution to this, doing it in one query and I
have the feeling, that I can almost touch it with my fingertips in my mind,
but I can't go that final step, if you know what I mean. AND THAT DRIVES ME
CRAZY!!

 

I appreciate your thoughts on this.

 

Regards,

Jan


You'll be looking for something like this (untested):

SELECT * FROM a
LEFT JOIN b ON (a.pid = b.pid)
WHERE (b.aid = 1 AND b.value  100) OR (b.aid = 3 AND b.value = 'jpg')

Obviously instead of the * you may have to change to a list of field names to 
avoid fieldname collision on the two tables.
Thanks,
Ash
http://www.ashleysheridan.co.uk




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



RE: [PHP] SQL Syntax

2010-06-15 Thread Ashley Sheridan
On Wed, 2010-06-16 at 03:23 +0200, Jan Reiter wrote:

 Thanks. That was my first attempt, too. Only this will throw out rows, that 
 meet only one of the conditions, too. For example, I would get all pictures 
 that are bigger than 100, regardless of type, and all pictures that are of 
 type jpg, no matter the size. 
 
 Doing it with a view would be an option, but that would immensely decrease 
 flexibility.  
 
 I guess I have to keep on cooking my brain on this ;-) 
 
 I think I did it before, a few years ago when MySQL didn't support views yet, 
 but I can't find that stuff ... 
 
 @Dan: Thanks for forwarding my mail to the MySQL List!
 
 Regards,
 Jan
 
 
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
 Sent: Wednesday, June 16, 2010 3:09 AM
 To: Jan Reiter
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] SQL Syntax
 
 On Wed, 2010-06-16 at 02:58 +0200, Jan Reiter wrote: 
 
 Hi folks!
 
 I'm kind of ashamed to ask a question, as I haven't followed this list very
 much lately. 
 
  
 
 This isn't exactly a PHP question, but since mysql is the most popular
 database engine used with php, I figured someone here might have an idea.
 
  
 
 I have 2 tables. Table A containing 2 fields. A user ID and a picture ID =
 A(uid,pid) and another table B, containing 3 fields. The picture ID, an
 attribute ID and a value for that attribute = B(pid,aid,value).
 
  
 
 Table B contains several rows for a single PID with various AIDs and values.
 Each AID is unique to a PID.  (e.g. AID = 1 always holding the value for the
 image size and AID = 3 always holding a value for the image type)
 
  
 
 The goal is now to join table A on table B using pid, and selecting the rows
 based on MULTIPLE  attributes. 
 
  
 
 So the result should only contain rows for images, that relate to an
 attribute ID = 1 (size) that is bigger than 100 AND!!! an attribute ID =
 5 that equals 'jpg'. 
 
  
 
 I know that there is an easy solution to this, doing it in one query and I
 have the feeling, that I can almost touch it with my fingertips in my mind,
 but I can't go that final step, if you know what I mean. AND THAT DRIVES ME
 CRAZY!!
 
  
 
 I appreciate your thoughts on this.
 
  
 
 Regards,
 
 Jan
 
 
 You'll be looking for something like this (untested):
 
 SELECT * FROM a
 LEFT JOIN b ON (a.pid = b.pid)
 WHERE (b.aid = 1 AND b.value  100) OR (b.aid = 3 AND b.value = 'jpg')
 
 Obviously instead of the * you may have to change to a list of field names to 
 avoid fieldname collision on the two tables.
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
 


I think maybe your table structure could do with a little work, as it
doesn't lend itself to simple queries. It could probably be done the way
you need with sub-queries, but as the tables become more populated and
more people are triggering the queries, this is going to become very
slow.

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




Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread Robert Cummings

Rick Dwyer wrote:

Hello all.

I'm trying to learn PHP on the fly and I have a line of code that  
contains syntax I can't find documented anywhere:


php echo check('element8');

In the above line, can someone tell me what check means?



In the above, check is a function. It is being called with parameter 
'element8'.


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] PHP Syntax Help - Check?

2010-02-24 Thread Paul M Foster
On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote:

 Rick Dwyer wrote:
 Hello all.

 I'm trying to learn PHP on the fly and I have a line of code that
 contains syntax I can't find documented anywhere:

 php echo check('element8');

 In the above line, can someone tell me what check means?


 In the above, check is a function. It is being called with parameter
 'element8'.

This is true. But perhaps more importantly, check() is not a native PHP
function. Thus it comes from some other library or group of external
functions.

Paul

-- 
Paul M. Foster

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



Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread Rick Dwyer

OK... external function... that would explain why I could not locate it.

Let me get right to the problem I am having with this code as someone  
may be able to help directly.


I have a link on a page that opens a contact form.  The link is  
mypage.php?my_id=5


So on mypage.php, I capture this value with:
$my_id=$_GET['my_id'];

I understand this much.  But when the end user submits this contact  
form they do so to formcheck.php and if formcheck.php sees a required  
field is blank, it throws it back to mypage.php with an alert.  BUT, I  
lose the value of the variable $my_id.  SO, I created a hidden field  
on mypate.php with  value=?php echo $my_id; ? and on  
formcheck.php, I added $my_id = $_Post['my_id'];


However, when formcheck.php returns me to mypage.php, $my_id is still  
blank.


Very frustrating.

Any help determining what I am doing wrong is greatly appreciated.

Thanks.



 --Rick


On Feb 25, 2010, at 12:31 AM, Paul M Foster wrote:


On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote:


Rick Dwyer wrote:

Hello all.

I'm trying to learn PHP on the fly and I have a line of code that
contains syntax I can't find documented anywhere:

php echo check('element8');

In the above line, can someone tell me what check means?



In the above, check is a function. It is being called with parameter
'element8'.


This is true. But perhaps more importantly, check() is not a native  
PHP

function. Thus it comes from some other library or group of external
functions.

Paul

--
Paul M. Foster

--
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] PHP Syntax Help - Check?

2010-02-24 Thread viraj
if you do the redirection with header('Location: /mypage.php'),
setting a variable on formcheck.php is not enough.

if you modify the header('Location: /mypage.php') to..

header('Location: /mypage.php?my_id=5')

it will take the variable to mypage.php as $_GET['my_id]

you can not expect a variable value set in to $_POST array to reflect
on a totally different page without making it a form post (aka use of
proper headers).

i guess, it's time to you to read about session_start() method and the
array $_SESSION available in php :)


~viraj

On Thu, Feb 25, 2010 at 11:22 AM, Rick Dwyer rpdw...@earthlink.net wrote:
 OK... external function... that would explain why I could not locate it.

 Let me get right to the problem I am having with this code as someone may be
 able to help directly.

 I have a link on a page that opens a contact form.  The link is
 mypage.php?my_id=5

 So on mypage.php, I capture this value with:
 $my_id=$_GET['my_id'];

 I understand this much.  But when the end user submits this contact form
 they do so to formcheck.php and if formcheck.php sees a required field is
 blank, it throws it back to mypage.php with an alert.  BUT, I lose the value
 of the variable $my_id.  SO, I created a hidden field on mypate.php with
  value=?php echo $my_id; ? and on formcheck.php, I added $my_id =
 $_Post['my_id'];

 However, when formcheck.php returns me to mypage.php, $my_id is still blank.

 Very frustrating.

 Any help determining what I am doing wrong is greatly appreciated.

 Thanks.



  --Rick


 On Feb 25, 2010, at 12:31 AM, Paul M Foster wrote:

 On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote:

 Rick Dwyer wrote:

 Hello all.

 I'm trying to learn PHP on the fly and I have a line of code that
 contains syntax I can't find documented anywhere:

 php echo check('element8');

 In the above line, can someone tell me what check means?


 In the above, check is a function. It is being called with parameter
 'element8'.

 This is true. But perhaps more importantly, check() is not a native PHP
 function. Thus it comes from some other library or group of external
 functions.

 Paul

 --
 Paul M. Foster

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





-- 
~viraj

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



Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread James McLean
On Thu, Feb 25, 2010 at 4:22 PM, Rick Dwyer rpdw...@earthlink.net wrote:
 OK... external function... that would explain why I could not locate it.

 Let me get right to the problem I am having with this code as someone may be
 able to help directly.

 I have a link on a page that opens a contact form.  The link is
 mypage.php?my_id=5

 So on mypage.php, I capture this value with:
 $my_id=$_GET['my_id'];

 I understand this much.  But when the end user submits this contact form
 they do so to formcheck.php and if formcheck.php sees a required field is
 blank, it throws it back to mypage.php with an alert.  BUT, I lose the value
 of the variable $my_id.  SO, I created a hidden field on mypate.php with
  value=?php echo $my_id; ? and on formcheck.php, I added $my_id =
 $_Post['my_id'];

 However, when formcheck.php returns me to mypage.php, $my_id is still blank.

Use the right varialble for the method you're using, so if you're
posting, use $_POST, if you're getting use $_GET..

Going by your example, $_GET is what you should probably be using,
this is usually the default method if no method is specified on the
form tag.

Cheers

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



Re: [PHP] PHP Syntax Help - Check?

2010-02-24 Thread Rick Dwyer

Hmm.  OK with the help below, I am closer.

The other fields on the page are getting passed via form fields that  
look like this:


input  type=text value=?php echo check('element9'); ?  
name=form[element9] size=40 maxlength=255

so I added:
input  type=text value=?php echo check('my_id'); ?  
name=form[my_id] size=40 maxlength=255



and formcheck.php has:

?php
//start the session
session_start();

//array of fields in form. (In the format field_name = field_label)
$form_fields = array(
element0 = 'Your Name:',
element1 = 'Your Email:',
element4 = 'Item Number:',
.
);
and I added:
my_id = 'My ID Is:',

And this works!
So when I am on mypage.php and I enter a value into the form field  
my_id it carries over and repopulates should the form fail validation.


But upon initial load of the page from my link of mypage.php?my_id=5  
(so I am not getting there via a form submit) how do I get the value  
into the form field?



 --Rick


On Feb 25, 2010, at 1:02 AM, viraj wrote:


if you do the redirection with header('Location: /mypage.php'),
setting a variable on formcheck.php is not enough.

if you modify the header('Location: /mypage.php') to..

header('Location: /mypage.php?my_id=5')

it will take the variable to mypage.php as $_GET['my_id]

you can not expect a variable value set in to $_POST array to reflect
on a totally different page without making it a form post (aka use of
proper headers).

i guess, it's time to you to read about session_start() method and the
array $_SESSION available in php :)


~viraj

On Thu, Feb 25, 2010 at 11:22 AM, Rick Dwyer rpdw...@earthlink.net  
wrote:
OK... external function... that would explain why I could not  
locate it.


Let me get right to the problem I am having with this code as  
someone may be

able to help directly.

I have a link on a page that opens a contact form.  The link is
mypage.php?my_id=5

So on mypage.php, I capture this value with:
$my_id=$_GET['my_id'];

I understand this much.  But when the end user submits this contact  
form
they do so to formcheck.php and if formcheck.php sees a required  
field is
blank, it throws it back to mypage.php with an alert.  BUT, I lose  
the value
of the variable $my_id.  SO, I created a hidden field on mypate.php  
with

 value=?php echo $my_id; ? and on formcheck.php, I added $my_id =
$_Post['my_id'];

However, when formcheck.php returns me to mypage.php, $my_id is  
still blank.


Very frustrating.

Any help determining what I am doing wrong is greatly appreciated.

Thanks.



 --Rick


On Feb 25, 2010, at 12:31 AM, Paul M Foster wrote:


On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote:


Rick Dwyer wrote:


Hello all.

I'm trying to learn PHP on the fly and I have a line of code that
contains syntax I can't find documented anywhere:

php echo check('element8');

In the above line, can someone tell me what check means?



In the above, check is a function. It is being called with  
parameter

'element8'.


This is true. But perhaps more importantly, check() is not a  
native PHP

function. Thus it comes from some other library or group of external
functions.

Paul

--
Paul M. Foster

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






--
~viraj

--
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] SQL syntax?

2008-12-05 Thread Allan Arguelles


 $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
 %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
 $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
 Impressions AS Ad_Impressions, ;
 $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
 $sql .= ORDER BY StartDate DESC;
   

You forgot the tables, plus you have an extra comma after CPM_Rate.



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



Re: [PHP] SQL syntax?

2008-12-05 Thread Terion Miller
On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles [EMAIL PROTECTED]wrote:


 
  $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate,
 '%b.
  %e, %Y %l:%i %p') AS Start_Date,
  DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
  $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
  Impressions AS Ad_Impressions, ;
  $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
  $sql .= ORDER BY StartDate DESC;
 

 You forgot the tables, plus you have an extra comma after CPM_Rate.

 well I changed it to:

  $sql = SELECT workorderform.WorkOrderID AS Work_Order_ID,
 DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date,
 ;
 $sql .= workorderform.Advertiser AS
 Advertiser_Name,workorderform.AccountNum AS Account_Number,
 workorderform.Impressions AS Ad_Impressions, ;
 $sql .= workorderform.AdSize AS Ad_Size,  workorderform.CPM AS
 CPM_Rate ;
 $sql .= ORDER BY StartDate DESC;

 and got the same error




Re: [PHP] SQL syntax?

2008-12-05 Thread Allan Arguelles
Umm.. I meant you need to put

$sql .= FROM workorderform ;

between these:

$sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
$sql .= ORDER BY StartDate DESC;


:)


Terion Miller wrote:
 On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles [EMAIL PROTECTED]wrote:

   
 $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate,
   
 '%b.
 
 %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
 $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
 Impressions AS Ad_Impressions, ;
 $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
 $sql .= ORDER BY StartDate DESC;

   
 You forgot the tables, plus you have an extra comma after CPM_Rate.

 well I changed it to:

  $sql = SELECT workorderform.WorkOrderID AS Work_Order_ID,
 DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date,
 ;
 $sql .= workorderform.Advertiser AS
 Advertiser_Name,workorderform.AccountNum AS Account_Number,
 workorderform.Impressions AS Ad_Impressions, ;
 $sql .= workorderform.AdSize AS Ad_Size,  workorderform.CPM AS
 CPM_Rate ;
 $sql .= ORDER BY StartDate DESC;

 and got the same error


 

   


Re: [PHP] SQL syntax?

2008-12-05 Thread Terion Miller
ah...I also though it was because I didn't have a statement like where
adsize = adsize or something but I tried that and got the same error I have
been getting ...

You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'FROM
workorderform, WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC' at
line 2

and why does it keep saying line 2...
here is the snippet as it is now:

 $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
%e, %Y %l:%i %p') AS Start_Date,
DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
$sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
Impressions AS Ad_Impressions, ;
$sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ;
$sql.= FROM workorderform, ;
$sql .=  WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC;


On Fri, Dec 5, 2008 at 4:14 PM, Allan Arguelles [EMAIL PROTECTED]wrote:

  Umm.. I meant you need to put

 $sql .= FROM workorderform ;

 between these:

 $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
 $sql .= ORDER BY StartDate DESC;


 :)


 Terion Miller wrote:

 On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles [EMAIL PROTECTED] [EMAIL 
 PROTECTED]wrote:



  $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate,


  '%b.


  %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
 $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
 Impressions AS Ad_Impressions, ;
 $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
 $sql .= ORDER BY StartDate DESC;



  You forgot the tables, plus you have an extra comma after CPM_Rate.

 well I changed it to:

  $sql = SELECT workorderform.WorkOrderID AS Work_Order_ID,
 DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date,
 ;
 $sql .= workorderform.Advertiser AS
 Advertiser_Name,workorderform.AccountNum AS Account_Number,
 workorderform.Impressions AS Ad_Impressions, ;
 $sql .= workorderform.AdSize AS Ad_Size,  workorderform.CPM AS
 CPM_Rate ;
 $sql .= ORDER BY StartDate DESC;

 and got the same error







Re: [PHP] SQL syntax?

2008-12-05 Thread Allan Arguelles
Try this:

 $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
%e, %Y %l:%i %p') AS Start_Date,
DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
$sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
Impressions AS Ad_Impressions, ;
$sql .= AdSize AS Ad_Size, CPM AS CPM_Rate ;
$sql.= FROM workorderform ;
$sql .=  WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC;


I just removed extra commas from CPM_Rate and workorderform


Terion Miller wrote:
 ah...I also though it was because I didn't have a statement like where
 adsize = adsize or something but I tried that and got the same error I have
 been getting ...

 You have an error in your SQL syntax; check the manual that corresponds to
 your MySQL server version for the right syntax to use near 'FROM
 workorderform, WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC' at
 line 2

 and why does it keep saying line 2...
 here is the snippet as it is now:

  $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
 %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
 $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
 Impressions AS Ad_Impressions, ;
 $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ;
 $sql.= FROM workorderform, ;
 $sql .=  WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC;


 On Fri, Dec 5, 2008 at 4:14 PM, Allan Arguelles [EMAIL PROTECTED]wrote:

   
  Umm.. I meant you need to put

 $sql .= FROM workorderform ;

 between these:

 $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
 $sql .= ORDER BY StartDate DESC;


 :)


 Terion Miller wrote:

 On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles [EMAIL PROTECTED] [EMAIL 
 PROTECTED]wrote:



  $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate,


  '%b.


  %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
 $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
 Impressions AS Ad_Impressions, ;
 $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
 $sql .= ORDER BY StartDate DESC;



  You forgot the tables, plus you have an extra comma after CPM_Rate.

 well I changed it to:

  $sql = SELECT workorderform.WorkOrderID AS Work_Order_ID,
 DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date,
 ;
 $sql .= workorderform.Advertiser AS
 Advertiser_Name,workorderform.AccountNum AS Account_Number,
 workorderform.Impressions AS Ad_Impressions, ;
 $sql .= workorderform.AdSize AS Ad_Size,  workorderform.CPM AS
 CPM_Rate ;
 $sql .= ORDER BY StartDate DESC;

 and got the same error





 

   


Re: [PHP] SQL syntax?

2008-12-05 Thread Terion Miller
Excellent Allan thanks so much, sometimes I think php is causing me
blindness!!
Terion

On Fri, Dec 5, 2008 at 4:26 PM, Allan Arguelles [EMAIL PROTECTED]wrote:

  Try this:

  $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
 %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
 $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
 Impressions AS Ad_Impressions, ;
 $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate ;
 $sql.= FROM workorderform ;
 $sql .=  WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC;


 I just removed extra commas from CPM_Rate and workorderform


 Terion Miller wrote:

 ah...I also though it was because I didn't have a statement like where
 adsize = adsize or something but I tried that and got the same error I have
 been getting ...

 You have an error in your SQL syntax; check the manual that corresponds to
 your MySQL server version for the right syntax to use near 'FROM
 workorderform, WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC' at
 line 2

 and why does it keep saying line 2...
 here is the snippet as it is now:

  $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
 %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
 $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
 Impressions AS Ad_Impressions, ;
 $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ;
 $sql.= FROM workorderform, ;
 $sql .=  WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC;


 On Fri, Dec 5, 2008 at 4:14 PM, Allan Arguelles [EMAIL PROTECTED] [EMAIL 
 PROTECTED]wrote:



   Umm.. I meant you need to put

 $sql .= FROM workorderform ;

 between these:

 $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
 $sql .= ORDER BY StartDate DESC;


 :)


 Terion Miller wrote:

 On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles [EMAIL PROTECTED] [EMAIL 
 PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]wrote:



  $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate,


  '%b.


  %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
 $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
 Impressions AS Ad_Impressions, ;
 $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
 $sql .= ORDER BY StartDate DESC;



  You forgot the tables, plus you have an extra comma after CPM_Rate.

 well I changed it to:

  $sql = SELECT workorderform.WorkOrderID AS Work_Order_ID,
 DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date,
 DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date,
 ;
 $sql .= workorderform.Advertiser AS
 Advertiser_Name,workorderform.AccountNum AS Account_Number,
 workorderform.Impressions AS Ad_Impressions, ;
 $sql .= workorderform.AdSize AS Ad_Size,  workorderform.CPM AS
 CPM_Rate ;
 $sql .= ORDER BY StartDate DESC;

 and got the same error










Re: [PHP] SQL syntax?

2008-12-05 Thread Ashley Sheridan
On Fri, 2008-12-05 at 16:51 -0600, Terion Miller wrote:
 Excellent Allan thanks so much, sometimes I think php is causing me
 blindness!!
 Terion
 
 On Fri, Dec 5, 2008 at 4:26 PM, Allan Arguelles [EMAIL PROTECTED]wrote:
 
   Try this:
 
   $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
  %e, %Y %l:%i %p') AS Start_Date,
  DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
  $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
  Impressions AS Ad_Impressions, ;
  $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate ;
  $sql.= FROM workorderform ;
  $sql .=  WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC;
 
 
  I just removed extra commas from CPM_Rate and workorderform
 
 
  Terion Miller wrote:
 
  ah...I also though it was because I didn't have a statement like where
  adsize = adsize or something but I tried that and got the same error I have
  been getting ...
 
  You have an error in your SQL syntax; check the manual that corresponds to
  your MySQL server version for the right syntax to use near 'FROM
  workorderform, WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC' at
  line 2
 
  and why does it keep saying line 2...
  here is the snippet as it is now:
 
   $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b.
  %e, %Y %l:%i %p') AS Start_Date,
  DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
  $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
  Impressions AS Ad_Impressions, ;
  $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ;
  $sql.= FROM workorderform, ;
  $sql .=  WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC;
 
 
  On Fri, Dec 5, 2008 at 4:14 PM, Allan Arguelles [EMAIL PROTECTED] [EMAIL 
  PROTECTED]wrote:
 
 
 
Umm.. I meant you need to put
 
  $sql .= FROM workorderform ;
 
  between these:
 
  $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
  $sql .= ORDER BY StartDate DESC;
 
 
  :)
 
 
  Terion Miller wrote:
 
  On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles [EMAIL PROTECTED] [EMAIL 
  PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]wrote:
 
 
 
   $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate,
 
 
   '%b.
 
 
   %e, %Y %l:%i %p') AS Start_Date,
  DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ;
  $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number,
  Impressions AS Ad_Impressions, ;
  $sql .= AdSize AS Ad_Size,  CPM AS CPM_Rate, ;
  $sql .= ORDER BY StartDate DESC;
 
 
 
   You forgot the tables, plus you have an extra comma after CPM_Rate.
 
  well I changed it to:
 
   $sql = SELECT workorderform.WorkOrderID AS Work_Order_ID,
  DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date,
  DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date,
  ;
  $sql .= workorderform.Advertiser AS
  Advertiser_Name,workorderform.AccountNum AS Account_Number,
  workorderform.Impressions AS Ad_Impressions, ;
  $sql .= workorderform.AdSize AS Ad_Size,  workorderform.CPM AS
  CPM_Rate ;
  $sql .= ORDER BY StartDate DESC;
 
  and got the same error
 
 
If I run into troubles with SQL (specifically MySQL) I run the query in
phpMyAdmin, which is so helpful. If you're using another SQL variant
like that god-forsaken M$ SQL, then you have to use the appropriate tool
to interface with the database there. It sure helps remove the SQL
problems from PHP, which was your problem in this case.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Weird Syntax Error

2008-11-14 Thread Thodoris



-Original Message-
From: Edgar da Silva (Fly2k) [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 13, 2008 9:39 AM
To: Kyle Terry
Cc: PHP General Mailing List
Subject: Re: [PHP] Weird Syntax Error

Try:

$insert = INSERT INTO release_file_upload (upl_file_name,
upl_file_type,
upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES
('$filename',
'{$_SESSION['upload']['type']}', '{$_SESSION['upload']['size']}',
now(),
'$username', '$path', '$release_id');

2008/11/13 Kyle Terry [EMAIL PROTECTED]:


I keep getting this syntax error on the following string...

syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING
  

or


T_VARIABLE or T_NUM_STRING

$insert = INSERT INTO release_file_upload (upl_file_name,
  

upl_file_type,


upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES
  

('$filename',


'$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
'$username', '$path', '$release_id');
  


Yup... I was just about to say--you need to wrap your array references with curly braces {}. 
Otherwise, I believe PHP will look for a primitive variable named $_SESSION, not an array whose 
indices are upload and size.

HTH,


Todd Boyd
Web Programmer
  


You could also use the . operator instead and quote using the quote 
method if you are using PDO.


But this is a personal style I guess.

--
Thodoris



Re: [PHP] Weird Syntax Error

2008-11-13 Thread Stut

On 13 Nov 2008, at 15:28, Kyle Terry wrote:

I keep getting this syntax error on the following string...

syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING  
or

T_VARIABLE or T_NUM_STRING

$insert = INSERT INTO release_file_upload (upl_file_name,  
upl_file_type,
upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES  
('$filename',

'$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
'$username', '$path', '$release_id');


I can't see anything wrong with that line (except that I don't think  
those variables will interpolate correctly, and you don't seem to be  
escaping stuff going into your SQL which is, ya know, bad!!). Your  
problem is probably on the line before, possible several lines before.  
Post a bit of the surrounding code.


-Stut

--
http://stut.net/

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



Re: [PHP] Weird Syntax Error

2008-11-13 Thread Michael Kubler

Hi Kyle,
The line looks fine in my text editor (SciTE).
Have you checked the line above it is properly enclosed and ended?

Michael Kubler
*G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz



Kyle Terry wrote:

I keep getting this syntax error on the following string...

syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING or
T_VARIABLE or T_NUM_STRING

$insert = INSERT INTO release_file_upload (upl_file_name, upl_file_type,
upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES ('$filename',
'$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
'$username', '$path', '$release_id');

  


Re: [PHP] Weird Syntax Error

2008-11-13 Thread Edgar da Silva (Fly2k)
Try:

$insert = INSERT INTO release_file_upload (upl_file_name, upl_file_type,
upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES ('$filename',
'{$_SESSION['upload']['type']}', '{$_SESSION['upload']['size']}', now(),
'$username', '$path', '$release_id');

2008/11/13 Kyle Terry [EMAIL PROTECTED]:
 I keep getting this syntax error on the following string...

 syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING or
 T_VARIABLE or T_NUM_STRING

 $insert = INSERT INTO release_file_upload (upl_file_name, upl_file_type,
 upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES ('$filename',
 '$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
 '$username', '$path', '$release_id');

 --
 Kyle Terry | www.kyleterry.com




-- 
Abraços
Edgar Ferreira da Silva
Engenheiro de Software
Campinas - SP
(19) 8110-0733

-
Aprenda PHP, cole códigos, saiba das vagas de empregos:
http://www.manjaphp.com.br


RE: [PHP] Weird Syntax Error

2008-11-13 Thread Boyd, Todd M.
 -Original Message-
 From: Edgar da Silva (Fly2k) [mailto:[EMAIL PROTECTED]
 Sent: Thursday, November 13, 2008 9:39 AM
 To: Kyle Terry
 Cc: PHP General Mailing List
 Subject: Re: [PHP] Weird Syntax Error
 
 Try:
 
 $insert = INSERT INTO release_file_upload (upl_file_name,
 upl_file_type,
 upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES
 ('$filename',
 '{$_SESSION['upload']['type']}', '{$_SESSION['upload']['size']}',
 now(),
 '$username', '$path', '$release_id');
 
 2008/11/13 Kyle Terry [EMAIL PROTECTED]:
  I keep getting this syntax error on the following string...
 
  syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING
 or
  T_VARIABLE or T_NUM_STRING
 
  $insert = INSERT INTO release_file_upload (upl_file_name,
 upl_file_type,
  upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES
 ('$filename',
  '$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
  '$username', '$path', '$release_id');

Yup... I was just about to say--you need to wrap your array references with 
curly braces {}. Otherwise, I believe PHP will look for a primitive variable 
named $_SESSION, not an array whose indices are upload and size.

HTH,


Todd Boyd
Web Programmer


Re: [PHP] Re: syntax question

2007-03-26 Thread Richard Lynch
None of the previous posts added any security...

They all ONLY provided different syntax to leave your database wide
open for abuse.

This is much safer:
$cat_name_sql = myqsl_real_escape_string($_POST['cat_name']);
$query = insert into categories (category_name) values
('$cat_name_sql');

You could/should also check for what you consider valid characters in
a 'cat_name'

if (!preg_match(|^[a-z0-9_ -]+$|i', $_POST['cat_name'])){
  //tell the user their cat_name is invalid, and don't do the INSERT
}

On Mon, March 26, 2007 10:14 am, Ross wrote:
 thanks.

 Ross [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Can I put post values directly into insert statements?

 $query = INSERT INTO categories (category_name) VALUES
 ('$_POST['cat_name']);

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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] heredoc syntax vs Double-Quotes

2006-03-15 Thread Chris

Chris Kennon wrote:

Hi,

Not looking to start some pugilistic fray, but when is using heredoc  
advisable over Double-Quotes?


Probably with really long strings or pages of data so you don't have to 
worry about quotes etc.


Pretty much comes down to personal preference I think.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] heredoc syntax vs Double-Quotes

2006-03-15 Thread Paul Novitski

At 07:06 PM 3/15/2006, Chris Kennon wrote:

when is using heredoc advisable over Double-Quotes?



I love using heredoc primarily because it helps me separate logic 
from markup when generating HTML.  The text in a heredoc expression 
is vanilla, no escape sequences needed, so there's less worry about 
typos.  I find it one of the strongest features of PHP as compared to 
other scripting languages.


Paul 


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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Larry E. Ullman
I'm trying to expand my understanding of PHP by looking at some pre- 
built code modules.  I don't fully understand the syntax $site-Run 
(); in the following code.  Can someone offer a helpful explanation?


?php

//define(PB_CRYPT_LINKS , 1);
define(_LIBPATH,./lib/);
require_once _LIBPATH . site.php;

$site = new CSite(./site.xml,true);
$site-Run();

?


The $site variable is an object, specifically an instance of the  
CSite class. Run() is a method (i.e., a function) defined within this  
class, so the statement $site-Run() executes that function. This is  
basic object oriented stuff which you may not have run across before.


Hope that helps,
larry

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Mikey

Lowell Herbert wrote:

I'm trying to expand my understanding of PHP by looking at some pre- 
built code modules.  I don't fully understand the syntax $site-Run 
(); in the following code.  Can someone offer a helpful explanation?


?php

//define(PB_CRYPT_LINKS , 1);
define(_LIBPATH,./lib/);
require_once _LIBPATH . site.php;

$site = new CSite(./site.xml,true);
$site-Run();

?


Run() is a method of the CSite class - you will need to look in the 
defination of that class to find out what it does,


Mikey

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Lowell Herbert


On Sep 27, 2005, at 2:16 PM, Mikey wrote:


Lowell Herbert wrote:


I'm trying to expand my understanding of PHP by looking at some  
pre- built code modules.  I don't fully understand the syntax  
$site-Run (); in the following code.  Can someone offer a  
helpful explanation?


?php

//define(PB_CRYPT_LINKS , 1);
define(_LIBPATH,./lib/);
require_once _LIBPATH . site.php;

$site = new CSite(./site.xml,true);
$site-Run();

?



Run() is a method of the CSite class - you will need to look in the  
defination of that class to find out what it does,


Mikey



Thanks for all the responses.  I understand that $site is an instance  
of the class CSite, and that Run() is a function in that class.  I do  
not understand what the operater - means, and what meaning the  
result of the function Run() has to $site.  Clarification anyone?


Thanks in advance,
Lowell

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Jasper Bryant-Greene

Lowell Herbert wrote:


Thanks for all the responses.  I understand that $site is an instance  
of the class CSite, and that Run() is a function in that class.  I do  
not understand what the operater - means, and what meaning the  
result of the function Run() has to $site.  Clarification anyone?




The operator - in this context ( $site-Run() ) sort of means the 
function Run() inside the object $site.


The result of the function (if there is one) is thrown away, because you 
don't assign it to anything. If you did this then it would be assigned 
to something:


$result = $site-Run();

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread A.J. Brown
Lowell,

The - operator was taken from the pointer operator in C.  It's used to 
access a method or variable within an INSTANCE of an object, as opposed to 
the :: operator, which is used to access a static method of a class.  Note 
the difference between a class and an object -- an object is an instance of 
a class.

if Run() is a static method (I.E. it has no references to $this) and 
$site is an instance of SiteClass, the following are equivalent:

$site-Run();
SiteClass::Run();

If you're still confused, I can go further into the difference between an 
Object and a Class.

-- 

Sincerely,

A.J. Brown
BitNotion Technologies


Lowell Herbert [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 On Sep 27, 2005, at 2:16 PM, Mikey wrote:

 Lowell Herbert wrote:


 I'm trying to expand my understanding of PHP by looking at some  pre- 
 built code modules.  I don't fully understand the syntax  $site-Run 
 (); in the following code.  Can someone offer a  helpful explanation?

 ?php

 //define(PB_CRYPT_LINKS , 1);
 define(_LIBPATH,./lib/);
 require_once _LIBPATH . site.php;

 $site = new CSite(./site.xml,true);
 $site-Run();

 ?


 Run() is a method of the CSite class - you will need to look in the 
 defination of that class to find out what it does,

 Mikey


 Thanks for all the responses.  I understand that $site is an instance  of 
 the class CSite, and that Run() is a function in that class.  I do  not 
 understand what the operater - means, and what meaning the  result of 
 the function Run() has to $site.  Clarification anyone?

 Thanks in advance,
 Lowell 

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Lowell Herbert


On Sep 27, 2005, at 4:19 PM, Jasper Bryant-Greene wrote:


Lowell Herbert wrote:

Thanks for all the responses.  I understand that $site is an  
instance  of the class CSite, and that Run() is a function in that  
class.  I do  not understand what the operater - means, and  
what meaning the  result of the function Run() has to $site.   
Clarification anyone?




The operator - in this context ( $site-Run() ) sort of means the  
function Run() inside the object $site.


The result of the function (if there is one) is thrown away,  
because you don't assign it to anything. If you did this then it  
would be assigned to something:


$result = $site-Run();



Thank you for your clear explanation!!!
Lowell

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



Re: [PHP]PHP Syntax Notation

2005-09-27 Thread Andy Pieters
Hi

As a complement to the answers you have had here I wish to ammend the 
following.

The Run in the example is a function, and because this function is inside a 
Class object, it is called a method.

A class is a set of variables (properties) and functions (methods) that you 
can create instances of.  

I suggest you consult the complete php documentation with user comments and 
examples at php.net.  Available in many languages.  This manual is used by 
many -including me- on a daily basis.


Hope this helps


With kind regards


Andy

On Tuesday 27 September 2005 22:29, Lowell Herbert wrote:
 On Sep 27, 2005, at 4:19 PM, Jasper Bryant-Greene wrote:
  Lowell Herbert wrote:
  Thanks for all the responses.  I understand that $site is an
  instance  of the class CSite, and that Run() is a function in that
  class.  I do  not understand what the operater - means, and
  what meaning the  result of the function Run() has to $site.
  Clarification anyone?
 
  The operator - in this context ( $site-Run() ) sort of means the
  function Run() inside the object $site.
 
  The result of the function (if there is one) is thrown away,
  because you don't assign it to anything. If you did this then it
  would be assigned to something:
 
  $result = $site-Run();

 Thank you for your clear explanation!!!
 Lowell

-- 
Registered Linux User Number 379093
Now listening to [silence]

   amaroK::the Coolest Media Player in the known Universe!


   Cockroaches and socialites are the only things that can 
   stay up all night and eat anything.
Herb Caen
--
-- --BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++
L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e$@ h++(*) r--++ y--()
-- ---END GEEK CODE BLOCK--
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/

--


pgpfMLvuAfYVj.pgp
Description: PGP signature


Re: [PHP] Re: syntax error, unexpected T_STRING

2005-07-18 Thread Jochem Maas

George B wrote:

George B wrote:


I am trying to connect to a datbase:


mysql_select_db ('database')
or die (couldnt connect to databse)

What is wrong here?
This is the error:

Parse error: syntax error, unexpected T_STRING in file name on line 12


this code works though


the semicolon delimits a single statement (however complex).
tabs and spaces have no 'token' meaning. as in the parser doesn't give a
hoot if you write the whole scripton a single line. (I use the word statement
but I'm not sure that's the correct name for it - anyone care to add?)
if/else/else if/while/for(/etc?) have the quality that you can leave
out the braces if you are only wish to conditionally execute 1 statement
... e.g:

// run this on the cmdline or change the '\n's to 'br /'
$a = $b = $c = A; $d = array(A); $e = B;

echo \nplainfoos and foofoos:\n;

// this one you dont see (the silentfoo)
if (!in_array(str_replace($a,$b,$c),$d))
echo silentfoo\n;

// this is like the next one
if (in_array(str_replace($a,$b,$c),$d))
echo foo\n;

// this is like the previous one
if (in_array(str_replace($a,$b,$c),$d)) {
echo foo\n;
}

///

// this is not like the next one
if (in_array(str_replace($a,$b,$c),array($e)))
echo foo;
echo foo\n;

// this is not like the previous one
if (in_array(str_replace($a,$b,$c),$d)) {
echo foo;
echo foo\n;
}

and now a word from our sponsor for this evening about die()ing ...


$db = mysql_connect(localhost, myaccount, mypass) or die(Could 
not connect.);


?
function yourmoney($kids = 1) { return 80 - (90 * $kids); }
function yourlife($lastWords = errr) { die(strval($s)); }

yourmoney() or yourlife(is no choice at all.);
?

(it has to be added that we are talking about those special kind of
children that are capable of 'breaking' your friends Hummer ;-))

[not a true story - just popped into my head.]


if(!$db)
die(no db);
if(!mysql_select_db(database,$db))
 die(No database selected.);


die(); die(); die() ... see it doesn't even sound very nice ;-)

have fun!





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



RE: [PHP] Right syntax for max value??

2005-06-14 Thread Jay Blanchard
[snip]
$getnewstitle = SELECT newstitle FROM `news` WHERE news_id = ( SELECT
max( news_id ) FROM news ) ;

Does anybody know the right syntax?
[/snip]


Yes, people on the MySQL list.

Actually you do not need the sub-select here (your remote host may not
have a MySQL version that supports sub-queries)

$getnewstitle = SELECT MAX(news_id), newstitle FROM `news` ;

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



Re: [PHP] Right syntax for max value??

2005-06-14 Thread John Nichel

twistednetadmin wrote:

I am making a table at my homepage that automatically collects the
latest news from mysql db.
 I have got it to work at my own server at home, but not at
www.torewestre.com (my remote site)

Local settings:(WinXP Pro) Apache 2.0.54, PHP 5.0.4 and MySQL 4.1.11

Remote settings:(Unix) Apache 1.3.27, PHP 4.3.4 and MySQL 3.23.54

This is the query that works on localhost:


$getnewstitle = SELECT newstitle FROM `news` WHERE news_id = ( SELECT
max( news_id ) FROM news ) ;

What it does:

collects the newstitle from the field where PRIMARY key(news_id) is
the highest auto_increment number.

This works just as excpected on localhost but not on remote.

Does anybody know the right syntax?


Not a php question, and you can't do this in MySQL 3.x

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Right syntax for max value??

2005-06-14 Thread Brandon Ryan
I would do $getnewstitle = SELECT newstitle FROM `news` ORDER BY news_id 
DESC LIMIT 1;
 This sorts the records by news_id and the limit 1 only returns the first 
record.

On 6/14/05, twistednetadmin [EMAIL PROTECTED] wrote: 
 
 I am making a table at my homepage that automatically collects the
 latest news from mysql db.
 I have got it to work at my own server at home, but not at
 www.torewestre.com http://www.torewestre.com (my remote site)
 
 Local settings:(WinXP Pro) Apache 2.0.54, PHP 5.0.4 and MySQL 4.1.11
 
 Remote settings:(Unix) Apache 1.3.27, PHP 4.3.4 and MySQL 3.23.54
 
 This is the query that works on localhost:
 
 
 $getnewstitle = SELECT newstitle FROM `news` WHERE news_id = ( SELECT
 max( news_id ) FROM news ) ;
 
 What it does:
 
 collects the newstitle from the field where PRIMARY key(news_id) is
 the highest auto_increment number.
 
 This works just as excpected on localhost but not on remote.
 
 Does anybody know the right syntax?
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



RE: [PHP] Right syntax for max value??

2005-06-14 Thread Neal Carmine
Mysql 3.23 does not support the subquery you are using in your sql
statement.  

Check http://dev.mysql.com/doc/mysql/en/subqueries.html for more
information.

Neal

-Original Message-
From: twistednetadmin [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 14, 2005 9:44 AM
To: php-general@lists.php.net
Subject: [PHP] Right syntax for max value??

I am making a table at my homepage that automatically collects the
latest news from mysql db.
 I have got it to work at my own server at home, but not at
www.torewestre.com (my remote site)

Local settings:(WinXP Pro) Apache 2.0.54, PHP 5.0.4 and MySQL 4.1.11

Remote settings:(Unix) Apache 1.3.27, PHP 4.3.4 and MySQL 3.23.54

This is the query that works on localhost:


$getnewstitle = SELECT newstitle FROM `news` WHERE news_id = ( SELECT
max( news_id ) FROM news ) ;

What it does:

collects the newstitle from the field where PRIMARY key(news_id) is
the highest auto_increment number.

This works just as excpected on localhost but not on remote.

Does anybody know the right syntax?

-- 
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] sql syntax problem

2004-12-13 Thread Richard Lynch
Merlin wrote:
 SELECT c.name AS city
 FROM geo_de.geodb_locations AS c, fix.user AS u
 WHERE u.user_id =4 AND c.plz
 LIKE  %u.plz%;

I believe you want something not unlike this:

WHERE u.user_id = 4
  AND c.plz LIKE concat('%', u.plz, '%')

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] sql syntax problem

2004-12-13 Thread Thomas Munz
This is the PHP mailing list, not the SQL mailing list ;)

but here is the syntax ( not tested ):

SELECT 
   c.name AS city
FROM 
   geodb_locations AS c,
   user AS u
WHERE 
   u.user_id = 4
   AND
   c.plz LIKE  u.plz;

 Hello everybody,

 I am trying to create a sql query with php and I do have a syntax problem
 with the mysql query.
 One row is called plz and I would like to search for a value inside that
 with a like statement. Problem is, the system takes the u.plz as a
 character not as a table element:

 LIKE  %u.plz%

 Has anybody an idea how the correct sytnax is? I am lost here.

 Thank you in advance,

 Merlin

 PS: This is the complete statement:
 SELECT c.name AS city
 FROM geo_de.geodb_locations AS c, fix.user AS u
 WHERE u.user_id =4 AND c.plz
 LIKE  %u.plz%;

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


Re: [PHP] Re: Syntax problem - dynamic static member access

2004-11-07 Thread Jake Press
Jason Barnett wrote:
Jake, as you probably already know you usually have to give the class 
name when attempting to get a static variable, i.e.

YourClassName::$bob;
You *can* dynamically refer to a static class variable from within an 
object without knowing the name of the class; this is what self is 
for.  i.e.

class YourClassName {
  function getStatic($var) {
return self::$var;
  }
}
Hi Jason,
Thanks for your response. :)
That doesnt seem to be an answer at all applicable to my question tho...
Ofcourse i realise you need to give the class name when attempting to 
get a static variable...
heh... im sure it would be interesting referencing a class without its 
name :)

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


Re: [PHP] Re: Syntax problem - dynamic static member access

2004-11-07 Thread Jake Press
Thanks Tul,
Okay, so its a limitation :(
I cant find the line of posts, any idea on it - or possible keywords i 
can google with ?

I'd like to find out the reasons behind why this a fixed limitation
Best Regards
Jake Press
M. Sokolewicz wrote:
hi,
it's a limitation, and not allowed in PHP. There was a whole line of 
posts about it in internals.

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


Re: [PHP] PHP5 syntax question

2004-11-04 Thread Simas Toleikis
Gerard Samuel wrote:
I dont see it in the documentation, but I've seen samples of code using
something to the effect of -
$foo-method1()-method2()

It's called object dereferencing and its not implemented in PHP4. It is 
avalaible in PHP5.
If method1() returns an instance of some object then the returned object 
method2() will be called.

I think PHP5 docs are not full yet. Wasnt there supposed to be 
namespaces in PHP5? PHP documentation doesnt even mentions them...

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


Re: [PHP] PHP5 syntax question

2004-11-04 Thread Thomas Goyne
On Fri, 05 Nov 2004 09:19:58 +0200, Simas Toleikis [EMAIL PROTECTED]  
wrote:

I think PHP5 docs are not full yet. Wasnt there supposed to be  
namespaces in PHP5? PHP documentation doesnt even mentions them...
No, they were cut, and it is highly doubtful they will show up any time  
before php6.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
http://www.smempire.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] heredoc syntax

2004-10-20 Thread Janet Valade
Adil wrote:
anyone know why heredoc syntax might not work with php5/apache installed.  I
can't get even the simplest strings in heredoc syntax to work and I've tried
just cutting and pasting other peoples stuff in that syntax as well, and
still no luck
thx.
Adil.
Heredoc syntax is pretty rigid and it's easy to have it wrong invisibly.
$varname = END
Text of string
END;
The first END must be at the end of the line, nothing after it, not even 
a blank space. The last END must be at the beginning of the line, not 
before it, not even a blank space.

Janet

--
Janet Valade -- janet.valade.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] heredoc syntax

2004-10-20 Thread Matthew Weier O'Phinney
* Janet Valade [EMAIL PROTECTED]:
 Adil wrote:

 anyone know why heredoc syntax might not work with php5/apache installed.  I
 can't get even the simplest strings in heredoc syntax to work and I've tried
 just cutting and pasting other peoples stuff in that syntax as well, and
 still no luck

 Heredoc syntax is pretty rigid and it's easy to have it wrong invisibly.
^
That's the key -- whitespace is invisible to the naked eye typically.

 $varname = END
 Text of string
 END;

 The first END must be at the end of the line, nothing after it, not even 
 a blank space. The last END must be at the beginning of the line, not 
 before it, not even a blank space.

And don't forget that the last END must be followed by a semi-colon
ONLY, no other characters on that line... ;-)

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



RE: [PHP] what syntax error are they talking about?

2004-09-30 Thread Jay Blanchard
[snip]
Error message:
You have an error in your SQL syntax. Check the manual that 
corresponds to your MySQL server version for the right syntax to use 
near '(20),username text (10),password varchar (10))' at line 1
[/snip]


We'd have to see the whole query. Can you echo $sql and give us the
whole thing?

[snip]
A separate question:
What is the meaning of the . on each end of the 
.$_POST[field_length][$i]. ?
[/snip]

Those are concatenation operators. If I say foo . bar it becomes foobar

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



Re: [PHP] if syntax using multiple conditions

2004-09-15 Thread Brian Anderson
Thanks! And, *wow* yes I just did try php2asp. Pretty good translation,
although a few things need adjusting, it seems to do a remarkable job. I'll
definitely have to play with it some more.

:)

-Brian

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



Re: [PHP] if syntax using multiple conditions

2004-09-13 Thread raditha dissanayake
Brian Anderson wrote:
What is the proper syndax in an if statement for containing multiple conditions?
 

both examples you have given are valid but their logic is slightly 
different.

example:
if ( condition1  condition2 ) {
   dothis;
}
if ( condition1  (condition2 || condition3) ) {
   dothis;
}
I am trying to translate this from asp to php:
 

how about using the asp2php program?
--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] if syntax using multiple conditions

2004-09-13 Thread Greg Donald
On Mon, 13 Sep 2004 11:32:00 -0500, Brian Anderson
[EMAIL PROTECTED] wrote:
 What is the proper syndax in an if statement for containing multiple conditions?
 
 example:
 
 if ( condition1  condition2 ) {
 
 dothis;
 }
 
 if ( condition1  (condition2 || condition3) ) {
 
 dothis;
 }

Looks good to me.

 I am trying to translate this from asp to php:
 
 If WhichAction = 7 And (InStr(filename, \) Or InStr(filename, /) Or 
 (Left(filename, 1) = chr(32)) Or InStr(filename, *) Or InStr(filename, ?) Or 
 InStr(filename, |) Or InStr(filename, ) Or InStr(filename, ) Or 
 InStr(filename, :) Or InStr(filename, ) Or InStr(filename, ')) Then
   messages = Bad filename
   filename = 
   WhichAction = 0
 End If

I'd use a regular expression so as to match all those symbols with one
command.  Check out eregi() or maybe strstr().


-- 
Greg Donald
http://destiney.com/

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



Re: [PHP] if syntax using multiple conditions

2004-09-13 Thread John Nichel
Brian Anderson wrote:
What is the proper syndax in an if statement for containing multiple conditions?
example:
if ( condition1  condition2 ) {
dothis;
}
if ( condition1  (condition2 || condition3) ) {
dothis;
}

Both are valid.  First example will validate if both condition1 and 
condition2 evaluate to true (they're set, and not null or false, etc.).

Second example will validate if condition1 evaluates to true AND EITHER 
condition2 OR condition3 evaluate to true

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] TAB Syntax

2004-06-29 Thread Matthew Sims


 I know I'm probably going to get flamed for this but it is only a
 development site but I am having some trouble getting the syntax right for
 using the tab when echoing information. My current command is:

  print_r(Host: $hostbrUser: $userbrPassword: $password);

 I've tried:

  print_r(Host: \t$hostbrUser: $userbrPassword: $password);

 and god knows what else with the brackets etc.

 Any ideas...?


I think your understanding of print_r is a little fuzzy.
Try just using print.

--Matthew Sims
--http://killermookie.org


 --
 -
  Michael Mason
  Arras People
  www.arraspeople.co.uk
 -

 --
 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] Class Syntax Help or Globals issue

2004-06-04 Thread Bob Pillford
Thanks very much!
Marek Kilimajer wrote:
bob pilly wrote:
Hi All
I am new to classes and are trying to work out whether
they will make my coding experience easier. I have
written the following test class which is trying to
take three variables from a mssql query and add them
as variables in a new class. This isnt working as i
keep getting an error that says ;
Warning: Missing argument 1 for app() in
/var/www/htdocs/temp3.php on line 13
Warning: Missing argument 2 for app() in
/var/www/htdocs/temp3.php on line 13
Warning: Missing argument 3 for app() in
/var/www/htdocs/temp3.php on line 13
the code .
//a basic class to store basic appointment details in
class App {
var $name;
var $the_date;
var $result;
//add values to the variables
This is the function's constructor, it's called when you create a 
class instance using new operator:

function App($app1name,$appdate,$appresult){
$this-name=$app1name;
$this-the_date=$appdate;
$this-result=$appresult;
}
}
$query=select app1name,appdate,appresult from
appresult where appdate  'jun 01 2004';
$qresult=mssql_query($query,$numero);//get the number
of rows returned
$numrow=mssql_num_rows($qresult);
if($row=mssql_fetch_array($qresult)){
$i=0;
do{
$j=$i;

So instead of:
$j= new App;

$j-App($row[app1name],$row['appdate'],$row['appresult']);

you have to suply the arguments to the contructor this way:
$j= new App($row[app1name],$row['appdate'],$row['appresult']);
}
while($row=mssql_fetch_array($qresult));
}
?
Is there a syntax problem with the way im trying to
pass the value of the $row array cells into the class
function?
I have looked at the online manual for classes but
find it a bit confusing on how to input and extract
variables data in classes. Any help or pointing in the
direction of some good docs would be greatly
appreciated!
thanks for any help in advance.

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


Re: [PHP] Class Syntax Help or Globals issue

2004-06-03 Thread Marek Kilimajer
bob pilly wrote:
Hi All
I am new to classes and are trying to work out whether
they will make my coding experience easier. I have
written the following test class which is trying to
take three variables from a mssql query and add them
as variables in a new class. This isnt working as i
keep getting an error that says ;
Warning: Missing argument 1 for app() in
/var/www/htdocs/temp3.php on line 13
Warning: Missing argument 2 for app() in
/var/www/htdocs/temp3.php on line 13
Warning: Missing argument 3 for app() in
/var/www/htdocs/temp3.php on line 13
the code .
//a basic class to store basic appointment details in
class App {
var $name;
var $the_date;
var $result;
//add values to the variables
This is the function's constructor, it's called when you create a class 
instance using new operator:

function App($app1name,$appdate,$appresult){
$this-name=$app1name;
$this-the_date=$appdate;
$this-result=$appresult;
}
}
$query=select app1name,appdate,appresult from
appresult where appdate  'jun 01 2004';
$qresult=mssql_query($query,$numero);//get the number
of rows returned
$numrow=mssql_num_rows($qresult);
if($row=mssql_fetch_array($qresult)){
$i=0;
do{
$j=$i;
So instead of:
$j= new App;

$j-App($row[app1name],$row['appdate'],$row['appresult']);
you have to suply the arguments to the contructor this way:
$j= new App($row[app1name],$row['appdate'],$row['appresult']);
}
while($row=mssql_fetch_array($qresult));
}
?
Is there a syntax problem with the way im trying to
pass the value of the $row array cells into the class
function?
I have looked at the online manual for classes but
find it a bit confusing on how to input and extract
variables data in classes. Any help or pointing in the
direction of some good docs would be greatly
appreciated!
thanks for any help in advance.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP syntax error or javascript mistake?

2003-11-19 Thread Marek Kilimajer
Kenn Murrah wrote:
I'm trying to open a new window on top of the current window, and it 
does that, but the original (bottom) window changes to read Object 
Window ... I can get back to the original with the Back button but of 
course don't want to ask that of the user ... I simply want a new window 
to appear on top of the original, after which the user can close the top 
window and be back where he started 
Oh, here's the code:

echo a 
href='javascript:window.open(\$fg_id\,\\,\height=400,width=300,left=80,top=80,scrollbars=1\)'; 

Browser follows the link, you need to return false after opening the window:

a 
href='javascript:window.open(\$fg_id\,\\,\height=400,width=300,left=80,top=80,scrollbars=1\); 
return false;'

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


RE: [PHP] hard(?) syntax problem

2003-11-04 Thread Pablo Gosse
On Tuesday, November 04, 2003 8:12 AM Adam wrote:

 I want to access a value of an array by key, but the array is not a
 variable - it is a constant.

 How do I do it?
 I tried
 $value = PL_ORT[$key];
 , but this doesn't work (parse error)...
 I even tried 
 $value = {PL_ORT[$key]};

Hi Adam.

As per the manual, constants may only evaluate to scalar values.  Are
you sure what you're trying to do is even possible here?

If you try to define a constant as an array, as follows:

?php
define('something',array('foo','bar'));
?

the following error results:

Warning: Constants may only evaluate to scalar values in
c:\phpdev\www\constant.php on line 2.

The valid types for use within constants are:

- boolean
- integer
- floating-point number (float)
- string 

Cheers,
Pablo

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



Re: [PHP] custom syntax highlighting in html-kit

2003-08-20 Thread Aaron Gould
This is not possible... yet.  I would like this feature too, but it has been
addressed a few times on the newsgroups at chami.com.

You can check the newsgroups out at
http://www.chami.com/html-kit/newsgroups/.

As far as I know, this feature is on Chami's long-term to-do list.

--
Aaron Gould
[EMAIL PROTECTED]
Web Developer
Parts Canada


- Original Message - 
From: Chris W. Parker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, August 20, 2003 2:55 PM
Subject: [PHP] custom syntax highlighting in html-kit


Hello,

I'd REALLY REALLY like to be able to modify the syntax highlighting in
html-kit. Is this possible?

Right now in PHP if you have a line like:

echo this is the text i want to echo.;

Everything between the two 's will be gray. I don't necessarily want to
change that color (that parts easy) want I do want to do is highlight {
} within  . For example a line like:

echo this is the text and this is the value: {$arra[0]}.;

I want everything starting at { and ending with } to be a different
color, maybe yellow, or orange.


Anyone have any clues? I've been googling and searching chami's site but
can't find a definitive yes or no.


Thanks!
Chris.

-- 
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] Unknown Syntax

2003-07-11 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Fri, 11 Jul 2003 at 13:55,
lines prefixed by '' were originally written by you.
 Does anybody recognize this:
 !==
 with 2 '='
 Ive known != to mean not equal to but i'm just looking at someone
 elses
 script and they use this instead. Does anyone know if this works or
 any
 problems with it?
 Cheers

This compares type as well as content, for example:
2 !== 2 evaluates to true but
2 != 2 evaluates to false

David.


--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



Re: [PHP] Unknown Syntax

2003-07-11 Thread James Kaufman
On Fri, Jul 11, 2003 at 01:56:46PM +0100, Chris Morrow wrote:
 Does anybody recognize this:
 
 !==
 
 with 2 '='
 
 Ive known != to mean not equal to but i'm just looking at someone elses
 script and they use this instead. Does anyone know if this works or any
 problems with it?
 
 Cheers
 

The syntax means 'not true' You can use it after a strpos operation to
distinguish 'string was not found' from 'string was found at position 0'.


-- 
Jim Kaufman mailto:[EMAIL PROTECTED]
Linux Evangelistcell: 612-481-9778  
public key 0x6D802619   fax:  952-937-9832
http://www.linuxforbusiness.net

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



Re: [PHP] Unknown Syntax

2003-07-11 Thread Leif K-Brooks
Chris Morrow wrote:

Does anybody recognize this:

!==

with 2 '='

Ive known != to mean not equal to but i'm just looking at someone elses
script and they use this instead. Does anyone know if this works or any
problems with it?
Not identical.  Negative ===.
http://us2.php.net/manual/en/language.operators.comparison.php
--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


RE: [PHP] correct syntax

2003-06-25 Thread Ford, Mike [LSS]
 -Original Message-
 From: Harry Wiens [mailto:[EMAIL PROTECTED]
 Sent: 25 June 2003 09:04
 
 What would be the correct syntax?
 
 1. $_SESSION[test]
 2. $_SESSION['test']
 3. $_SESSION[test]

All of these are correct depending on the context.  What's your context?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] PHP syntax colouring on documentation

2003-04-04 Thread Pete James
check phpinfo()... it lists the colors that 
highlight_file()/show_source() uses.

Better yet, here's the values:

highlight.bg#FF #FF
highlight.comment   #FF9900 #FF9900
highlight.default   #CC #CC
highlight.html  #00 #00
highlight.keyword   #006600 #006600
highlight.string#CC #CC
HTH.
Pete
Randum Ian wrote:
Hi there, I am currently writing a number of guides on PHP, SMARTY and 
Syntax and I was wondering if there is a set schema for the colouring of 
code within these guides. Is there a website that can give me an idea?

Regards, Ian.




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


Re: [PHP] PHP syntax colouring on documentation

2003-04-04 Thread Randum Ian
Good stuff thanks Pete.

 check phpinfo()... it lists the colors that 
 highlight_file()/show_source() uses.
 
 Better yet, here's the values:
 
 highlight.bg  #FF #FF
 highlight.comment #FF9900 #FF9900
 highlight.default #CC #CC
 highlight.html#00 #00
 highlight.keyword #006600 #006600
 highlight.string  #CC #CC
 
 HTH.
 Pete
 
 Randum Ian wrote:
 Hi there, I am currently writing a number of guides on PHP, SMARTY and
  Syntax and I was wondering if there is a set schema for the colouring
 of  code within these guides. Is there a website that can give me an
 idea?
 
 Regards, Ian.
 
 



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



Re: [PHP] PHP syntax colouring on documentation

2003-04-04 Thread Burhan Khalid
Randum Ian wrote:
Hi there, I am currently writing a number of guides on PHP, SMARTY and 
Syntax and I was wondering if there is a set schema for the colouring of 
code within these guides. Is there a website that can give me an idea?

Regards, Ian.


RTFM

http://www.php.net/manual/en/function.highlight-string.php
http://www.php.net/manual/en/function.highlight-file.php
--
Burhan Khalid
phplist[at]meidomus[dot]com


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


Re: [PHP] PHP syntax colouring on documentation

2003-04-04 Thread Randum Ian
 Randum Ian wrote:
 
 [ snip ]
 

RTFM

http://www.php.net/manual/en/function.highlight-string.php
http://www.php.net/manual/en/function.highlight-file.php

 
 Hi Burhan,
 
 I wasn't wanting to highlight anything like that, I am writing a guide
  which will be printed out in colour and wanted to highlight the code 
 appropriately. Thanks for replying.
 
 Regards, Ian.
 
 Apologies Ian -- I am still on first cup of coffee.
 
 I don't suppose there is a standard scheme for highlighting such 
 matters, but I think that since its dealing with PHP, you would be 
 better off sticking with the default color highlighting that comes with
 PHP.
 
 To find out what colors are used for what, check your friendly php.ini
 :)
 
 Again, I apologize for my rash post earlier.
 
 --
 Burhan Khalid
 phplist[at]meidomus[dot]com

Don't worry about it mate, I understand how p* off experienced coders 
can get with the young ones!

I have had a look at the phpinfo() file and it has come up with what it 
uses to highlight code so I might as well just use that!

Regards, Ian.


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



Re: [PHP] Array syntax not covered in documentation

2003-03-12 Thread CPT John W. Holmes
 I want to do the following:

 $u=preg_replace(/[^$chars]/e,'%.unpack(H2, $0)', $u);

 However, as you know, unpack returns an array.  I tried this instead:

 $u=preg_replace(/[^$chars]/e,'%.(unpack(H2, $0)[])', $u);

 but that isn't syntactically correct.  I know that this is possible to
 remedy using a user function but I do this kind of thing very often
 (grab the contents of an array value in one line of code) and want to be
 able to do it without splitting it into multiple lines.  Is that possible?

What exactly are you trying to do? Can you explain it and give some same
strings and output you're looking to achieve?

---John Holmes...


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



Re: [PHP] Array syntax not covered in documentation

2003-03-12 Thread Marek Kilimajer
maybe implode?
$u=preg_replace(/[^$chars]/e,%.implode('',unpack(H2, $0)), $u);
adrian porter wrote:

I want to do the following:

$u=preg_replace(/[^$chars]/e,'%.unpack(H2, $0)', $u);

However, as you know, unpack returns an array.  I tried this instead:

$u=preg_replace(/[^$chars]/e,'%.(unpack(H2, $0)[])', $u);

but that isn't syntactically correct.  I know that this is possible to 
remedy using a user function but I do this kind of thing very often 
(grab the contents of an array value in one line of code) and want to 
be able to do it without splitting it into multiple lines.  Is that 
possible?

thanks.
adrian



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


Re: [PHP] PHP_SELF syntax

2003-02-24 Thread Jason Lange
What you might try is removing the single-quotes from around PHP_SELF.

Before: $_SERVER['PHP_SELF']
After:  $_SERVER[PHP_SELF]
Another note: as far as I can tell you do not need the braces ({}) to 
enclose a variable within a double-quoted string. I may be wrong, but 
nothing I've read advocates doing this, and I've never had a problem 
with my code when I've written it this way.

Jason

Ernest E Vogelsinger wrote:
At 00:55 24.02.2003, Peter Gumbrell said:
[snip]
Could someone tell me why this code prompts a parse error. I have tried it
several different way. The statement is called from within a function:
print form method=\POST\ name=\update_workshop\
action=\$_SERVER['PHP_SELF']\\n;
[snip] 

When using array elements within a string you must enclose it in curly
brackets, like this:
print form method=\POST\ name=\update_workshop\
action=\{$_SERVER['PHP_SELF']}\\n;
HTH,



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


Re: [PHP] PHP_SELF syntax

2003-02-24 Thread 1LT John W. Holmes
 What you might try is removing the single-quotes from around PHP_SELF.

 Before: $_SERVER['PHP_SELF']
 After:  $_SERVER[PHP_SELF]

 Another note: as far as I can tell you do not need the braces ({}) to
 enclose a variable within a double-quoted string. I may be wrong, but
 nothing I've read advocates doing this, and I've never had a problem
 with my code when I've written it this way.

Just so there's no confusion, with double quoted strings, you can do it one
of two ways.

echo The value is {$_SERVER['PHP_SELF']};
or
echo The value is $_SERVER[PHP_SELF];

Neither is any more right than the other. You can always end the string and
concatinate the variable, too...

echo The value is  . $_SERVER['PHP_SELF'];

In that case, you should always use quotes around the key, single or double,
doesn't matter much.

---John Holmes...

  [snip]
 
 Could someone tell me why this code prompts a parse error. I have tried
it
 several different way. The statement is called from within a function:
 
 print form method=\POST\ name=\update_workshop\
 action=\$_SERVER['PHP_SELF']\\n;
 
  [snip]
 
  When using array elements within a string you must enclose it in curly
  brackets, like this:
 
  print form method=\POST\ name=\update_workshop\
  action=\{$_SERVER['PHP_SELF']}\\n;
 
  HTH,
 


 --
 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] PHP_SELF syntax

2003-02-24 Thread Ernest E Vogelsinger
At 01:42 24.02.2003, Jason Lange spoke out and said:
[snip]
What you might try is removing the single-quotes from around PHP_SELF.

Before: $_SERVER['PHP_SELF']
After:  $_SERVER[PHP_SELF]

This is only valid if the array is contained within a double quoted string
- it will generate a parser warning outside a string (undefind constant
PHP_SELF).

Another note: as far as I can tell you do not need the braces ({}) to 
enclose a variable within a double-quoted string. I may be wrong, but 
nothing I've read advocates doing this, and I've never had a problem 
with my code when I've written it this way.

The docs on strings
(http://www.php.net/manual/en/language.types.string.php) clearly states this:

If a dollar sign ($) is encountered, the parser will greedily take as much
tokens as possible to form a valid variable name. Enclose the variable name
in curly braces if you want to explicitly specify the end of the name.

$fruits = array('strawberry' = 'red', 'banana' = 'yellow');
// Works but note that this works differently outside string-quotes
echo A banana is $fruits[banana].;
// Works
echo A banana is {$fruits['banana']}.;
// Works but PHP looks for a constant named banana first
// as described below.
echo A banana is {$fruits[banana]}.;
// Won't work, use braces.  This results in a parse error.
echo A banana is $fruits['banana'].;
// Works
echo A banana is  . $fruits['banana'] . .;


-- 
   O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
^ http://www.vogelsinger.at/


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



Re: [PHP] PHP_SELF syntax

2003-02-24 Thread Justin French
on 24/02/03 11:42 AM, Jason Lange ([EMAIL PROTECTED]) wrote:

 What you might try is removing the single-quotes from around PHP_SELF.
 
 Before: $_SERVER['PHP_SELF']
 After:  $_SERVER[PHP_SELF]
 
 Another note: as far as I can tell you do not need the braces ({}) to
 enclose a variable within a double-quoted string. I may be wrong, but
 nothing I've read advocates doing this, and I've never had a problem
 with my code when I've written it this way.

Wrapping vars in braces helps clarify the code, and can avoid problems like:

?
$price = '44.99';
echo Price: US$$priceeach;// probably won't work
echo Price: US${$price}each;  // will work for sure
echo Price: US$ . $price . each;// will work, but not my pref
?

I've also found it helps with things like:

?
echo a href='{$_SERVER['PHP_SELF']}'click/a;
?

... where normally the single quotes would cause confusion, or require the
href to be wrapped in escaped double quotes.

In otherwords, wrapping $vars in {braces} provides clarity to both the PHP
parser, and to the writer, IMHO.


Justin


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



Re: [PHP] PHP_SELF syntax

2003-02-23 Thread Ernest E Vogelsinger
At 00:55 24.02.2003, Peter Gumbrell said:
[snip]
Could someone tell me why this code prompts a parse error. I have tried it
several different way. The statement is called from within a function:

print form method=\POST\ name=\update_workshop\
action=\$_SERVER['PHP_SELF']\\n;
[snip] 

When using array elements within a string you must enclose it in curly
brackets, like this:

print form method=\POST\ name=\update_workshop\
action=\{$_SERVER['PHP_SELF']}\\n;

HTH,

-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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



Re: [PHP] PHP_SELF syntax

2003-02-23 Thread David Otton
On Sun, 23 Feb 2003 18:55:06 -0500, you wrote:

Could someone tell me why this code prompts a parse error. I have tried it
several different way. The statement is called from within a function:

print form method=\POST\ name=\update_workshop\
action=\$_SERVER['PHP_SELF']\\n;

echo ('form method=POST name=update_workshop action=' .
$_SERVER['PHP_SELF'] . '' . \n);

works for me (moved the variable outside the string). I first thought it
might be a scope problem, but $_SERVER is apparently a superglobal so
that's not it.


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



Re: [PHP] POP3 ... syntax error

2003-02-06 Thread Adam Voigt




I'm aware it's not a PHP problem, I was trying to be nice by helping

figure out what the problem was in his raw communication.



On Wed, 2003-02-05 at 15:24, Jason Wong wrote:

On Wednesday 05 February 2003 23:32, Adam Voigt wrote:

 How about some code?



 On Wed, 2003-02-05 at 10:21, Christian Ista wrote:



 Hello,



 I'm trying to access pop3 server via PHP code. I can establish the

 connection, send the USER command (I receive the +OK answer). After

 that

 I sent the PASS command but I receive the answer -ERR syntax error.



 I don't understand why syntax error.



 Do you have an idea ?



No need for code, it's not a php problem. 



Google for pop3 commands to find out how to talk to pop3 servers.



-- 

Jason Wong - Gremlins Associates - www.gremlins.biz

Open Source Software Systems Integrators

* Web Design  Hosting * Internet  Intranet Applications Development *

--

Search the list archives before you post

http://marc.theaimsgroup.com/?l=php-general

--

/*

The Beatles:

	Paul McCartney's old back-up band.

*/





-- 

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php





-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


Re: [PHP] POP3 ... syntax error

2003-02-05 Thread Adam Voigt




How about some code?



On Wed, 2003-02-05 at 10:21, Christian Ista wrote:

Hello,



I'm trying to access pop3 server via PHP code. I can establish the

connection, send the USER command (I receive the +OK answer). After that

I sent the PASS command but I receive the answer -ERR syntax error. 



I don't understand why syntax error.



Do you have an idea ?





Christian,



---

Christian Ista (AFAS member)

Hosting - Dedicated server

http://www.bee-hosting.com

http://www.your-softwares.com







-- 

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php






-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


Re: [PHP] POP3 ... syntax error

2003-02-05 Thread Jason Wong
On Wednesday 05 February 2003 23:32, Adam Voigt wrote:
 How about some code?

 On Wed, 2003-02-05 at 10:21, Christian Ista wrote:

 Hello,

 I'm trying to access pop3 server via PHP code. I can establish the
 connection, send the USER command (I receive the +OK answer). After
 that
 I sent the PASS command but I receive the answer -ERR syntax error.

 I don't understand why syntax error.

 Do you have an idea ?

No need for code, it's not a php problem. 

Google for pop3 commands to find out how to talk to pop3 servers.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The Beatles:
Paul McCartney's old back-up band.
*/


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




Re: [PHP] PHP Syntax - mail statement

2002-11-23 Thread Marco Tabini
Probably just a problem with register_globals

Try:

$contents = {$_REQUEST['firstname']}, {$_REQUEST['lastname']}, {$_REQUEST['email']};

Marco


php|architect - The magazine for PHP Professionals
The monthly worldwide magazine dedicated to PHP programmers
Check us out on the web at http://www.phparch.com

On Sat, 2002-11-23 at 18:13, Michael Sharp wrote:
 I have a html form that has just 3 fields and each are defined as
 name=firstname, name=lastname, and name=email . The action is
 calling a sendmail.php file and the method is POST. Here is the contents
 of sendmail.php:
 
 ?php
 $to = [EMAIL PROTECTED];
 $subject = Form Submission;
 $contents = $firstname, $lastname, $email;
 mail ($to, $subject, $contents);
 header (Location: http://probsd.org/rlewis/thankyou.txt;);
 ?
 
 When submitting the form, mail gets sent to [EMAIL PROTECTED] with the
 subject defined in sendmail.php, but the contents simply displayes both of
 the commas from $contents =  and not $firstname, $lastname, and $email.
 
 Syntax error or what?
 
 Michael
 
 
 
 
 -- 
 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] if syntax

2002-07-10 Thread jepadilla

This will only work if you have a single line of code after the else and 
if.  At least that is my understanding of all languages :)

J





Alexander Ross [EMAIL PROTECTED]
07/10/2002 08:25 AM

 
To: [EMAIL PROTECTED]
cc: 
Subject:[PHP] if syntax


I know this is correct:

if ($something)
{
...
}
else
{
...
}

But I recently saw someone use this instead:

if($something):
 ...
else:
...

Is that also correct??   No brackets needed?



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






Re: [PHP] if syntax

2002-07-10 Thread Martin Clifford

There are no brackets necessary if you only have one line of code to be executed in 
the case.  For example:

if($var == 1)
echo Var equals 1;
} else {
echo Var does not equal 1;
}

But this is not valid:

if($var == 1)
echo Var equals ;
echo 1;
} else {

}

HTH

Martin

 Alexander Ross [EMAIL PROTECTED] 07/10/02 10:25AM 
I know this is correct:

if ($something)
{
...
}
else
{
...
}

But I recently saw someone use this instead:

if($something):
 ...
else:
...

Is that also correct??   No brackets needed?



-- 
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] if syntax

2002-07-10 Thread R'twick Niceorgaw

read here for the alternative control structures in php
http://www.php.net/manual/en/control-structures.alternative-syntax.php
- Original Message - 
From: [EMAIL PROTECTED]
To: Alexander Ross [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, July 10, 2002 7:28 AM
Subject: Re: [PHP] if syntax


 This will only work if you have a single line of code after the else and 
 if.  At least that is my understanding of all languages :)
 
 J
 
 
 
 
 
 Alexander Ross [EMAIL PROTECTED]
 07/10/2002 08:25 AM
 
  
 To: [EMAIL PROTECTED]
 cc: 
 Subject:[PHP] if syntax
 
 
 I know this is correct:
 
 if ($something)
 {
 ...
 }
 else
 {
 ...
 }
 
 But I recently saw someone use this instead:
 
 if($something):
  ...
 else:
 ...
 
 Is that also correct??   No brackets needed?
 
 
 
 -- 
 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] if syntax

2002-07-10 Thread vins

OK...
This is another easy question that everyone has an answer for.
Here's mine
:D

the if statement has many ways of being formed.
1 line code: (Echo or exit command)

if(empty($Variable))
exit;
else
echo Variable exists

Multiple line code:
if(empty($Variable))
{
header(Location: Here.com);
exit;
}
else
{
echo Valid variable;
eixt;
}

Combined:
if(empty($Variable))
echo Variable empty;
else
{
Header(Location: Here.com);
exit;
}

or the other alternative

(empty($Variable)) ? echo Empty : echo Contains Something;

[EMAIL PROTECTED] wrote in message
news:OFF48BDDD0.BCC82414-ON87256BF2.004F65C2-87256BF2.004F6811@blackhillscor
p.com...
 This will only work if you have a single line of code after the else and
 if.  At least that is my understanding of all languages :)

 J





 Alexander Ross [EMAIL PROTECTED]
 07/10/2002 08:25 AM


 To: [EMAIL PROTECTED]
 cc:
 Subject:[PHP] if syntax


 I know this is correct:

 if ($something)
 {
 ...
 }
 else
 {
 ...
 }

 But I recently saw someone use this instead:

 if($something):
  ...
 else:
 ...

 Is that also correct??   No brackets needed?



 --
 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] if syntax

2002-07-10 Thread Chris Hewitt

Alexander,

The thing to do is to try it yourself. Yes its OK for single statements 
(I assume the colon after the $condition): is a typo. The first two 
examples in the manual (Chapter 11, if) show this syntax though not with 
else.

HTH
Chris

Alexander Ross wrote:


if($something):
 ...
else:
...

Is that also correct??   No brackets needed?






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




  1   2   >