Re: [PHP] Shared Memory Problem

2005-11-16 Thread Yaswanth Narvaneni
Hi Curt,

These are my open shared memories in the server output of ipcs command.

-- Shared Memory Segments 
keyshmid  owner  perms  bytes  nattch status
0x 18645001   gOLeM 600393216 2  dest
0x162e 18808842   root  66630 1

The last one the the sharedmem the php will be using. the key is 5678
and as you said I
have modified my code to

$shm_id = shmop_open(intval($shm_key), a,666,0) or die(FATAL
ERROR:: $php_errormsg);

U obtain the shm_key from a file. The key I am using is 5678 and it is
getting that value from the file. I even hardcoded the value, but the
error is not getting solved.

Is this a proble with any of the server configs? Coz we have
downloaded an example C file and this is also not working with the
PHP. Where as if the server and client both written in C are able to
communicate using the shared memory. Any clue any one??

Ok...just a crazy query...does it have anything to do with
Notice: import_request_variables(): No prefix specified - possible
security hazard in

which occurs due to register_globals set to Off??

On 11/16/05, Curt Zirzow [EMAIL PROTECTED] wrote:
 On Wed, Nov 16, 2005 at 03:33:22AM +0530, Yaswanth Narvaneni wrote:
  Hi!
 
  I have a server written in C++ and my webpages are in PHP. The PHP has
  to communicate with the server using shared memory. This was working
  fine on the server running FC-1 with php-4.3.8. We recently migrated
  to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it
  displays is as follows:
 
  shmop_open(): unable to attach or create shared memory segment in
  /var/www/html/sharedmem.php on line 2
 
  The server opens the shm in 666 (originally was 644) even then it was
  not working. I can see the shared mem open using 'ipcs' command.
 
  ...
  $shm_id = shmop_open($shm_key, a,0,0) or die(FATAL ERROR:: Unable
  to Access Shared Memory);

 You might want to try to open it within the same mode that the
 server created it in:

 1)
   $shm_id = shmop_open($shm_key, a,0666,0);

 2)
   are you 100% sure the key is valid? the error message you are
   getting seems to point in this direction since the shmop_open is
   failing on the C call to shmget(), wich usually fails when either
   you dont have enough memory to create it (which you arn't doing),
   some other creation problems, or that the key supplied wasn't
   found.


 Curt.
 --

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




--
In theory there is no difference between theory and practice.
In practice there is. -- Fortune Cookie

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



Re: [PHP] Shared Memory Problem

2005-11-16 Thread Yaswanth Narvaneni
Hi!

There is a strange problem now. This is the error message my php file gives.
kernel not configured for shared memory kernel not configured for
semaphores kernel not configured for message queues

The source is as follows:
?php

$shm_id = shmop_open(5678, a, 0, 0);
if (!$shm_id) {
   echo Couldn't create shared memory segment\n : $php_errormsg;
}

print br;
print system(ipcs);

?

when I logged into my machine as user apache and tried ipcs command it
was working fine (I changed the shell of apache from /sbin/nologin to
/bin/bash)

Any clue??

Regards,
Yaswanth


On 11/16/05, Yaswanth Narvaneni [EMAIL PROTECTED] wrote:
 Hi Curt,

 These are my open shared memories in the server output of ipcs command.

 -- Shared Memory Segments 
 keyshmid  owner  perms  bytes  nattch status
 0x 18645001   gOLeM 600393216 2  dest
 0x162e 18808842   root  66630 1

 The last one the the sharedmem the php will be using. the key is 5678
 and as you said I
 have modified my code to

 $shm_id = shmop_open(intval($shm_key), a,666,0) or die(FATAL
 ERROR:: $php_errormsg);

 U obtain the shm_key from a file. The key I am using is 5678 and it is
 getting that value from the file. I even hardcoded the value, but the
 error is not getting solved.

 Is this a proble with any of the server configs? Coz we have
 downloaded an example C file and this is also not working with the
 PHP. Where as if the server and client both written in C are able to
 communicate using the shared memory. Any clue any one??

 Ok...just a crazy query...does it have anything to do with
 Notice: import_request_variables(): No prefix specified - possible
 security hazard in

 which occurs due to register_globals set to Off??

 On 11/16/05, Curt Zirzow [EMAIL PROTECTED] wrote:
  On Wed, Nov 16, 2005 at 03:33:22AM +0530, Yaswanth Narvaneni wrote:
   Hi!
  
   I have a server written in C++ and my webpages are in PHP. The PHP has
   to communicate with the server using shared memory. This was working
   fine on the server running FC-1 with php-4.3.8. We recently migrated
   to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it
   displays is as follows:
  
   shmop_open(): unable to attach or create shared memory segment in
   /var/www/html/sharedmem.php on line 2
  
   The server opens the shm in 666 (originally was 644) even then it was
   not working. I can see the shared mem open using 'ipcs' command.
  
   ...
   $shm_id = shmop_open($shm_key, a,0,0) or die(FATAL ERROR:: Unable
   to Access Shared Memory);
 
  You might want to try to open it within the same mode that the
  server created it in:
 
  1)
$shm_id = shmop_open($shm_key, a,0666,0);
 
  2)
are you 100% sure the key is valid? the error message you are
getting seems to point in this direction since the shmop_open is
failing on the C call to shmget(), wich usually fails when either
you dont have enough memory to create it (which you arn't doing),
some other creation problems, or that the key supplied wasn't
found.
 
 
  Curt.
  --
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 In theory there is no difference between theory and practice.
 In practice there is. -- Fortune Cookie



--
In theory there is no difference between theory and practice.
In practice there is. -- Fortune Cookie

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



[PHP] SOAP and PHP

2005-11-16 Thread Angelo Zanetti

Hi guys.

I've googled but found so many pages that I'm not sure what to use.

I want to use PHP to make use of SOAP.

I've found:
-nuSoap
-libxml(2)
-php-soap
-and others which seemed less important.

Can you recommend which one to use? and which one is the most supported.
Also if I've missed some that you feel I should know about please let me 
know.

Thanks in advance.

Angelo

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



Re: [PHP] SOAP and PHP

2005-11-16 Thread Torgny Bjers
Angelo Zanetti wrote:

 Hi guys.

 I've googled but found so many pages that I'm not sure what to use.

 I want to use PHP to make use of SOAP.

 I've found:
 -nuSoap
 -libxml(2)
 -php-soap
 -and others which seemed less important.

 Can you recommend which one to use? and which one is the most supported.
 Also if I've missed some that you feel I should know about please let
 me know.
 Thanks in advance.

 Angelo


Not sure, but there's already a couple of relevant classes in PEAR:
http://pear.php.net/search.php?q=soapin=packagesx=0y=0

A hot tip is to always search in the packages there. :)
http://pear.php.net/packages.php

Warm Regards,
Torgny

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



Re: [PHP] Re: PHP Framework

2005-11-16 Thread Yonatan Ben-Nes

Aaron Greenspan wrote:

Yonatan,

And since I'm the Lampshade guy, I'll throw Lampshade out there, as well:

http://www.thinkcomputer.com/software/lampshade/index.html

Unlike a lot of frameworks, Lampshade is entirely procedural, and it's 
designed specifically for use with MySQL. I suppose that makes it less 
flexible than some people would want, but if it fits your application 
specs, then it's very fast and straightforward.


In general, it's been around since 2002 (no plans to go away next year), 
it's in use at Harvard and at very large companies, and at very small 
ones, too, and there's a whole lot of documentation, in both HTML and 
PDF format. I also happen to think that as far as programming frameworks 
go, it's pretty easy to learn. The Lampshade Starter Kit, which you can 
download alongside the core files, gives you an example application that 
you can work with and modify.


Good luck with your search!

Aaron

Aaron Greenspan
President  CEO
Think Computer Corporation

http://www.thinkcomputer.com



Thanks Aaron it sounds promising but sadly it won't fit to my needs 
cause I use PostgreSQL as my database... I guess that I should have 
written that at my requirements...


Thanks again anyway :)
  Yonatan

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



[PHP] Re: SOAP and PHP

2005-11-16 Thread Petr Smith

Torgny Bjers wrote:

Angelo Zanetti wrote:



Hi guys.

I've googled but found so many pages that I'm not sure what to use.

I want to use PHP to make use of SOAP.

I've found:
-nuSoap
-libxml(2)
-php-soap
-and others which seemed less important.

Can you recommend which one to use? and which one is the most supported.
Also if I've missed some that you feel I should know about please let
me know.
Thanks in advance.

Angelo




Not sure, but there's already a couple of relevant classes in PEAR:
http://pear.php.net/search.php?q=soapin=packagesx=0y=0

A hot tip is to always search in the packages there. :)
http://pear.php.net/packages.php

Warm Regards,
Torgny



Who uses PEAR? Mess of old unsupported and undocumented libraries which 
only their authors (maybe) can use?


I would recommend PHP5 SOAP extension, based on libxml2. It works 
without problems and without messing with PEAR.


You can start with this tutorial: 
http://www-128.ibm.com/developerworks/library/os-phpws/?ca=dgr-lnxw06PHP5soap


Petr

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



Re: [PHP] Re: SOAP and PHP

2005-11-16 Thread Paul Waring
On Wed, Nov 16, 2005 at 12:40:21PM +0100, Petr Smith wrote:
 Who uses PEAR? Mess of old unsupported and undocumented libraries which 
 only their authors (maybe) can use?

I use PEAR for a few things, such as database abstraction. I admit that
a lot of the less popular modules haven't been updated/documented in a
long time though, which is a shame.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Virtual includes of PHP into SSI pages.

2005-11-16 Thread cron
For this to work you must set html and shml as a php file extension in
apache.

This is because shml includes are made before it reaches apache output, so
if you have file a including file b it the same as having only one file
a with copy and paste of file b with shml file extension and thus this
is never parsed to php.

Hope i´m making any sense here, bad english

Angelo



- Original Message - 
From: Neil Hoggarth [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Monday, November 14, 2005 11:01 AM
Subject: [PHP] Virtual includes of PHP into SSI pages.


 Hi Folks,

 I'm attempting to diagnose an apparent problem with my Apache/PHP
 server setup. The platform is SPARC Solaris 9. I'm running Apache httpd
 2.0.55 and PHP 4.4.1, built from NetBSD pkgsrc.

 I have a user who has .shtml (server side include) pages which include
 PHP fragments using directives like !--#include virtual=/name.php --
 (and yes, I know this is silly, and that obvious thing to do is to use
 PHP for the top level pages rather than SSI; unfortunatly I'm the
 sysadmin providing the service, rather than the person maintaining the
 content).

 I wanted to check to see if anyone knows of any known problems or
 gotchas in this area?

 I'm told that this mechanism was working okay until recently, but it
 broke at some point in the last few months. I've done a number of
 upgrades to both the apache2 and PHP packages over the time period in
 question, in response to security advisories; unfortunately the user
 can't pinpoint exactly when things started to fail.

 I've recreated a very simple test case:

 test.shtml:

html
head
titleTest Page/title
/head
body
pBegin Test/p
!--#include virtual=/foo1.php --
pEnd Test/p
/body
/html

 foo1.php:

pHello From PHP/p

 Fetching test.shtml produces the output:

Begin Test

End Test

 (no sign of the included fragment in the output).

 Editing the test harness to teplacing the include of foo1.php with an
 include of a plain HTML or SHTML file produces the expected output
 (included content appears in the output between the begin and end
 markers).

 Furthermore, if I edit the test harness to include an HTML file and
 *then* the PHP fragment, I get a reproduceable segmentation fault in
 PHP:

 Program received signal SIGSEGV, Segmentation fault.
 0xfecb541c in zend_hash_index_update_or_next_insert (ht=0xfed3c1c4, h=0,
 pData=0xffbfdec8, nDataSize=12,
  pDest=0x0, flag=1) at
 /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_hash.c:390
 390 p = ht-arBuckets[nIndex];
 (gdb) where
 #0  0xfecb541c in zend_hash_index_update_or_next_insert (ht=0xfed3c1c4,
 h=0, pData=0xffbfdec8,
  nDataSize=12, pDest=0x0, flag=1)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_hash.c:390
 #1  0xfecb8cc0 in zend_list_insert (ptr=0x299250, type=2)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_list.c:45
 #2  0xfecb8eb8 in zend_register_resource (rsrc_result=0x0,
rsrc_pointer=0x299250, rsrc_type=2)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_list.c:98
 #3  0xfec693d8 in _php_stream_alloc (ops=0xfed31528, abstract=0x1eb770,
persistent_id=0x0,
  mode=0xfece83f0 rb) at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:281
 #4  0xfec6e0b0 in _php_stream_fopen_from_fd (fd=22, mode=0xfece83f0 rb,
persistent_id=0x0)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2072
 #5  0xfec6de5c in _php_stream_fopen (filename=0x297cb8
/usr/pkg/share/httpd/htdocs/foo1.php,
  mode=0xfece83f0 rb, opened_path=0xffbfeb90, options=165)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2004
 #6  0xfec6d5cc in _php_stream_fopen_with_path (filename=0x297cb8
/usr/pkg/share/httpd/htdocs/foo1.php,
  mode=0xfece83f0 rb, path=0xfece7fc8 .:/usr/pkg/lib/php,
opened_path=0xffbfeb90, options=165)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:1784
 #7  0xfec6efd4 in php_plain_files_stream_opener (wrapper=0xfed31598,
  path=0x297cb8 /usr/pkg/share/httpd/htdocs/foo1.php, mode=0xfece83f0
rb, options=165,
  opened_path=0xffbfeb90, context=0x0)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2489
 #8  0xfec6fb18 in _php_stream_open_wrapper_ex (path=0x297cb8
/usr/pkg/share/httpd/htdocs/foo1.php,
  mode=0xfece83f0 rb, options=173, opened_path=0xffbfeb90,
context=0x0)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2696
 #9  0xfec6ff34 in _php_stream_open_wrapper_as_file_handle (
  path=0x297cb8 /usr/pkg/share/httpd/htdocs/foo1.php, mode=0xfece83f0
rb, options=141, fh=0xffbfeb88)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2823
 #10 0xfec53900 in php_open_wrapper_for_zend (filename=0x297cb8
/usr/pkg/share/httpd/htdocs/foo1.php,
  fh=0xffbfeb88) at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/main.c:764
 #11 

[PHP] Portability, Compatibility and short tags

2005-11-16 Thread Jochem Maas

nevermind the short tags issue! ;-)

- there is a chance that autocasting [of function arguments] is going to change 
to
be stricter and no longer work the same as explicit casting so that the 
following 2
echos statement would no longer work the same (the first would fail).

$str = This is a test;
$cnt = 3abc;

echo substr($str, 0, $cnt); // would fail (3rd arg not numeric)
echo substr($str, 0, (int)$cnt);// works fine

my feeling is that the inconsistency will make the language less attractive, if 
php is
autocasting then I expect it to cast in the same way internally as when I
ask for it explicitly - if it doesn't I have to memorize the differences, which
is another reason to start looking into other languages (ruby anyone?) and 
certainly
the kind of thing to really confuse beginners.

anyone else want to speak up against the proposed results of such a change?
(please dig into the internals mailing list to read more on the subject)

the arugment (AFAICT) behind the stricter casting is the ever more popular
helps developers catch stupid/hard-to-find bugs before they cause a problem
argument, which to me is becoming a bit long in the tooth. At some stage there
will be so many hoops you have to jump through (and know that the hoops exist in
the first place) before you can get anything done that the net result is:

YES, these 
purist/strict/help-the-dev-catch-difficult-php-bugs-before-they-bite-him-
in-the-ass have helped reduce the ammount of bad php code begin written  
because
everyone is writing their apps in another language.

another example of this mentality is the fact that array_merge() only excepts 
array()s
where are in the past other type of vars were automatically cast to array.

ok that became a bit of a rant - it's just I really like php and I rather want 
it
to stay likable :-)

rgds,
Jochem

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



Re: [PHP] Is echo tag reasonably portable?

2005-11-16 Thread Jochem Maas

Curt Zirzow wrote:

On Tue, Nov 15, 2005 at 05:39:36PM +, Richard Davey wrote:


Hi Jim,

Tuesday, November 15, 2005, 5:25:58 PM, you wrote:



I don't know, but those who do should not use short tags. And those
who hope to should not get into the habit of using short tags.


And for the vast majority remaining, who write closed-apps for
clients??



It will be when you have to sort through 1,000,000 lines of code in
400 files to change '?' to '?PHP'. Better to save the grief and do
it right to start with, no?


There is no right or wrong for this, it's down to personal
developer preference. Nothing more, nothing less. It's only right if
you're building an app for distribution to unknown end-users. I don't
think that covers the majority of work we all do here somehow.



There is the issue if you are dealing with xml, consider php script is:

  ?xml version=1.0 encoding?
  ? echo $something_xml_ish ?
  
which is exactly why ?php was born.


indeed, but it seems to me that all writings on writing solid ('enterprise 
level'?)
php code recommend with a capital R not to write your code embedded inline with 
you
xml/xhtml/html/whatever because it's often brittle and very hard to maintain 
(read
illegible). i.e. I think your mad if you have created 100 lines of XML 
liberally
interspersed with php code.

just a thought :-)




Curt.


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



RE: [PHP] Regex for Amateur Radio Callsigns

2005-11-16 Thread Ford, Mike
 -Original Message-
 From: Leonard Burton [mailto:[EMAIL PROTECTED] 
 Sent: 16 November 2005 03:39
 To: php-general@lists.php.net
 
 Basically here is the regex I used (I am not the best with regexes):
 
 $pattern = /^[0-9]?[A-Z]{1,2}[0-9][A-Z]{1,3}/;
 
 Here are how they look
 W1W
 W1AW
 WA1W
 AD4HZ
 N9URK
 WB6NOA
 4N1UBG
 
 I guess this would be better?
 
 $pattern  = /^;
 $pattern .= ([0-9][A-Z][0-9][A-Z]{3})|; //4N1UBG
 $pattern .= ([A-Z][0-9][A-Z]{1,3})|;//N9URK, W1AW, W1W
 $pattern .= ([A-Z]{2}[0-9][A-Z]{1,3}); //WB6NOA, AD4HZ, 
 WA1W
 $pattern .= /;

You should be able to fold the second and third into:

  $pattern .= /([A-Z]{1,2}[0-9][A-Z]{1,3})/

It would be harder, if even possible, to merge this with the first form,
due to the requirement for exactly 3 letters vs 1-3; some kind of
complicated look-behind might do it, but I don't think I even want to
try!

Cheers!

Mike
 


Mike Ford, Electronic Information Services Adviser, Learning Support
Services,
JG125, The Library, James Graham Building, Headingley Campus, Beckett
Park,
LEEDS, LS6 3QS, United Kingdom
Tel: +44 113 283 2600 extn 4730Fax: +44 113 283 3211


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Catch warnings

2005-11-16 Thread Mariano Guadagnini

Curt Zirzow wrote:


On Tue, Nov 15, 2005 at 04:39:05PM -0300, Mariano Guadagnini wrote:
 

Hi, i�m writting a php program that parses and saves some xml files on a 
server. The problem is that i want to catch warnings so as to be able to 
store them in a variable, but not to be put directly on client�s 
browser. I got the following code, but i cannot get it working:

//
$old_track = ini_set('track_errors', '1');

if ([EMAIL PROTECTED]()) {
echo $php_errormsg, \n;
}

ini_set('track_errors', $old_track);
//
When i execute the cgi, the $php_errormsg variable is always empty, even 
when there are errors.


Any ideas?
   



I'd probably scratch that approach and use set_error_handler()
instead.  You could even get fancy and create a class that uses
it so your code could be something like:

?php
 phpErrorHandler::start();
 // some code that causes errors... 
 phpErrorHander::stop();

?

Although i see this more as a developement tool than production
solution.


Curt
 

Thanks for the reply Curt. You are right that this is not a production 
solution, but in fact i need to store the warnings somewhere because the 
server I have access to has warnings disable, and i need to track the  
messages to find which xml documents are malformed and failed to parse. 
I´ll try this.


Mariano.


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.1/169 - Release Date: 15/11/2005

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



Re: [PHP] SOAP and PHP

2005-11-16 Thread Chris Shiflett

Angelo Zanetti wrote:

I've googled but found so many pages that I'm not sure what to use.

I want to use PHP to make use of SOAP.


If you're using PHP 5, this is a good option:

http://php.net/soap

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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



[PHP] APC caching keys.

2005-11-16 Thread Jochem Maas

I have started making use of the APC extension to cache opcodes, etc
now I'm also trying to cache the output of some sql queries and I want to
use a hash of the query as key to store/fetch the value e.g:

apc_fetch(md5($qry))

does anyone know of a good reason (including performance reasons) for
not using a hash in such a way?

tia  rgds,
Jochem

PS - apc is very nice! I just haven't been able to get it to work on 5.1 (last 
tried
on 5.1RC5dev) - has anybody else had luck getting apc to work with 5.1? did you 
have
to do anything special?

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



Re: [PHP] Regex for Amateur Radio Callsigns

2005-11-16 Thread Stephen Calnan
  The only problem with this is that it would take 444 which is not a
  valid call.

Wikipedia defines a HAM call sign here:
http://en.wikipedia.org/wiki/Call_sign#Amateur_radio

A regex based upon this definition might be: 
/\b(([A-Z]{1,2})|([A-Z][0-9]))[0-9][A-Z]{1,3}\b/

I tested this out a tiny bit and it seems to work OK.  Good luck.

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



[PHP] better way to mix html and php code?

2005-11-16 Thread [EMAIL PROTECTED]

Hi to all,
always wondered what's better way to mix html and php code. Here are 
three ways of the same code. Which one you prefer? (And why, of caurse :))


Solution 1: 


?php
require 'includes/header.php';

$cat_parent = $_GET['cat_parent'];
$cat_id = $_GET['cat_id'];

echo 'table border=0 align=center cellpadding=1 cellspacing=0 
style=border: 1px solid #EBEBEB; padding: 25px;';

echo 'tr';
echo 'td align=left height=35 valign=top 
colspan=2bu'. $_SESSION['CATEGORIES']['name'][$cat_parent] .'  
'. $_SESSION['CATEGORIES']['name'][$cat_id] .'/u/b/td';
echo  'td align=center valign=bottom colspan=2a 
href=new_product.php?cat_id='.$cat_id.'cat_parent='.$cat_parent.' 
style=font-size: 11px; color: gray;[ Add New Product ]/a/td';

echo '/tr';

$query = my_query(
   SELECT chp.products_prod_id, p.prod_id, p.prod_name, 
p.prod_no, p.prod_status

   FROM categories_has_products as chp, products as p
   WHERE chp.categories_cat_id = '.$cat_id.' AND 
chp.products_prod_id = p.prod_id

   , 0);
while($result = mysql_fetch_array($query))
{
   echo 'tr';
   echo 'td align=left valign=topraquo; '. 
$result['prod_name'] .'/td';
   echo 'td align=center valign=top[ '. 
$result['prod_no'] .' ]/td';

   echo 'td align=center valign=top';
   echo 'img src=../images/icon_edit2.gif alt=EDIT 
width=14 height=14 hspace=0 vspace=0 border=0';
   echo 'a 
href=products.php?cat_id='.$cat_id.'cat_parent='.$cat_parent.'action=deleteprod_id='.$result['prod_id'].' 
onclick=return confirm(\'Do you really want to delete this 
product?\');img src=../images/icon_delete.gif alt=DELETE 
width=14 height=14 hspace=5 vspace=0 border=0/a';

   switch($result['prod_status'])
   {
   case 'live':
   echo 'a 
href=products.php?new_status=hiddenprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img 
src=../images/status_live.gif alt=LIVE width=13 height=13 
hspace=2 vspace=0 border=0/a';

   break;

   case 'hidden':
   echo 'a 
href=products.php?new_status=liveprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img 
src=../images/status_hidden.gif alt=HIDDEN width=13 height=13 
hspace=2 vspace=0 border=0/a';

   break;

   case 'temp':
   echo 'b[T]/b';
   break;

   }
   echo '/td';
   echo '/tr';
}
echo '/table';

include 'includes/footer.php';
?


Solution 2: 


?php
require 'includes/header.php';

$cat_parent = $_GET['cat_parent'];
$cat_id = $_GET['cat_id'];
?
table border=0 align=center cellpadding=1 cellspacing=0 
style=border: 1px solid #EBEBEB; padding: 25px;

   tr
   td align=left height=35 valign=top colspan=2bu?= 
$_SESSION['CATEGORIES']['name'][$cat_parent] ?  ?= 
$_SESSION['CATEGORIES']['name'][$cat_id] ?/u/b/td
   td align=center valign=bottom colspan=2a 
href=new_product.php?cat_id=?= $cat_id ?cat_parent=?= $cat_parent 
? style=font-size: 11px; color: gray;[ Add New Product ]/a/td

   /tr
?php
$query = my_query(
   SELECT chp.products_prod_id, p.prod_id, p.prod_name, 
p.prod_no, p.prod_status

   FROM categories_has_products as chp, products as p
   WHERE chp.categories_cat_id = '.$cat_id.' AND 
chp.products_prod_id = p.prod_id

   , 0);
while($result = mysql_fetch_array($query))
{
?
   tr
   td align=left valign=topraquo; ?= $result['prod_name'] 
?/td

   td align=center valign=top[ ?= $result['prod_no'] ? ]/td
   td align=center valign=top
   img src=../images/icon_edit2.gif alt=EDIT width=14 
height=14 hspace=0 vspace=0 border=0
   a href=products.php?cat_id=?= $cat_id ?cat_parent=?= 
$cat_parent ?action=deleteprod_id=?= $result['prod_id'] ? 
onclick=return confirm('Do you really want to delete this 
product?');img src=../images/icon_delete.gif alt=DELETE 
width=14 height=14 hspace=5 vspace=0 border=0/a


?php
   switch($result['prod_status'])
   {
   case 'live':
   echo 'a 
href=products.php?new_status=hiddenprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img 
src=../images/status_live.gif alt=LIVE width=13 height=13 
hspace=2 vspace=0 border=0/a';

   break;

   case 'hidden':
   echo 'a 

Re: [PHP] better way to mix html and php code?

2005-11-16 Thread Richard Davey
Hi afan,

Wednesday, November 16, 2005, 4:12:53 PM, you wrote:

 always wondered what's better way to mix html and php code. Here are
 three ways of the same code. Which one you prefer? (And why, of
 caurse :))

Honestly, I wouldn't pick any of them :)

But if I had to (i.e. forced at gun-point or something) it'd have to
be #2, because it's at least mixing HTML and PHP in a way that doesn't
create massive strings, for no actual reason other than it is the
easiest format to go in and change the HTML without causing a
potential syntax error.

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



[PHP] Error Messages, Windows, and Tequila

2005-11-16 Thread Jay Blanchard
Hidy-ho good meighbors and neighborettes!

I continue my, as yet unquenched, fascination with the Windows operating
system[sic].

Does anyone know (I have error reporting set so high it would make your head
swim) why errors wouldn't be output to a browser window when they occur? For
instance, I typed the following;

while($doc = odbc_feych_array($dbDocData) // note the misspelling of fetch
that means I was thinking in wild-west dialect at the time, 'fey-uch'

An erro went to the Apache log but no error, such as the highly popular
syntax erro was sent to the browser. Alas, a search of Google revealed
nothing worthwhile, probably because I didn't have the right search term.
Would someone please shed some light on this?

Thanks!

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



Re: [PHP] Error Messages, Windows, and Tequila

2005-11-16 Thread David Grant
Printing error messages to your output can be disabled with the
display_errors directive in your php.ini file.  To enable error
printing, the directive should read:

display_errors = On

Cheers,

Dave

Jay Blanchard wrote:
 Hidy-ho good meighbors and neighborettes!
 
 I continue my, as yet unquenched, fascination with the Windows operating
 system[sic].
 
 Does anyone know (I have error reporting set so high it would make your head
 swim) why errors wouldn't be output to a browser window when they occur? For
 instance, I typed the following;
 
 while($doc = odbc_feych_array($dbDocData) // note the misspelling of fetch
 that means I was thinking in wild-west dialect at the time, 'fey-uch'
 
 An erro went to the Apache log but no error, such as the highly popular
 syntax erro was sent to the browser. Alas, a search of Google revealed
 nothing worthwhile, probably because I didn't have the right search term.
 Would someone please shed some light on this?
 
 Thanks!
 

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



Re: [PHP] Error Messages, Windows, and Tequila

2005-11-16 Thread Richard Davey
Hi Jay,

Wednesday, November 16, 2005, 4:36:25 PM, you wrote:

 Does anyone know (I have error reporting set so high it would make
 your head swim) why errors wouldn't be output to a browser window
 when they occur? For instance, I typed the following;

Are you 100% Tequila-worm sure you've got all the relevant ini flags
set? (display errors, E_ALL, yadda yadda) and that PHP on your lovely
Windows box is actually *using* that ini file and not the mystic
built-in one?

Tis the only reason I can think of that would halt it dead, because as
shocking as this may sound - PHP on Windows *can* actually display
errors ;)

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

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



RE: [PHP] Error Messages, Windows, and Tequila

2005-11-16 Thread Jay Blanchard
[snip]
Printing error messages to your output can be disabled with the
display_errors directive in your php.ini file.  To enable error
printing, the directive should read:

display_errors = On
[/snip]

You are correct sir, it is set to off by default. I will hike over to the
data center and flick the switch. Thanks!

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



Re: [PHP] Error Messages, Windows, and Tequila

2005-11-16 Thread Dan McCullough
Also check to make sure that its the right php.ini file, I have had a
problem in the past when the installer has put the php.ini file in the
WINDOWS directory and there is an existing one in the PHP directory as
well.  I would check phpinfo and see where the php.ini file is
located.

On 11/16/05, Richard Davey [EMAIL PROTECTED] wrote:
 Hi Jay,

 Wednesday, November 16, 2005, 4:36:25 PM, you wrote:

  Does anyone know (I have error reporting set so high it would make
  your head swim) why errors wouldn't be output to a browser window
  when they occur? For instance, I typed the following;

 Are you 100% Tequila-worm sure you've got all the relevant ini flags
 set? (display errors, E_ALL, yadda yadda) and that PHP on your lovely
 Windows box is actually *using* that ini file and not the mystic
 built-in one?

 Tis the only reason I can think of that would halt it dead, because as
 shocking as this may sound - PHP on Windows *can* actually display
 errors ;)

 Cheers,

 Rich
 --
 Zend Certified Engineer
 PHP Development Services
 http://www.corephp.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



[PHP] PHP PDO functions

2005-11-16 Thread Yonatan Ben-Nes

Hi all,

After searching for a framework which work with PostgreSQL  PHP I've 
found Framewerk (http://svn.framewerk.org/) which seem to fit my needs, 
the only problem that I've found is that it use the PDO functions.


Now maybe I'm wrong but I understood that database abstraction layers 
like PEAR::DB got their disadvantages, does PDO got disadvantages also 
compared for using specific pg_ functions?


Thanks in advance,
  Yonatan Ben-Nes

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



[PHP] Re: better way to mix html and php code?

2005-11-16 Thread Al

[EMAIL PROTECTED] wrote:

Hi to all,
always wondered what's better way to mix html and php code. Here are 
three ways of the same code. Which one you prefer? (And why, of caurse 
:))


Solution 1: 
 


?php
require 'includes/header.php';

$cat_parent = $_GET['cat_parent'];
$cat_id = $_GET['cat_id'];

echo 'table border=0 align=center cellpadding=1 cellspacing=0 
style=border: 1px solid #EBEBEB; padding: 25px;';

echo 'tr';
echo 'td align=left height=35 valign=top 
colspan=2bu'. $_SESSION['CATEGORIES']['name'][$cat_parent] .'  
'. $_SESSION['CATEGORIES']['name'][$cat_id] .'/u/b/td';
echo  'td align=center valign=bottom colspan=2a 
href=new_product.php?cat_id='.$cat_id.'cat_parent='.$cat_parent.' 
style=font-size: 11px; color: gray;[ Add New Product ]/a/td';

echo '/tr';

$query = my_query(
   SELECT chp.products_prod_id, p.prod_id, p.prod_name, 
p.prod_no, p.prod_status

   FROM categories_has_products as chp, products as p
   WHERE chp.categories_cat_id = '.$cat_id.' AND 
chp.products_prod_id = p.prod_id

   , 0);
while($result = mysql_fetch_array($query))
{
   echo 'tr';
   echo 'td align=left valign=topraquo; '. 
$result['prod_name'] .'/td';
   echo 'td align=center valign=top[ '. $result['prod_no'] 
.' ]/td';

   echo 'td align=center valign=top';
   echo 'img src=../images/icon_edit2.gif alt=EDIT 
width=14 height=14 hspace=0 vspace=0 border=0';
   echo 'a 
href=products.php?cat_id='.$cat_id.'cat_parent='.$cat_parent.'action=deleteprod_id='.$result['prod_id'].' 
onclick=return confirm(\'Do you really want to delete this 
product?\');img src=../images/icon_delete.gif alt=DELETE 
width=14 height=14 hspace=5 vspace=0 border=0/a';

   switch($result['prod_status'])
   {
   case 'live':
   echo 'a 
href=products.php?new_status=hiddenprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img 
src=../images/status_live.gif alt=LIVE width=13 height=13 
hspace=2 vspace=0 border=0/a';

   break;

   case 'hidden':
   echo 'a 
href=products.php?new_status=liveprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img 
src=../images/status_hidden.gif alt=HIDDEN width=13 height=13 
hspace=2 vspace=0 border=0/a';

   break;

   case 'temp':
   echo 'b[T]/b';
   break;

   }
   echo '/td';
   echo '/tr';
}
echo '/table';

include 'includes/footer.php';
?


Solution 2: 
 


?php
require 'includes/header.php';

$cat_parent = $_GET['cat_parent'];
$cat_id = $_GET['cat_id'];
?
table border=0 align=center cellpadding=1 cellspacing=0 
style=border: 1px solid #EBEBEB; padding: 25px;

   tr
   td align=left height=35 valign=top colspan=2bu?= 
$_SESSION['CATEGORIES']['name'][$cat_parent] ?  ?= 
$_SESSION['CATEGORIES']['name'][$cat_id] ?/u/b/td
   td align=center valign=bottom colspan=2a 
href=new_product.php?cat_id=?= $cat_id ?cat_parent=?= $cat_parent 
? style=font-size: 11px; color: gray;[ Add New Product ]/a/td

   /tr
?php
$query = my_query(
   SELECT chp.products_prod_id, p.prod_id, p.prod_name, 
p.prod_no, p.prod_status

   FROM categories_has_products as chp, products as p
   WHERE chp.categories_cat_id = '.$cat_id.' AND 
chp.products_prod_id = p.prod_id

   , 0);
while($result = mysql_fetch_array($query))
{
?
   tr
   td align=left valign=topraquo; ?= $result['prod_name'] 
?/td

   td align=center valign=top[ ?= $result['prod_no'] ? ]/td
   td align=center valign=top
   img src=../images/icon_edit2.gif alt=EDIT width=14 
height=14 hspace=0 vspace=0 border=0
   a href=products.php?cat_id=?= $cat_id ?cat_parent=?= 
$cat_parent ?action=deleteprod_id=?= $result['prod_id'] ? 
onclick=return confirm('Do you really want to delete this 
product?');img src=../images/icon_delete.gif alt=DELETE 
width=14 height=14 hspace=5 vspace=0 border=0/a


?php
   switch($result['prod_status'])
   {
   case 'live':
   echo 'a 
href=products.php?new_status=hiddenprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img 
src=../images/status_live.gif alt=LIVE width=13 height=13 
hspace=2 vspace=0 border=0/a';

   break;

   case 'hidden':
   echo 'a 

Re: [PHP] Re: better way to mix html and php code?

2005-11-16 Thread Anas Mughal
I wouldn't pick any of those approaches.

We did a quick POC for a site using approach #1.
Unfortunately, that POC code has lived to go into production.

Now, we are looking into some sort of framework that would allow us to
separatate of PHP code and HTML -- as much as possible. (Looking into Smarty
right now.) Haven't finalized the approach/framework yet. Any suggestions
would be welcomed.

Thanks.



On 11/16/05, Al [EMAIL PROTECTED] wrote:

 [EMAIL PROTECTED] wrote:
  Hi to all,
  always wondered what's better way to mix html and php code. Here are
  three ways of the same code. Which one you prefer? (And why, of caurse
  :))
 
  Solution 1:
 
 
 
  ?php
  require 'includes/header.php';
 
  $cat_parent = $_GET['cat_parent'];
  $cat_id = $_GET['cat_id'];
 
  echo 'table border=0 align=center cellpadding=1 cellspacing=0
  style=border: 1px solid #EBEBEB; padding: 25px;';
  echo ' tr';
  echo ' td align=left height=35 valign=top
  colspan=2bu'. $_SESSION['CATEGORIES']['name'][$cat_parent] .' 
  '. $_SESSION['CATEGORIES']['name'][$cat_id] .'/u/b/td';
  echo ' td align=center valign=bottom colspan=2a
  href=new_product.php?cat_id='.$cat_id.'cat_parent='.$cat_parent.'
  style=font-size: 11px; color: gray;[ Add New Product ]/a/td';
  echo ' /tr';
 
  $query = my_query(
  SELECT chp.products_prod_id, p.prod_id, p.prod_name,
  p.prod_no, p.prod_status
  FROM categories_has_products as chp, products as p
  WHERE chp.categories_cat_id = '.$cat_id.' AND
  chp.products_prod_id = p.prod_id
  , 0);
  while($result = mysql_fetch_array($query))
  {
  echo ' tr';
  echo ' td align=left valign=topraquo; '.
  $result['prod_name'] .'/td';
  echo ' td align=center valign=top[ '. $result['prod_no']
  .' ]/td';
  echo ' td align=center valign=top';
  echo ' img src=../images/icon_edit2.gif alt=EDIT
  width=14 height=14 hspace=0 vspace=0 border=0';
  echo ' a
  href=products.php
 ?cat_id='.$cat_id.'cat_parent='.$cat_parent.'action=deleteprod_id='.$result['prod_id'].'
  onclick=return confirm(\'Do you really want to delete this
  product?\');img src=../images/icon_delete.gif alt=DELETE
  width=14 height=14 hspace=5 vspace=0 border=0/a';
  switch($result['prod_status'])
  {
  case 'live':
  echo 'a
  href=products.php
 ?new_status=hiddenprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img
  src=../images/status_live.gif alt=LIVE width=13 height=13
  hspace=2 vspace=0 border=0/a';
  break;
 
  case 'hidden':
  echo 'a
  href=products.php
 ?new_status=liveprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img
  src=../images/status_hidden.gif alt=HIDDEN width=13 height=13
  hspace=2 vspace=0 border=0/a';
  break;
 
  case 'temp':
  echo 'b[T]/b';
  break;
 
  }
  echo ' /td';
  echo ' /tr';
  }
  echo '/table';
 
  include 'includes/footer.php';
  ?
 
 
  Solution 2:
 
 
 
  ?php
  require 'includes/header.php';
 
  $cat_parent = $_GET['cat_parent'];
  $cat_id = $_GET['cat_id'];
  ?
  table border=0 align=center cellpadding=1 cellspacing=0
  style=border: 1px solid #EBEBEB; padding: 25px;
  tr
  td align=left height=35 valign=top colspan=2bu?=
  $_SESSION['CATEGORIES']['name'][$cat_parent] ?  ?=
  $_SESSION['CATEGORIES']['name'][$cat_id] ?/u/b/td
  td align=center valign=bottom colspan=2a
  href=new_product.php?cat_id=?= $cat_id ?cat_parent=?= $cat_parent
  ? style=font-size: 11px; color: gray;[ Add New Product ]/a/td
  /tr
  ?php
  $query = my_query(
  SELECT chp.products_prod_id, p.prod_id, p.prod_name,
  p.prod_no, p.prod_status
  FROM categories_has_products as chp, products as p
  WHERE chp.categories_cat_id = '.$cat_id.' AND
  chp.products_prod_id = p.prod_id
  , 0);
  while($result = mysql_fetch_array($query))
  {
  ?
  tr
  td align=left valign=topraquo; ?= $result['prod_name']
  ?/td
  td align=center valign=top[ ?= $result['prod_no'] ? ]/td
  td align=center valign=top
  img src=../images/icon_edit2.gif alt=EDIT width=14
  height=14 hspace=0 vspace=0 border=0
  a href=products.php?cat_id=?= $cat_id ?cat_parent=?=
  $cat_parent ?action=deleteprod_id=?= $result['prod_id'] ?
  onclick=return confirm('Do you really want to delete this
  product?');img src=../images/icon_delete.gif alt=DELETE
  width=14 height=14 hspace=5 vspace=0 border=0/a
 
  ?php
  switch($result['prod_status'])
  {
  case 'live':
  echo 'a
  href=products.php
 ?new_status=hiddenprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img
  src=../images/status_live.gif alt=LIVE width=13 height=13
  hspace=2 vspace=0 border=0/a';
  break;
 
  case 'hidden':
  echo 'a
  href=products.php
 ?new_status=liveprod_id='.$result['prod_id'].'cat_id='.$cat_id.'cat_parent='.$cat_parent.'img
  src=../images/status_hidden.gif alt=HIDDEN width=13 height=13
  hspace=2 vspace=0 border=0/a';
  break;
 
  case 'temp':
  echo 

Re: [PHP] better way to mix html and php code?

2005-11-16 Thread Curt Zirzow
On Wed, Nov 16, 2005 at 10:12:53AM -0600, [EMAIL PROTECTED] wrote:
 Hi to all,
 always wondered what's better way to mix html and php code. Here are 
 three ways of the same code. Which one you prefer? (And why, of caurse :))
 
 Solution 2a:
 
?php
require 'includes/header.php';
 
$cat_parent = (int)$_GET['cat_parent'];
$cat_id = (int)$_GET['cat_id'];

$cat_names = $_SESSION['CATEGORIES']['name'];

?

table class=table-heading
tr
td
?php echo htmlentities($cat_names[$cat_parent])? ::
?php echo htmlentities($cat_names[$cat_id])?
/td
td
a href=new_product.php?cat_id=?php echo $cat_id 
?cat_parent=?php echo $cat_parent?[ Add New Product ]/a
/td
/tr
/table

table class=table-results
?php

$sql = SELECT  p.prod_id, p.prod_name, p.prod_no, p.prod_status
  FROM categories_has_products as chp, products as p
 WHERE chp.categories_cat_id = :cat_id 
   AND chp.products_prod_id = p.prod_id;

$stmt = $dbh-prepare($sql);
$stmt-bindParam(':cat_id', $cat_id);
$stmt-execute();

$query_cat_id_parent = products.php?cat_id=$cat_idcat_parent=$cat_parent; 
while($result = $stmt-fetch())
{
$query_product = $query_cat_id_parentprod_id={$result['prod_id']};

$del_link = $query_productaction=delete;

switch($result['prod_status'])
{
case 'live':
$status_link = $query_product .new_status=hidden;
$status_img  = 'live';
break;

case 'hidden':
$status_link = $query_product .new_status=live;
$status_img  = 'hidden';
break;

default:
case 'temp':
$status_link = '';
$status_img  = 'temp';
}

?

tr
td class=prod_nameraquo; ?php echo 
htmlentities($result['prod_name']); ?/td
td class=prod_no[ ?php echo $result['prod_no'] ? ]/td
td class=prod_action
img src=../images/icon_edit2.gif alt=EDIT 
width=14 height=14

a onclick=return confirm('Do you really want to 
delete this product?');
href=?php echo $del_link?
img src=../images/icon_delete.gif 
alt=DELETE width=14 height=14
/a

?php if($status_link) { ?
a href=?php echo $status_link?
img src=../images/status_?php echo 
$status_img?.gif 
alt=?php echo $status_img? 
width=13 height=13
/a
?php } else { ?
img src=../images/status_?php echo 
$status_img?.gif 
alt=?php echo $status_img? 
width=13 height=13
?php } ?

/td
/tr

?php

} // $stmt-fetch()

?
/table

?php

include 'includes/footer.php';
?

Curt.
-- 

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



[PHP] Formatting of a number

2005-11-16 Thread Scott Parks

Hi-

I have a number that I am trying to format.  It is data coming from a  
main frame and
has 8 characters assigned to it (6 and two decimal places).  I have  
zerofill set up in
MySQL on this field and am working on the best way to display the  
number.


Currently I have this:

$sOutput = number_format(rtrim($sValue,'0') /100,2);

What I am running into is this, I have a number in this field as:
3145900, using the above I will get:  314.59, which is wrong, it
needs to be 3,145.90.

Yet, if I have a number of:  749450, I get the result I am looking for
of 749.45.

I did not see a way to tell trim I only want one 0 cut?

Any thoughts?

Thank you!

-Scott

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



Re: [PHP] Formatting of a number

2005-11-16 Thread David Grant
Hi Scott,

How do you distinguish between a value filled with zeroes and a value
with 0 in both decimal positions?

For example, why is 3145900 expressed as 3,145.90, and not 31,459.00?

Cheers,

David Grant

Scott Parks wrote:
 Hi-
 
 I have a number that I am trying to format.  It is data coming from a
 main frame and
 has 8 characters assigned to it (6 and two decimal places).  I have
 zerofill set up in
 MySQL on this field and am working on the best way to display the number.
 
 Currently I have this:
 
 $sOutput = number_format(rtrim($sValue,'0') /100,2);
 
 What I am running into is this, I have a number in this field as:
 3145900, using the above I will get:  314.59, which is wrong, it
 needs to be 3,145.90.
 
 Yet, if I have a number of:  749450, I get the result I am looking for
 of 749.45.
 
 I did not see a way to tell trim I only want one 0 cut?
 
 Any thoughts?
 
 Thank you!
 
 -Scott
 
 --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



FW: [PHP] unsubscribing

2005-11-16 Thread Brown, Craig
I tried several times as well. So far, no luck. I tried the unsubscribe
address but it doesn't work.

-Original Message-
From: wayne [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 15, 2005 9:34 PM
To: php-general@lists.php.net
Subject: [PHP] unsubscribing


I tried to unsubscribe on several occasion without
success. I followed the instruction at the bottom 
of the email. Can someone take me off the list.
Thank You.

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

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



[PHP] How to build a XML DTD on the fly?

2005-11-16 Thread Erik Franzén
The code below lacks the part where the folling DTD attribute is 
created: !ATTLIST document id ID #IMPLIED


How can I create the above DTD attribute in the code below?

?php
// Creates an instance of the DOMImplementation class
$oDomImp = new DOMImplementation;

// Creates a DOMDocumentType instance
$oDomDtd = $oDomImp-createDocumentType('document', null, null);

// Creates a DOMDocument instance
$oDom = $oDomImp-createDocument(, , $oDomDtd);

// Set other properties
$oDom-encoding = 'iso-8859-1';
$oDom-standalone = true;

// Create an empty element
$oElement = $oDom-createElement('document', 'test');
$oElement-setAttribute('id', '123');
// Append the element
$oDom-appendChild($oElement);

// Retrieve and print the document
echo $oDom-saveXML() . \n;

echo TagName:  . $oDom-getElementById('123')-tagName;
?

Now the code produces the following result:

?xml version=1.0 encoding=iso-8859-1 standalone=yes?
!DOCTYPE document
document id=123test/document

TagName:


Thanks
/Erik

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



Re: [PHP] better way to mix html and php code?

2005-11-16 Thread Brent Baisley
You should separate HTML and PHP code into separate files to make it  
easily maintainable. Ideally, someone who knows HTML without any  
knowledge of PHP would be able to change the layout of the web page  
without breaking anything.
There are a bunch of examples of how to do this, usually falling  
under the MVC Design Pattern title. That's Model, View, Controller.


I use a simple substitution system to embed tags that represent  
data into my HTML files.


The html file would look something like:
table
trtdFirst Name/td
td{:FirstName:}/td
trtdLast Name/td
td{:LastName:}/td
/table

The php file would be something like:
$tpl= file_get_contents('htmlfile.htm');
//Assign Data to tags
$data['{:FirstName:}']= 'Brent';
$data['{:LastName:}']= 'Baisley';
//Get Tags to search on
$tags= array_keys($data);

//Populate html template with data
$content= str_replace($tags, $data, $tpl);
echo $tpl;


That's an extremely simplified templating system and an over  
simplified example. But it shows how you can easily completely  
separate html from php, presentation from logic. I find it far easier  
to work on than any of your three examples. Most importantly, it  
allows more talented interface designer design your interface, while  
you focus on the php and logic.



On Nov 16, 2005, at 11:12 AM, [EMAIL PROTECTED] wrote:


Hi to all,
always wondered what's better way to mix html and php code. Here  
are three ways of the same code. Which one you prefer? (And why,  
of caurse :))


Solution 1:  
## 
##

?php
require 'includes/header.php';

$cat_parent = $_GET['cat_parent'];
$cat_id = $_GET['cat_id'];

echo 'table border=0 align=center cellpadding=1  
cellspacing=0 style=border: 1px solid #EBEBEB; padding: 25px;';

echo 'tr';
echo 'td align=left height=35 valign=top  
colspan=2bu'. $_SESSION['CATEGORIES']['name'] 
[$cat_parent] .'  '. $_SESSION['CATEGORIES']['name'][$cat_id] .'/ 
u/b/td';
echo  'td align=center valign=bottom colspan=2a  
href=new_product.php?cat_id='.$cat_id.'cat_parent='. 
$cat_parent.' style=font-size: 11px; color: gray;[ Add New  
Product ]/a/td';

echo '/tr';

$query = my_query(
   SELECT chp.products_prod_id, p.prod_id, p.prod_name,  
p.prod_no, p.prod_status

   FROM categories_has_products as chp, products as p
   WHERE chp.categories_cat_id = '.$cat_id.' AND  
chp.products_prod_id = p.prod_id

   , 0);
while($result = mysql_fetch_array($query))
{
   echo 'tr';
   echo 'td align=left valign=topraquo; '. $result 
['prod_name'] .'/td';
   echo 'td align=center valign=top[ '. $result 
['prod_no'] .' ]/td';

   echo 'td align=center valign=top';
   echo 'img src=../images/icon_edit2.gif alt=EDIT  
width=14 height=14 hspace=0 vspace=0 border=0';
   echo 'a href=products.php?cat_id='. 
$cat_id.'cat_parent='.$cat_parent.'action=deleteprod_id='.$result 
['prod_id'].' onclick=return confirm(\'Do you really want to  
delete this product?\');img src=../images/icon_delete.gif  
alt=DELETE width=14 height=14 hspace=5 vspace=0  
border=0/a';

   switch($result['prod_status'])
   {
   case 'live':
   echo 'a href=products.php? 
new_status=hiddenprod_id='.$result['prod_id'].'cat_id='. 
$cat_id.'cat_parent='.$cat_parent.'img src=../images/ 
status_live.gif alt=LIVE width=13 height=13 hspace=2  
vspace=0 border=0/a';

   break;

   case 'hidden':
   echo 'a href=products.php? 
new_status=liveprod_id='.$result['prod_id'].'cat_id='. 
$cat_id.'cat_parent='.$cat_parent.'img src=../images/ 
status_hidden.gif alt=HIDDEN width=13 height=13 hspace=2  
vspace=0 border=0/a';

   break;

   case 'temp':
   echo 'b[T]/b';
   break;

   }
   echo '/td';
   echo '/tr';
}
echo '/table';

include 'includes/footer.php';
?


Solution 2:  
## 
##

?php
require 'includes/header.php';

$cat_parent = $_GET['cat_parent'];
$cat_id = $_GET['cat_id'];
?
table border=0 align=center cellpadding=1 cellspacing=0  
style=border: 1px solid #EBEBEB; padding: 25px;

   tr
   td align=left height=35 valign=top  
colspan=2bu?= $_SESSION['CATEGORIES']['name'][$cat_parent] ? 
  ?= $_SESSION['CATEGORIES']['name'][$cat_id] ?/u/b/td
   td align=center valign=bottom colspan=2a  
href=new_product.php?cat_id=?= $cat_id ?cat_parent=?=  
$cat_parent ? style=font-size: 11px; color: gray;[ Add New  
Product ]/a/td

   /tr
?php
$query = my_query(
   SELECT chp.products_prod_id, p.prod_id, p.prod_name,  

Re: [PHP] better way to mix html and php code?

2005-11-16 Thread Miles Thompson

At 05:04 PM 11/16/2005, Brent Baisley wrote:

You should separate HTML and PHP code into separate files to make it
easily maintainable. Ideally, someone who knows HTML without any
knowledge of PHP would be able to change the layout of the web page
without breaking anything.
There are a bunch of examples of how to do this, usually falling
under the MVC Design Pattern title. That's Model, View, Controller.

I use a simple substitution system to embed tags that represent
data into my HTML files.

The html file would look something like:
table
trtdFirst Name/td
td{:FirstName:}/td
trtdLast Name/td
td{:LastName:}/td
/table

The php file would be something like:
$tpl= file_get_contents('htmlfile.htm');
//Assign Data to tags
$data['{:FirstName:}']= 'Brent';
$data['{:LastName:}']= 'Baisley';
//Get Tags to search on
$tags= array_keys($data);

//Populate html template with data
$content= str_replace($tags, $data, $tpl);
echo $tpl;


That's an extremely simplified templating system and an over
simplified example. But it shows how you can easily completely
separate html from php, presentation from logic. I find it far easier
to work on than any of your three examples. Most importantly, it
allows more talented interface designer design your interface, while
you focus on the php and logic.


a lot of stuff snipped

This


td{:FirstName:}/td

is really so different from

td ?php echo $FirstName ? /td

Why learn a templating language on top of PHP? That's one of its reasons 
for being.


Yes, it can be a bit of a hash at times. Of all the suggestion offered, if 
I was dumped in and had to do so maintenance, Curt's was the cleanest example.


Cheers - Miles

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



Re: [PHP] Re: Zend + Eclipse + Standized Framework

2005-11-16 Thread Roman Ivanov

Greg Donald wrote:
Maybe Zend will get it right where all the previous attempts I've 
seen/used are less than great.


Personally, I would start creation of PHP framework by cleaning up PHP 
sytax. It's freakin' impossible to make complex OOP clean:


$this-output(array('dir', 'template'), new BlaBla($this-bla));

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



[PHP] Permissions problems with Windows Authentication in IIS

2005-11-16 Thread Paul Kane
For our company's intranet, I've turned on Windows Authentication in IIS
so that I can automatically capture the network username for everyone
hitting our website. It works well, but I'm having a problem with file
permissions now.
 
PHP normally executes the page request with the Intranet Guest User
account (IUSR_COMPUTERNAME). But with Windows Authentication enabled
(and Anonymous access disabled), PHP is executing the page request AS
the user requesting the page (for instance, \\DomainName\JohnSmith).
 
Further, John Smith is one of hundreds of employees that access the
site. In order for him and everyone else to upload files or have PHP
write files, I have to open up directories so that EVERYONE can
read/write/modify them. This seems like a step backwards, security-wise;
I'm worried about users mucking with each other's files.
 
Does anyone have a suggestion for a better solution? I would prefer the
previous method where PHP runs under a dedicated account (inaccessible
by employees), which would make my directory permissions problem
simpler.
 
Thank you!
 
 
Paul Kane
 

This e-mail and any attachments are intended for the designated recipient(s) 
only.
 If you have received this e-mail in error, please notify [EMAIL PROTECTED] and 
disregard this message. However, if you have obtained this e-mail via 
electronic 
eavesdropping, you are in violation of the Electronic Communications Privacy 
Act. 
Furthermore disclosure, copying, distribution, or taking of any action in 
reliance 
on the contents hereof is strictly prohibited without the explicit consent of 
University Federal Credit Union.





[PHP] Developement Environment for PHP?

2005-11-16 Thread Tom Cruickshank
Hello,
 I'm not sure if this has been asked before or not (probably has) but I
can't seem to find it. I'm looking for a Development Environment for PHP
other then vi. What I'm looking for is an environment which has powerful
debugging techniques and resources. Preferably using a Unix based platform
(that's what I'm developing on).

Would anyone have any suggestions?

Tom



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 11/16/2005
 

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



Re: [PHP] Developement Environment for PHP?

2005-11-16 Thread Dan McCullough
Zend Studio
PHPEclipse
LAMP + Notepad :)

On 11/16/05, Tom Cruickshank [EMAIL PROTECTED] wrote:
 Hello,
 I'm not sure if this has been asked before or not (probably has) but I
 can't seem to find it. I'm looking for a Development Environment for PHP
 other then vi. What I'm looking for is an environment which has powerful
 debugging techniques and resources. Preferably using a Unix based platform
 (that's what I'm developing on).

 Would anyone have any suggestions?

 Tom



 --
 No virus found in this outgoing message.
 Checked by AVG Free Edition.
 Version: 7.1.362 / Virus Database: 267.13.3/173 - Release Date: 11/16/2005


 --
 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] better way to mix html and php code?

2005-11-16 Thread Robert Cummings
On Wed, 2005-11-16 at 16:17, Miles Thompson wrote:
 At 05:04 PM 11/16/2005, Brent Baisley wrote:
 You should separate HTML and PHP code into separate files to make it
 easily maintainable. Ideally, someone who knows HTML without any
 knowledge of PHP would be able to change the layout of the web page
 without breaking anything.
 There are a bunch of examples of how to do this, usually falling
 under the MVC Design Pattern title. That's Model, View, Controller.
 
 I use a simple substitution system to embed tags that represent
 data into my HTML files.
 
 The html file would look something like:
 table
 trtdFirst Name/td
 td{:FirstName:}/td
 trtdLast Name/td
 td{:LastName:}/td
 /table
 
 The php file would be something like:
 $tpl= file_get_contents('htmlfile.htm');
 //Assign Data to tags
 $data['{:FirstName:}']= 'Brent';
 $data['{:LastName:}']= 'Baisley';
 //Get Tags to search on
 $tags= array_keys($data);
 
 //Populate html template with data
 $content= str_replace($tags, $data, $tpl);
 echo $tpl;
 
 
 That's an extremely simplified templating system and an over
 simplified example. But it shows how you can easily completely
 separate html from php, presentation from logic. I find it far easier
 to work on than any of your three examples. Most importantly, it
 allows more talented interface designer design your interface, while
 you focus on the php and logic.
 
 a lot of stuff snipped
 
 This
 
 td{:FirstName:}/td
 is really so different from
 
 td ?php echo $FirstName ? /td
 
 Why learn a templating language on top of PHP? That's one of its reasons 
 for being.

Because templating generally enforces better separation of business
logic from display logic. Because templating usually offers a less
esoteric way of working with the data (although as we all know, not
always). Because templates can allow the pre-computing of content such
that overhead can be reduced for all subsequent retrievals (and yes I
mean true savings without using a cache though mileage differs from one
system to the next). Because template tags are often shorter and
clearer. because template tags can resemble HTML, with which designers
are already familiar. Because template tags can allow for arbitrary
ordering of parameters with arbitrary parameters being optional without
the need to use an array. Because...

Anyways you suggest learning a templating language on top of PHP which
presumes the designer knows PHP in the first place. In which case if the
designer does not, a tag based system is what they already know from
which logically follows... why learn a PHP system on top of XML (of
which HTML is a subset)?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Kevin Smith

Hi All,

Ok, before we start, I know this topic has been flogged to death on how 
to load images from a database using PHP. So, before we start, I have 
had this method of loading images in this way working for years. :) 
However, the problem I've come across has given me a major headache and 
can't find a solution to the problem.


So on to the problem

I have 2 servers (setup details below).  Server #1 loads the images from 
the MySQL database using PHP perfectly.  However, Server #2, which has 
identical versions of Apache, MySQL, PHP and were compiled with the 
exact same parameters, doesn't want to even bother working.  The PHP 
scripts just outputs a bunch of text, which I have seen before if 
certain headers are incorrectly built.  However, there is no difference 
in the installation of the software, apart from the OS and that fact 
that Server #2's MySQL RPM was built specifically for Redhat Enterprise 4.


Server #1

Fedora Core 2 (fully patched)
Apache 2.0.55 (compiled from source)
MySQL-4.1.5 (RPM glibc 2.3)
PHP-4.4.1 (compiled from source)

Server #2

Redhat Enterprise 4 (fully patched)
Apache 2.0.55 (compiled from source)
MySQL-4.1.5 (RPM Redhat Enterprise 4 version)
PHP-4.4.1 (compiled from source)

If I export the data from the MySQL database into a file and then call 
it from the browser, the image shows perfectly, so we're not dealing 
with corrupt data.  I use SQLYog to also administer the databases, 
viewing the BLOB field using this tool allows me to view the image 
stored, and it shows perfectly well.


Data returned from httpd -l, httpd -V, php -v and php -m show 
identical builds.


Has anyone come across this problem before?  Also the httpd.conf and 
php.ini files are identical in everyway, apart from IP addresses.


Many thanks,

Kevin Smith



smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Robert Cummings
On Wed, 2005-11-16 at 18:01, Kevin Smith wrote:

 Has anyone come across this problem before?  Also the httpd.conf and 
 php.ini files are identical in everyway, apart from IP addresses.

Did you double check in the phpinfo() output for each server that the
php.ini is being loaded for where you think it's being loaded?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Kevin Smith




HI Robert,

I have checked both phpinfo() and php -i via the cli as follows and
both produce the expected results. Also phpinfo() shows the exact same
"Configure Command" data for both servers.

Server #1
[EMAIL PROTECTED] limiteds_v2]# php -i | grep ini
Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

Server #2
[EMAIL PROTECTED] domains]# php -i | grep ini
Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

Also both php.ini files have PHPSESSID specifically set to only work
with cookies. If this was not the case, the website wouldn't work
very well, which the sites do, apart from the images on Server #2. :(

Any other ideas? This is a very strange one.

To show you what happens, here's the site that works and the one that
doesn't:

Server #1 (working)
http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2

Server #2 (sad and not working)
http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2

Regards,

Kevin

Robert Cummings wrote:

  On Wed, 2005-11-16 at 18:01, Kevin Smith wrote:
  
  
Has anyone come across this problem before?  Also the httpd.conf and 
php.ini files are identical in everyway, apart from IP addresses.

  
  
Did you double check in the phpinfo() output for each server that the
php.ini is being loaded for where you think it's being loaded?

Cheers,
Rob.
  





smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Curt Zirzow
On Wed, Nov 16, 2005 at 11:44:27PM +, Kevin Smith wrote:
 HI Robert,
 
 Server #1 (working)
 http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2
 
Headers for this one:
Content-Transfer-Encoding: binary
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
P3P: CP=NOI DSP COR NID CUR OUR NOR
Content-Length: 12547
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: image/jpeg


 Server #2 (sad and not working)
 http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2
 
And This one:
P3P: CP=NOI DSP COR NID CUR OUR NOR
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1


Something is different.

Curt.

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



Re: [PHP] better way to mix html and php code?

2005-11-16 Thread David Tulloh
Curt Zirzow wrote:
 On Wed, Nov 16, 2005 at 10:12:53AM -0600, [EMAIL PROTECTED] wrote:
 
Hi to all,
always wondered what's better way to mix html and php code. Here are 
three ways of the same code. Which one you prefer? (And why, of caurse :))


Personally, I present solution 2b.  I also don't like the idea of
a(nother) templating language either.  When doing html like this I also
like using short tags because it looks better and the colon syntax for
ifs as I find it easier for non-programmers and easier to follow in
large blocks of html.  That should be enough to get everyone here screaming.

I would also wrap this file inside a layout script and/or use prepend
and append files.  Depending on the overall use I'd consider pushing
some of it into another file.  There is too much php code in there at
the moment.

David

Solution 2b:


table class=table-heading!-- should probably be a div --
tr
td
?=$cat_parent_name? ::
?=$cat_id_name?
/td
td
a href=new_product.php?cat_id=?php echo $cat_id
?cat_parent=?php echo $cat_parent?[ Add New Product ]/a
/td
/tr
/table

table class=table-results
? foreach ($products as $product): ?
tr
td class=prod_nameraquo; ?=product_name'?/td
td class=prod_no[ ?=$product_number? ]/td
td class=prod_action
img src=../images/icon_edit2.gif alt=EDIT 
width=14 height=14

a onclick=return confirm('Do you really want to 
delete this
product?');
href=?=$del_link?
img src=../images/icon_delete.gif 
alt=DELETE width=14
height=14
/a

? if($status_link): ?
a href=?=$status_link?
img 
src=../images/status_?=$status_img?.gif
alt=?=$status_img? 
width=13 height=13
/a
? else: ?
img src=../images/status_?=$status_img?.gif
alt=?=$status_img? width=13 
height=13
? endif; ?

/td
/tr

? endforeach; ?
/table

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



Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Robert Cummings
On Wed, 2005-11-16 at 18:44, Kevin Smith wrote:

 Any other ideas?  This is a very strange one.

The headers aren't the same, specifically the second one doesn't send
the type as image/jpeg.

Here's the first one:

-
[EMAIL PROTECTED]:~/sjhdsjhdsa wget -S
http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2;
--19:01:33-- 
http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2
   = `image_load.php?image_id=8522field_id=image_full_2'
Resolving www.limiteds.com... 217.168.144.110
Connecting to www.limiteds.com[217.168.144.110]:80... connected.
HTTP request sent, awaiting response... 
 1 HTTP/1.1 200 OK
 2 Date: Thu, 17 Nov 2005 00:01:12 GMT
 3 Server: Apache/2.0.55 (Unix) mod_ssl/2.0.55 OpenSSL/0.9.7a DAV/2
PHP/4.4.1
 4 X-Powered-By: PHP/4.4.1
 5 Content-Transfer-Encoding: binary
 6 Content-Length: 13184
 7 Vary: Accept-Encoding,User-Agent
 8 P3P: CP=NOI DSP COR NID CUR OUR NOR
 9 Keep-Alive: timeout=15, max=100
10 Connection: Keep-Alive
11 Content-Type: image/jpeg

100%[===] 
13,18455.98K/s 

19:01:33 (55.77 KB/s) -
`image_load.php?image_id=8522field_id=image_full_2' saved [13184/13184]
-


Here's the second one:

-
[EMAIL PROTECTED]:~/sjhdsjhdsa wget -S
http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2;
--19:01:37-- 
http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2
   = `image_load.php?image_id=8522field_id=image_full_2.1'
Resolving www.limitedshop.co.uk... 83.138.141.171
Connecting to www.limitedshop.co.uk[83.138.141.171]:80... connected.
HTTP request sent, awaiting response... 
 1 HTTP/1.1 200 OK
 2 Date: Thu, 17 Nov 2005 00:01:17 GMT
 3 Server: Apache/2.0.55 (Unix) mod_ssl/2.0.55 OpenSSL/0.9.7a DAV/2
PHP/4.4.1
 4 X-Powered-By: PHP/4.4.1
 5 Vary: Accept-Encoding,User-Agent
 6 P3P: CP=NOI DSP COR NID CUR OUR NOR
 7 Connection: close
 8 Content-Type: text/html; charset=ISO-8859-1

[  =  
] 13,18552.99K/s 

19:01:38 (52.94 KB/s) -
`image_load.php?image_id=8522field_id=image_full_2.1' saved [13185]
-




-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Curt Zirzow
On Wed, Nov 16, 2005 at 11:44:27PM +, Kevin Smith wrote:
 HI Robert,
 
 I have checked both phpinfo() and php -i via the cli as follows and both 
 produce the expected results.  Also phpinfo() shows the exact same 
 Configure Command data for both servers.
 
 Server #1
 [EMAIL PROTECTED] limiteds_v2]# php -i | grep ini
 Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini
 
 Server #2
 [EMAIL PROTECTED] domains]# php -i | grep ini
 Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

Oh and also, you really should check the output of the phpinfo()
through the browser, the php cli file could be reading a different
file.

 
 Also both php.ini files have PHPSESSID specifically set to only work 
 with cookies. If this was not the case, the website wouldn't work very 
 well, which the sites do, apart from the images on Server #2. :(

PHP by default uses cookies.


Curt.
-- 

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



Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Kevin Smith




Hi Curt,

In that case, what on earth is going on. This is the script which is
on both servers: However, I noticed that if I moved the following
lines to the top of the script:

header("Content-Type: image/jpeg");
header("Content-Transfer-Encoding: binary");

..and hard-code the mime type, it outputs the correct headers, apart
from "Transfer-Encoding:chunked". Which seems to still screw
it up. The content length is wrong (13198), it should be
13184. Looking at the RAW output of the image data, there is a
difference. I noticed 3381 was output as part of the image data, yet
this is not so on the Server #1, that works. Even if I fix the
content-length header to what it should be, it still has some
differences.

It still bugs me that the data is absolutely fine in the database, as I
can save the data out of it into a file and view that file as an image
with no problems at all.

Anything else you can think of?

Thanks,

Kevin

?php
require('../classes/housekeeping.php');
$db_conn = new HOUSEKEEPING;
$limiteds = $db_conn-database();

require('../classes/categories.php');

if ( isset($_GET['image_id'])  isset($_GET['field_id'])
 isset($_GET['mime_type']) )
{
 $image_info = new CATEGORY;
 $image_info-LINK = $limiteds;
 $image_info-IMAGE_ID = $_GET['image_id'];
 $image_info-FIELD_ID = $_GET['field_id'];
 $image_info-get_thumb_image();
 
 header("Content-Type: ".$_GET['mime_type']);
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".strlen($image_info-IMAGE_THUMB));
 echo $image_info-IMAGE_THUMB;
}
elseif ( isset($_GET['image_id'])  isset($_GET['field_id']) )
{
 $image_info = new CATEGORY;
 $image_info-LINK = $limiteds;
 $image_info-IMAGE_ID = $_GET['image_id'];
 $image_info-FIELD_ID = $_GET['field_id'];
 $image_info-get_thumb_image();
 
 header("Content-Type: $image_info-MIME_TYPE");
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".strlen($image_info-IMAGE_THUMB));
 echo $image_info-IMAGE_THUMB;
}
?


Curt Zirzow wrote:

  On Wed, Nov 16, 2005 at 11:44:27PM +, Kevin Smith wrote:

  
HI Robert,

Server #1 (working)
http://www.limiteds.com/includes/image_load.php?image_id=8522field_id=image_full_2


  
  Headers for this one:
Content-Transfer-Encoding: binary
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
P3P: CP="NOI DSP COR NID CUR OUR NOR"
Content-Length: 12547
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: image/jpeg



  
Server #2 (sad and not working)
http://www.limitedshop.co.uk/includes/image_load.php?image_id=8522field_id=image_full_2

  
   
And This one:
P3P: CP="NOI DSP COR NID CUR OUR NOR"
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1


Something is different.

Curt.







smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] Shared Memory Problem

2005-11-16 Thread Yaswanth Narvaneni
Hi!

I found the solution to my prob. SELinux was enabled in the server
which needs disabling. After disabling SELinux it was working great.
Thanks for your help guys.

Another small query though, is there anyway to enable SELinux and as
well use shared memory between PHP and C++? I know using Zend engine
would solve the prob, but we need to buy zend which is very costly for
me, any other solution is welcome.

Regards,
Yaswanth

On 11/16/05, Curt Zirzow [EMAIL PROTECTED] wrote:
 On Wed, Nov 16, 2005 at 03:33:22AM +0530, Yaswanth Narvaneni wrote:
  Hi!
 
  I have a server written in C++ and my webpages are in PHP. The PHP has
  to communicate with the server using shared memory. This was working
  fine on the server running FC-1 with php-4.3.8. We recently migrated
  to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it
  displays is as follows:
 
  shmop_open(): unable to attach or create shared memory segment in
  /var/www/html/sharedmem.php on line 2
 
  The server opens the shm in 666 (originally was 644) even then it was
  not working. I can see the shared mem open using 'ipcs' command.
 
  ...
  $shm_id = shmop_open($shm_key, a,0,0) or die(FATAL ERROR:: Unable
  to Access Shared Memory);

 You might want to try to open it within the same mode that the
 server created it in:

 1)
   $shm_id = shmop_open($shm_key, a,0666,0);

 2)
   are you 100% sure the key is valid? the error message you are
   getting seems to point in this direction since the shmop_open is
   failing on the C call to shmget(), wich usually fails when either
   you dont have enough memory to create it (which you arn't doing),
   some other creation problems, or that the key supplied wasn't
   found.


 Curt.
 --

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




--
In theory there is no difference between theory and practice.
In practice there is. -- Fortune Cookie

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



Re: [PHP] Loading Images from PHP broken on Redhat Enterprise

2005-11-16 Thread Kevin Smith




Solved!

I don't believe it, there was an extra carriage return in the require
file "housekeeping.php". This carriage return "is" present on Server
#1, but Server #2 obviously doesn't like it.

I am now going to stick my head out of my window and scream for not
thinking that that could have been a possibility.

Severely in need of some therapy.

Thank you for all your help, Curt and Robert :)

Regards,

Kevin

Curt Zirzow wrote:

  On Wed, Nov 16, 2005 at 11:44:27PM +, Kevin Smith wrote:
  
  
HI Robert,

I have checked both phpinfo() and php -i via the cli as follows and both 
produce the expected results.  Also phpinfo() shows the exact same 
"Configure Command" data for both servers.

Server #1
[EMAIL PROTECTED] limiteds_v2]# php -i | grep ini
Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

Server #2
[EMAIL PROTECTED] domains]# php -i | grep ini
Configuration File (php.ini) Path = /usr/local/Zend/etc/php.ini

  
  
Oh and also, you really should check the output of the phpinfo()
through the browser, the php cli file could be reading a different
file.

  
  
Also both php.ini files have PHPSESSID specifically set to only work 
with cookies. If this was not the case, the website wouldn't work very 
well, which the sites do, apart from the images on Server #2. :(

  
  
PHP by default uses cookies.


Curt.
  





smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] Developement Environment for PHP?

2005-11-16 Thread John Nichel

Tom Cruickshank wrote:

Hello,
 I'm not sure if this has been asked before or not (probably has) but I
can't seem to find it. I'm looking for a Development Environment for PHP
other then vi. What I'm looking for is an environment which has powerful
debugging techniques and resources. Preferably using a Unix based platform
(that's what I'm developing on).

Would anyone have any suggestions?


Yeah, it's been asked once or twice

http://marc.theaimsgroup.com/?l=php-generalw=2r=1s=php+editorq=t

I'll just say I used Zend Studio, give you this link...

http://www.thelinuxconsultancy.co.uk/phpeditors.php

...and watch Pandora's box come fully open from afar.

--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

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



Re[2]: [PHP] Regex for Amateur Radio Callsigns

2005-11-16 Thread Leif Gregory
Hello Leonard,

Tuesday, November 15, 2005, 8:39:19 PM, you wrote:
 Here are how they look
 W1W
 W1AW
 WA1W
 AD4HZ
 N9URK
 WB6NOA
 4N1UBG

Let's do it this way... What are the rules for a valid callsign?

i.e.
- If it's only three characters, it must start with a letter.
- All callsigns must have both alpha and numeric components.
- A callsign can not have to identical letters next to each other
- A callsign is always written in uppercase

etc.

If we know what the rules are that constitute a valid callsign, then
we can help you write a regexp.


-- 
  TBUDL/BETA/DEV/TECH Lists Moderator / PGP 0x6C0AB16B
 __       Geocaching:http://gps.PCWize.com
(  )  ( ___)(_  _)( ___)  TBUDP Wiki Site:  http://www.PCWize.com/thebat/tbudp
 )(__  )__)  _)(_  )__)   Roguemoticons  Smileys:http://PCWize.com/thebat
()()()(__)PHP Tutorials and snippets:http://www.DevTek.org

Do not disturb. Already disturbed! 

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



Re: Re[2]: [PHP] Regex for Amateur Radio Callsigns

2005-11-16 Thread Leonard Burton
HI,

 Tuesday, November 15, 2005, 8:39:19 PM, you wrote:
  Here are how they look
  W1W
  W1AW
  WA1W
  AD4HZ
  N9URK
  WB6NOA
  4N1UBG

 Let's do it this way... What are the rules for a valid callsign?

Basicly, you see an example of each different type of callsign.  Other
than the patterns you  see above there are no real rules.  A letter in
the example above means that there can only be a letter in the spot
and a number in a spot means there can only be a number in that spot. 
There are 7 different formats and you see the one above.

Did you see the regex I had in a previous post?

Thanks for your response.

--
Leonard Burton, N9URK
[EMAIL PROTECTED]


The prolonged evacuation would have dramatically affected the
survivability of the occupants.

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



[PHP] Re: better way to mix html and php code?

2005-11-16 Thread Roman Ivanov

For long strings I suggest using
echo EOTHML
EOHTML;

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



Re: [PHP] Error Command failed for target 'ext/xml/xml.lo' during make process (Solaris 8)

2005-11-16 Thread Curt Zirzow
On Tue, Nov 15, 2005 at 09:20:54PM +0100, Age Bosma wrote:
 Hi,
 
 I'm trying to compile php 4.4.1 on Solaris 8 but I'm getting the error
 Command failed for target 'ext/xml/xml.lo' during the make process.
 
 [snip]
 /nfs/dm11-fs22/work/training/dj365/php-4.4.1/ext/xml/xml.c:1582:
 `XML_Char' undeclared (first use in this function)
 ...
 make: Fatal error: Command failed for target 'ext/xml/xml.lo'
 
 If I look in the 'ext/xml/' folder, there's no file called 'xml.lo'.
 What can be the problem here?

It is trying to make the xml.lo file, the errors prior to that
explain why.

 
 I used the following configuration with gcc 3.2.3:
 
 configure --prefix=/work/training/dg432/servsoft/php4
 --with-apxs2=/work/training/dg432/servsoft/apache2/bin/apxs
 --with-mysql=/work/training/dg432/servsoft/mysql4 --enable-calendar
 --enable-ftp --with-gettext --with-iconv
 --with-dom=/work/training/dg432/servsoft
 --with-dom-xslt=/work/training/dg432/servsoft

This is an odd configure line, i'm guessing this is some sort of
package thing.  At first glance at the the errors above, i would
guess that this package has some version issues.

 Except for gettext and iconv I manually compiled all packaged myself.
 
 In addition to this, I got two warnings during the configuration process:
 configure: warning: You will need bison 1.28 and configure: warning:
 You will need bison 1.28 if you want to regenerate the Zend parser
 (found 1.27)
 Could this have anything to do with it?

most likely not.

Curt.
-- 

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



Re: [PHP] PHP PDO functions

2005-11-16 Thread Curt Zirzow
On Wed, Nov 16, 2005 at 07:29:18PM +0200, Yonatan Ben-Nes wrote:
 Hi all,
 
 After searching for a framework which work with PostgreSQL  PHP I've 
 found Framewerk (http://svn.framewerk.org/) which seem to fit my needs, 
 the only problem that I've found is that it use the PDO functions.
 
 Now maybe I'm wrong but I understood that database abstraction layers 
 like PEAR::DB got their disadvantages, does PDO got disadvantages also 
 compared for using specific pg_ functions?

If you are using the framework I'm not sure how it talks to a
database matters.

Curt.
-- 

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



Re: [PHP] Set Timezone to localtime in php.ini

2005-11-16 Thread Curt Zirzow
On Tue, Nov 15, 2005 at 09:49:10PM -0700, The Doctor wrote:
 IS their a way to set the time to localtime instead of GMT in
 the ini file?

No.

 
 Some users are complaining that they are seeing GMT, which this server
 is set to.

What timezone are the users expecting the time to be displayed in?
Do they get to specify what TZ they are in?

For starters i would suggest looking into the setlocale() function.

Curt.
-- 

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



Re: [PHP] Validating Email addrs

2005-11-16 Thread Curt Zirzow
On Wed, Nov 16, 2005 at 07:39:28AM -, George Pitcher wrote:
 I grabbed the following from a web-published article (sorry, can't remember
 where):

There a few things wrong with it as well.

 
 function validate_email($email) {
   if(preg_match(/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] 
 )+(
 \.[a-zA-Z0-9_-] +)+$/ , $email)){
 
Problem #1
  - with those spaces in the expression i would assume it really
needs to have the /x modifier, i would hardly thing that anyone
will type:
' c  zirzow @ gmail .c '
  - it doesn't consider emails like [EMAIL PROTECTED]

I think there was a 300+ line regex to catch all cases, posted
earlier.


   list($username,$domain)=split('@',$email);
   if(!customCheckDnsrr($domain)){
 ...
 function customCheckDnsrr($host,$recType='') {
   if(!empty($host)) {
   if($recType=='') $recType=MX;
   exec(nslookup -type=$recType $host,$output);
 ...

Problem #2
 - an MX record isn't required to deliver email. Try a:
nslookup -type=MX zirzow.dyndns.org then send an email to
[EMAIL PROTECTED], i will get it.

   foreach($output as $line) {
   if(preg_match(/^$host/, $line)) {

Problem #3
 - MX hosts dont *have* to resolve to the same host it is doing
   mail for, it  generally does resolve that way, in most cases.
   
 
 Never tested this, so can't comment on usefulness.

Uh.. well, i hope problems 1-3 should contribute to its (un)usefulness.

Curt.
-- 

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