php-general Digest 10 Jul 2008 15:07:41 -0000 Issue 5561

Topics (messages 276554 through 276593):

can any one help me on this
        276554 by: willyam pax
        276555 by: Bob
        276556 by: Robert Cummings

Re: zippidity do duh!
        276557 by: Nathan Nobbe

Re: PHP code will not work
        276558 by: Sanjay Mantoor
        276559 by: Ted Wood
        276586 by: Daniel Brown
        276593 by: Richard Heyes

Re: Logic sought
        276560 by: Per Jessen
        276571 by: Peter Ford

Pear DB
        276561 by: John Comerford
        276562 by: Jason Norwood-Young
        276563 by: Larry Garfield
        276564 by: Alex Chamberlain
        276566 by: Lester Caine

scalable web gallery
        276565 by: paragasu
        276567 by: Andreas J.
        276568 by: mike
        276569 by: Thodoris
        276573 by: Per Jessen
        276576 by: paragasu
        276589 by: Daniel Brown

Re: What font/size do you use for programming?
        276570 by: Peter Ford
        276574 by: Colin Guthrie
        276579 by: Eric Butera
        276583 by: Daniel Brown
        276584 by: Daniel Brown
        276585 by: Daniel Brown
        276588 by: Philip Thompson
        276590 by: Colin Guthrie
        276592 by: Jason Pruim

Re: Need help with regular expression
        276572 by: Maxim Antonov
        276577 by: Boyd, Todd M.
        276580 by: Al
        276581 by: Eric Butera

Error handling, apache and ErrorDocument
        276575 by: Daniele Grillenzoni

PHP and Modbus
        276578 by: Tom Chubb

phpmyadmin
        276582 by: Ronald Wiplinger
        276587 by: Wolf
        276591 by: Will Fitch

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Warning:session_start():Canot send session cache limiter - headers already 
sent

help me i dont understand this warning...
but the program still works...
thanks in advance...



--- End Message ---
--- Begin Message ---
It's probably some white space above your session_start function.

Make sure that there is no white space before your <?php start tag and try
again.

-----Original Message-----
From: willyam pax
Sent: 10 July 2008 13:13
To: [EMAIL PROTECTED]
Subject: [PHP] can any one help me on this

Warning:session_start():Canot send session cache limiter - headers already 
sent

help me i dont understand this warning...
but the program still works...
thanks in advance...


--- End Message ---
--- Begin Message ---
On Thu, 2008-07-10 at 11:13 +0800, willyam pax wrote:
> Warning:session_start():Canot send session cache limiter - headers already

It means you have output going to the browser before you begin your
session with session_start(). This usually means you have trailing
whitespace in an included file where you've used the closing PHP tag.

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


--- End Message ---
--- Begin Message ---
On Wed, Jul 9, 2008 at 6:52 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:

> try triggering an E_FATAL instead of E_NOTICE and you'll see
> there is no need to use Exceptions in this case (albeit that
> it's an acceptable alternative).
>

minor but, it would have to be E_USER_ERROR, because you can only trigger
E_USER_* errors from trigger_error().  anyway, that will halt script
execution, unless there is a handler specified with set_error_handler(),
which i would consider undesirable.  it seems to me it would be better to
acknowledge the issue and move on to other things during the request
processing, which is why in this case, and with most trigger_error() cases,
i typically use E_USER_NOTICE, unless i really intend to have the script
execution terminated, or i know for sure there is an error handler in place.

the reason i recommended an exception is because tedd was making it sound
like he wanted to alter the flow of control.  well, in that case, you dont
need exceptions, the alternate logic could obviously be placed in the body
of the else block, along with, or instead of, the trigger_error() call.  as
well, this could be turned into a function which would return a boolean
value, or accept a callback, or make me breakfast...  yes, there are many
ways to skin the cat here :)

and no, i likely wouldnt use an exception here, unless this was part of a
class (which in my code it likely would be :D).

-nathan

--- End Message ---
--- Begin Message ---
Hi,

I found
$_SERVER['HTTP_USER_AGENT'] works when you are using with browser by
server like Apache.

If you are executing your code like script in command prompt it may not work.
I got below :-
PHP Notice:  Undefined index: HTTP_USER_AGENT

If you use print_r($_SERVER) , you can see all the listing of indexes.



On Wed, Jul 9, 2008 at 7:15 PM, Mike V <[EMAIL PROTECTED]> wrote:
>
> I had this problem and just figured it out.  I was copying and pasting the
> code snippet from the tutorials page to my test editor and in the process
> picked up an invisible ctrl char.  Doh!!
>
>
> Joseph Subida wrote:
>>
>>
>> The error I get when I try
>>
>> <?php
>> echo $_SERVER['HTTP_USER_AGENT'];
>> ?>
>>
>> is
>>
>> Parse error: syntax error, unexpected T_VARIABLE in
>> /Library/WebServer/Documents/test.php on line 106
>>
>> I tried Googling "T_VARIABLE" and haven't found any useful solutions.
>> Any ideas? Thanks!
>>
>> -J.C.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/PHP-code-will-not-work-tp17811807p18362005.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Thanks,
Sanjay Mantoor

--- End Message ---
--- Begin Message ---

PHP at the command line doesn't run within a web server environment.

~Ted


On 9-Jul-08, at 11:07 PM, Sanjay Mantoor wrote:

Hi,

I found
$_SERVER['HTTP_USER_AGENT'] works when you are using with browser by
server like Apache.

If you are executing your code like script in command prompt it may not work.
I got below :-
PHP Notice:  Undefined index: HTTP_USER_AGENT

If you use print_r($_SERVER) , you can see all the listing of indexes.



On Wed, Jul 9, 2008 at 7:15 PM, Mike V <[EMAIL PROTECTED]> wrote:

I had this problem and just figured it out. I was copying and pasting the code snippet from the tutorials page to my test editor and in the process
picked up an invisible ctrl char.  Doh!!


Joseph Subida wrote:


The error I get when I try

<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>

is

Parse error: syntax error, unexpected T_VARIABLE in
/Library/WebServer/Documents/test.php on line 106

I tried Googling "T_VARIABLE" and haven't found any useful solutions.
Any ideas? Thanks!

-J.C.

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




--
View this message in context: 
http://www.nabble.com/PHP-code-will-not-work-tp17811807p18362005.html
Sent from the PHP - General mailing list archive at Nabble.com.


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





--
Thanks,
Sanjay Mantoor

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



--- End Message ---
--- Begin Message ---
On Thu, Jul 10, 2008 at 2:15 AM, Ted Wood <[EMAIL PROTECTED]> wrote:
>
> PHP at the command line doesn't run within a web server environment.

    Correct.  EGPCS is inaccessible via the CLI (unless you
force-populate the variables and arrays).  Only via a web server will
you have access to:

        $_ENV
        $_GET
        $_POST
        $_COOKIE
        $_SERVER
            - and -
        $_SESSION

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---
--- Begin Message ---
        $_ENV
>        $_SERVER

$_ENV and $_SERVER are. Though their contents are doubtless different.

--
Richard Heyes

Employ me:
http://www.phpguru.org/cv

--- End Message ---
--- Begin Message ---
tedd wrote:

> If two, or more, users hit the site at the same time then a RACE
> condition may have one user getting something they didn't ask for or
> not getting anything at all.
> 
> The complicated way I figure I could solve this would be to:
> 
> 1. Generate a random string name for the file -- instead of test.zip,
> it could be ax12nhg34.zip.

Either a random name or one based on the session_id(). 

> I know this will work, but if the user never downloads the file, then
> the files accumulate on the server.

Use cron to run a daily job of 

'find /yourtempdir -type f -ctime +1 | xargs rm'

Run more often and/or with less ctime if you need the space or the site
is very busy.


/Per Jessen, Zürich


--- End Message ---
--- Begin Message ---
tedd wrote:
Hi gang:

Here's the logic problem.

First the site:

http://php1.net/b/zip-files/

Now, the site works well enough. The user selects what they want, clicks Submit, the order is assembled in zip file and presented to the user for downloading.

However, as it stands now, before the script assembles the test.zip, it deletes (unlinks) the previous test.zip and therein lies the problem.

If two, or more, users hit the site at the same time then a RACE condition may have one user getting something they didn't ask for or not getting anything at all.

The complicated way I figure I could solve this would be to:

1. Generate a random string name for the file -- instead of test.zip, it could be ax12nhg34.zip.

2. Then when the user selects the download that would trigger a javascript routine that would send the name of the file to be deleted to a slave php script that would unlinks the file.

I know this will work, but if the user never downloads the file, then the files accumulate on the server.

Does anyone have a better idea?

Thanks,

tedd


For bespoke downloads I create a directory somewhere named with the session ID, then build the download file there and only allow access throw a PHP script which knows the session ID. I guess it depends how commercial or sensitive the data is.
Then I have a cron or something clean up the old directories.

It would be nice to have some sort of trigger to indicate that the session has expired - anyone know if Apache can do such a thing? In a Java environment, I used a session object which cleaned up such folders when it was garbage-collected...

--
Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

--- End Message ---
--- Begin Message ---
Hi Folks,

I have just successfully lobbied for the company I work for to use PHP/MySQL for our next website. My Question is regarding DB abstraction . I know there is a Pear DB module, is this the best to use ? I have a vague memory of reading somewhere that there is a newer lib or something which is considered better ?

TIA,
 JC

--- End Message ---
--- Begin Message ---
On Thu, 2008-07-10 at 16:47 +1000, John Comerford wrote:
> Hi Folks,
> 
> I have just successfully lobbied for the company I work for to use 
> PHP/MySQL for our next website.  My Question is regarding DB abstraction 
> .  I know there is a Pear DB module, is this the best to use ?  I have a 
> vague memory of reading somewhere that there is a newer lib or something 
> which is considered better ?
> 

Hi John

You might consider CodeIgniter - it's a very nice, simple to use
framework with a pretty good DB abstraction layer built in.
http://codeigniter.com/

J



--- End Message ---
--- Begin Message ---
PEAR::DB was deprecated years ago.  Do not use it.  

PEAR::MDB2 is the preferred PEAR wrapper these days.  

Personally, I skip them both and prefer to go straight to PDO, available in 
PHP 5.  

http://www.php.net/pdo

On Thursday 10 July 2008 1:47:34 am John Comerford wrote:
> Hi Folks,
>
> I have just successfully lobbied for the company I work for to use
> PHP/MySQL for our next website.  My Question is regarding DB abstraction
> .  I know there is a Pear DB module, is this the best to use ?  I have a
> vague memory of reading somewhere that there is a newer lib or something
> which is considered better ?
>
> TIA,
>   JC

-- 
Larry Garfield
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
> Hi Folks,
>
> I have just successfully lobbied for the company I work for to use 
> PHP/MySQL for our next website.  My Question is regarding DB abstraction 
> .  I know there is a Pear DB module, is this the best to use ?  I have a 
> vague memory of reading somewhere that there is a newer lib or something 
> which is considered better ?
>
> TIA,
>   JC

The newest version of Pear DB is Pear MDB2. I have to say I'm not a great
fan of the pear system, but MDB2 is probably one of the best.

Alex

No virus found in this outgoing message. Scanned by AVG Free 8.0
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.4.7/1542 - Release Date: 09/07/2008
06:50


--- End Message ---
--- Begin Message ---
John Comerford wrote:
Hi Folks,

I have just successfully lobbied for the company I work for to use PHP/MySQL for our next website. My Question is regarding DB abstraction . I know there is a Pear DB module, is this the best to use ? I have a vague memory of reading somewhere that there is a newer lib or something which is considered better ?

As others have said - MDB2 or PDO are the Pear:DB replacements, but if you would like a proper abstraction of SQL then ADOdb is still the best choice and it can handle PDO or raw mysql drivers internally. But more important it gives you the safety net to be able to switch to an alternative to MySQL ;)

http://adodb.sourceforge.net/

You will also find a lot of useful projects that are built on it which may provide the bulk of your site code. No need to build a site from scratch - just select a suitable framework :)

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
i am planning to create a web photo gallery. i know there is a lot
available out there,
but i really want to create my own. the problem is not about creating
the photo gallery.
i want it to be scalable.

the plan is saving the image metadata in the database and keep the
original files
in a folder. while it work perfectly, i afraid how many files 1
directory can keep.
in 1 year, there going to be more than 1000 photo uploaded or more.
sure it bring problem
to maintain thus files.

when i see big2 website out there like friendster, photobucket. the
url for the image change
like
pic-1.domain.com/images/filename.jpg
pic-2.domain.com/images/filename.jpg
etc. they seems to put the image in different subdomain. Just wan't to
ask anyone who
did create a big-big web gallery like this. How did you do it?

thanks

--- End Message ---
--- Begin Message ---
>> in 1 year, there going to be more than 1000 photo uploaded or more.
That isn’t really much.

A directory can held much more than a few thousand files.

They use more than one Server because 1 Server can't handle the load. The
don’t do that because of limited File system.

But the file system may get slower if you have thousands of files in one
dir. So maybe make dirs like c/a/cartoon.jpg to get not too much files in
one dir.

If you need several Servers for this depends on how many visitors you have.

-----Ursprüngliche Nachricht-----
Von: paragasu [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 10. Juli 2008 09:47
An: [EMAIL PROTECTED]
Betreff: [PHP] scalable web gallery

i am planning to create a web photo gallery. i know there is a lot
available out there,
but i really want to create my own. the problem is not about creating
the photo gallery.
i want it to be scalable.

the plan is saving the image metadata in the database and keep the
original files
in a folder. while it work perfectly, i afraid how many files 1
directory can keep.
in 1 year, there going to be more than 1000 photo uploaded or more.
sure it bring problem
to maintain thus files.

when i see big2 website out there like friendster, photobucket. the
url for the image change
like
pic-1.domain.com/images/filename.jpg
pic-2.domain.com/images/filename.jpg
etc. they seems to put the image in different subdomain. Just wan't to
ask anyone who
did create a big-big web gallery like this. How did you do it?

thanks

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


--- End Message ---
--- Begin Message ---
On 7/10/08, paragasu <[EMAIL PROTECTED]> wrote:
> i am planning to create a web photo gallery. i know there is a lot
> available out there,
> but i really want to create my own. the problem is not about creating
> the photo gallery.
> i want it to be scalable.
>
> the plan is saving the image metadata in the database and keep the
> original files
> in a folder. while it work perfectly, i afraid how many files 1
> directory can keep.
> in 1 year, there going to be more than 1000 photo uploaded or more.
> sure it bring problem
> to maintain thus files.

if this becomes a huge project i'd recommend looking into using mogilefs.

--- End Message ---
--- Begin Message ---

O/H paragasu ??????:
i am planning to create a web photo gallery. i know there is a lot
available out there,
but i really want to create my own. the problem is not about creating
the photo gallery.
i want it to be scalable.

the plan is saving the image metadata in the database and keep the
original files
in a folder. while it work perfectly, i afraid how many files 1
directory can keep.
in 1 year, there going to be more than 1000 photo uploaded or more.
sure it bring problem
to maintain thus files.

when i see big2 website out there like friendster, photobucket. the
url for the image change
like
pic-1.domain.com/images/filename.jpg
pic-2.domain.com/images/filename.jpg
etc. they seems to put the image in different subdomain. Just wan't to
ask anyone who
did create a big-big web gallery like this. How did you do it?

thanks

I never did create a big image gallery but I have worked with uploaded files quite many times. There are many solutions to this so it depends on what you have and what you are willing to do.

A first solution that I can think of is to separate your images in categories. Add a field in the database table that describes the image category and make a directory with the same name. When you query the database you will get the filename of the image (or something like that) and you will get the image from this specific directory. If you so many images that this does not solve this you may add an extra field in the database and add subcategories and move the files into a subdir (subcategory) inside the previously mentioned dir (category).

Another solution that is better if you are not willing to categorize the images is to divide them by date. You may include a date or date-time field in the database that describes the creation date of the image (or the upload date if you like) and divide the images into directories per month or per year or even both. Like making a directory 2008 and add inside sub-directories like 01,02,03... or Jan,Feb,Mar etc. Now when you query the database you may find from the creation date the directory that sores the image and everything is in order. For e.g.

If the date you got from the database is 2008-01-23 and the image name is image01.jpg then the path would be:

<?php

$date = '2008-01-23';
$fname = 'image01.jpg';
list($year,$month,$day) = split('-',$date);
$file_dir = '/data/images';
$path = $file_dir."/".$year."/".$month."/".$fname;

print $path;
?>

--
Thodoris


--- End Message ---
--- Begin Message ---
paragasu wrote:

> i am planning to create a web photo gallery. i know there is a lot
> available out there, but i really want to create my own. the problem
> is not about creating  the photo gallery.
> i want it to be scalable.

The first question is - how scalable?  How many photos and how many
users?

> the plan is saving the image metadata in the database and keep the
> original files in a folder. while it work perfectly, i afraid how many
> files 1 directory can keep.

Easily more than 100K.  Depending on your filesystem, directory access
might slow down the bigger it gets.  

> in 1 year, there going to be more than 1000 photo uploaded or more.
> sure it bring problem to maintain thus files.

No, 1000 photos in a single directory will not be a problem at all.


/Per Jessen, Zürich


--- End Message ---
--- Begin Message ---
<snip>
Another solution that is better if you are not willing to categorize
the images is to divide them by date. You may include a date or
date-time field in the database that describes the creation date of
the image (or the upload date if you like) and divide the images into
directories per month or per year or even both. Like making a
directory 2008 and add inside sub-directories like 01,02,03... or
Jan,Feb,Mar etc. Now when you query the database you may find from the
creation date the directory that sores the image and everything is in
order. For e.g.

If the date you got from the database is 2008-01-23 and the image name
is image01.jpg then the path would be:

<?php

$date = '2008-01-23';
$fname = 'image01.jpg';
list($year,$month,$day) = split('-',$date);
$file_dir = '/data/images';
$path = $file_dir."/".$year."/".$month."/".$fname;

print $path;
?>
</snip>
wow!.. this is a good idea. i really never think of this idea. i think
i want to divide the image
in a folder separated by year. thanks...

i am also wondering if there is another approach on organizing the photos.
what i heard from friends, image gallery like flickr using tag to
organize the photos.
anyone have comment on tag vs album?

On 7/10/08, Per Jessen <[EMAIL PROTECTED]> wrote:
> paragasu wrote:
>
>> i am planning to create a web photo gallery. i know there is a lot
>> available out there, but i really want to create my own. the problem
>> is not about creating  the photo gallery.
>> i want it to be scalable.
>
> The first question is - how scalable?  How many photos and how many
> users?
>
>> the plan is saving the image metadata in the database and keep the
>> original files in a folder. while it work perfectly, i afraid how many
>> files 1 directory can keep.
>
> Easily more than 100K.  Depending on your filesystem, directory access
> might slow down the bigger it gets.
>
>> in 1 year, there going to be more than 1000 photo uploaded or more.
>> sure it bring problem to maintain thus files.
>
> No, 1000 photos in a single directory will not be a problem at all.
>
>
> /Per Jessen, Zürich
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Thu, Jul 10, 2008 at 3:46 AM, paragasu <[EMAIL PROTECTED]> wrote:
>
> the plan is saving the image metadata in the database and keep the
> original files
> in a folder. while it work perfectly, i afraid how many files 1
> directory can keep.
> in 1 year, there going to be more than 1000 photo uploaded or more.
> sure it bring problem
> to maintain thus files.

    I wrote a gallery script in about two hours last year, and in the
first week alone, over 7,000 images were uploaded by fans of the band
for whom I wrote it.  It had full administrative control, voting, and
user authentication requirements, in addition to some other stuff, all
written from scratch in that time.

    So an existing system that's been around for a while would
*certainly* be able to handle a mere 1,000 in a year.  No worries
about that.

    And for the record, in the "olden days," there was a limit of
about 2048 files per directory, back when no one thought there would
ever be a need for nearly that many files.  Then, with improved
filesystems, the limit was rumored to be another magic number: 65535.
That depended on the operating system, filesystem, and the kernel.  I
think (but don't quote me on this) that BeOS had the 65535 limit.

    Now, on an ext3 filesystem (we're not counting ReiserFS because
(1) I was never a fan, and (2) he might kill me if I say something
bad!  8^O) you're okay with hundreds of thousands of files per
directory.  ls'ing will be a bit of a pain in the ass, and if you're
in Bash, you probably don't want to double-TAB the directory, but all
in all, you'll be okay.

    Still, I'd create 16 subdirectories under the images directory:
0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f.  Then name the file as an MD5 hash of
the image uploaded, and place it in the directory matching the first
character of the new file name.

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---
--- Begin Message ---
tedd wrote:
Hi gang:

I'm running a Mac (so I know mine is a bit different size wise) but I'm currently using Veranda at 14 point for coding.

Just out of curiosity, what font and size do you ppls use for your programming?

Cheers,

tedd


I'd love to be coding on the Veranda, but it's raining horizontally at the moment and my keyboard hates being wet.

I'm using Lucida Sans for code these days - I finally figured that it didn't really have to be a fixed-width font, since I couldn't find one that wasn't ugly.

--
Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

--- End Message ---
--- Begin Message ---
tedd wrote:
Just out of curiosity, what font and size do you ppls use for your programming?

I've got a lot of projects so I always use a really small font to save on disk space....


Col


--- End Message ---
--- Begin Message ---
Here's how I roll. :)  Consolas is the font.

http://refraxion.com/pdt-eclipse.png

--- End Message ---
--- Begin Message ---
On Thu, Jul 10, 2008 at 9:46 AM, Eric Butera <[EMAIL PROTECTED]> wrote:
> Here's how I roll. :)  Consolas is the font.
>
> http://refraxion.com/pdt-eclipse.png

    Reminds me of Comic Sans Bold.  ;-P

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---
--- Begin Message ---
On Thu, Jul 10, 2008 at 5:07 AM, Peter Ford <[EMAIL PROTECTED]> wrote:
>>
>> I'm running a Mac (so I know mine is a bit different size wise) but I'm
>> currently using Veranda at 14 point for coding.
>
> I'd love to be coding on the Veranda, but it's raining horizontally at the
> moment and my keyboard hates being wet.

    Ha!  Nice catch with the spelling, Pete.  That actually almost
made me spit coffee on my many thousands of monitors (they're
multiplying like rabbits now).

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---
--- Begin Message ---
On Thu, Jul 10, 2008 at 6:12 AM, Colin Guthrie <[EMAIL PROTECTED]> wrote:
> tedd wrote:
>>
>> Just out of curiosity, what font and size do you ppls use for your
>> programming?
>
> I've got a lot of projects so I always use a really small font to save on
> disk space....

    That doesn't work, dummy!  You still have to save only half of
your files.  ;-P

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

--- End Message ---
--- Begin Message ---
On Jul 10, 2008, at 4:07 AM, Peter Ford wrote:

tedd wrote:
Hi gang:
I'm running a Mac (so I know mine is a bit different size wise) but I'm currently using Veranda at 14 point for coding. Just out of curiosity, what font and size do you ppls use for your programming?
Cheers,
tedd

I'd love to be coding on the Veranda, but it's raining horizontally at the moment and my keyboard hates being wet.

I'm using Lucida Sans for code these days - I finally figured that it didn't really have to be a fixed-width font, since I couldn't find one that wasn't ugly.

Are you sure you're a *coder*? =D I've looked at some code in a non fixed-width font before and it hurt my eyes! I bet you use tabs instead of spaces too. ;)

~Phil


--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
On Thu, Jul 10, 2008 at 6:12 AM, Colin Guthrie <[EMAIL PROTECTED]> wrote:
tedd wrote:
Just out of curiosity, what font and size do you ppls use for your
programming?
I've got a lot of projects so I always use a really small font to save on
disk space....

    That doesn't work, dummy!  You still have to save only half of
your files.  ;-P

Yeah you're right... well most of my lines are short so I'll try only saving the left hand side of each file and see if that helps save space :p

Col


--- End Message ---
--- Begin Message ---

On Jul 10, 2008, at 10:44 AM, Colin Guthrie wrote:

Daniel Brown wrote:
On Thu, Jul 10, 2008 at 6:12 AM, Colin Guthrie <[EMAIL PROTECTED]> wrote:
tedd wrote:
Just out of curiosity, what font and size do you ppls use for your
programming?
I've got a lot of projects so I always use a really small font to save on
disk space....
   That doesn't work, dummy!  You still have to save only half of
your files.  ;-P

Yeah you're right... well most of my lines are short so I'll try only saving the left hand side of each file and see if that helps save space :p


No wonder my files are so large... I have been saving them at 20 point type... Easier to read from aways away :P


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





--- End Message ---
--- Begin Message ---
Hello.

But I need no td and tr inside regular expression
It is a part of my templater.


In real code it looks like:
  if(strlen($item[$key])<1){
return preg_replace('#\{%%%.*?\{%'.$key.'%\}.*?%%%\}#is','',$tpl);
            }

if one of $key inside {%%% .... %%%} points to empty array item - all section between {%%% %%%} must be deleted.



Daniel Brown :
On Wed, Jul 9, 2008 at 5:21 AM, Maxim Antonov <[EMAIL PROTECTED]> wrote:
Hi, all!

I try to use folowing regular expression:
$out =
preg_replace('#\{%%%.*?\{%bigfoto%\}.*?%%%\}#is','==REPLACEMENT==',$str);

[snip!]
I need result as:

<tr><td>NAME:</td><td><input type="text" name="name" value=""
size="80"/></td></tr>
 <tr><td>Foto:</td><td><input type="file" name="foto" value="{%foto%}" />
 {%%%<br/><img alt="{%name%}" src="{%foto%}"/>%%%}
 </td></tr>
==REPLACEMENT==
[snip!]

    To get it *exactly* as you've mentioned here, use this instead:

<?php
$out = 
preg_replace('/<tr><td>Big.*\{%%%.*\{%bigfoto%\}.*%%%\}.*<\/tr>/Uis','==REPLACEMENT==',$str);
?>


--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Maxim Antonov [mailto:[EMAIL PROTECTED]
> Sent: Thursday, July 10, 2008 4:24 AM
> To: [EMAIL PROTECTED]; Daniel Brown
> Subject: Re: [PHP] Need help with regular expression
> 
> Hello.
> 
> But I need no td and tr inside regular expression
> It is a part of my templater.
> 
> 
> In real code it looks like:
>    if(strlen($item[$key])<1){
>                  return
> preg_replace('#\{%%%.*?\{%'.$key.'%\}.*?%%%\}#is','',$tpl);
>              }
> 
> if one of $key inside  {%%% .... %%%} points to empty array item - all
> section between {%%% %%%} must be deleted.

---8<--- snip

Maxim,

You could try using a "capture group," and re-assemble the match with
the match group inbetween your {%%% %%%} omitted. Just an idea.


Todd Boyd
Web Programmer




--- End Message ---
--- Begin Message ---
Your description of the problem is confusing.

Do you simply want to delete a table row if it contains a variable, e.g., $var='bigfoto' and append "==REPLACEMENT==" ? Where $var can be anything you assign.


Maxim Antonov wrote:
Hello.

But I need no td and tr inside regular expression
It is a part of my templater.


In real code it looks like:
  if(strlen($item[$key])<1){
return preg_replace('#\{%%%.*?\{%'.$key.'%\}.*?%%%\}#is','',$tpl);
            }

if one of $key inside {%%% .... %%%} points to empty array item - all section between {%%% %%%} must be deleted.



Daniel Brown :
On Wed, Jul 9, 2008 at 5:21 AM, Maxim Antonov <[EMAIL PROTECTED]> wrote:
Hi, all!

I try to use folowing regular expression:
$out =
preg_replace('#\{%%%.*?\{%bigfoto%\}.*?%%%\}#is','==REPLACEMENT==',$str);

[snip!]
I need result as:

<tr><td>NAME:</td><td><input type="text" name="name" value=""
size="80"/></td></tr>
<tr><td>Foto:</td><td><input type="file" name="foto" value="{%foto%}" />
 {%%%<br/><img alt="{%name%}" src="{%foto%}"/>%%%}
 </td></tr>
==REPLACEMENT==
[snip!]

    To get it *exactly* as you've mentioned here, use this instead:

<?php
$out = preg_replace('/<tr><td>Big.*\{%%%.*\{%bigfoto%\}.*%%%\}.*<\/tr>/Uis','==REPLACEMENT==',$str);
?>


--- End Message ---
--- Begin Message ---
On Wed, Jul 9, 2008 at 5:21 AM, Maxim Antonov <[EMAIL PROTECTED]> wrote:
> Hi, all!
>
> I try to use folowing regular expression:
> $out =
> preg_replace('#\{%%%.*?\{%bigfoto%\}.*?%%%\}#is','==REPLACEMENT==',$str);
>
> It not work as I need. Please tell me - what I do wrong?
>
> I have string:
>
>
>   <tr><td>NAME:</td><td><input type="text" name="name" value=""
> size="80"/></td></tr>
>  <tr><td>Foto:</td><td><input type="file" name="foto" value="{%foto%}" />
>  {%%%<br/><img alt="{%name%}" src="{%foto%}"/>%%%}
>  </td></tr>
>  <tr><td>Big foto:</td><td><input type="file" name="bigfoto" value="" />
>  {%%%<br/><img alt="{%name%}" src="{%bigfoto%}"/>%%%}
>  </td></tr>
>
>
>
> I need result as:
>
>
> <tr><td>NAME:</td><td><input type="text" name="name" value=""
> size="80"/></td></tr>
>  <tr><td>Foto:</td><td><input type="file" name="foto" value="{%foto%}" />
>  {%%%<br/><img alt="{%name%}" src="{%foto%}"/>%%%}
>  </td></tr>
> ==REPLACEMENT==
>
>
> And I have this result:
>
>   <tr><td>NAME:</td><td><input type="text" name="name" value=""
> size="80"/></td></tr>
>  <tr><td>Foto:</td><td><input type="file" name="foto" value="{%foto%}" />
> ==REPLACEMENT==
>  </td></tr>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I'm sure it won't be this easy because of who knows what (like
inheriting code, etc), but why not just use something easier like:


$replace = array(
    '{%key1%}' => 'value1',
    '{%key2%}' => 'value2'
);

$html = str_replace(
    array_keys($replace),
    array_values($replace),
    file_get_contents('tpl.html')
);


Or the easiest is to just use raw php code seeing as php is a
templating language. :)

--- End Message ---
--- Begin Message --- Hi, I'm having trouble with a framework I'm developing, apparently when a non-catchable error occurs (E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING types) not only I can't fire up my error handling function, I can't even display the static html page I set with the ErrorDocument apache directive. What's weird is that it doesn't look like an apache problem, with perl it works perfectly.

This guy had the same problem as me, check his post (point 3 mostly): http://www.entropy.ch/blog/Developer/2007/05/10/Apache-ErrorDocument-PHP-header-interaction.html

Thanks in advance

Daniele Grillenzoni
--- End Message ---
--- Begin Message ---
Hi List,
Has anyone on this list had any application experience of polling Modbus
devices with PHP?
Thanks

--- End Message ---
--- Begin Message ---
I would like to use this time phpmyadmin (2.11.3) to setup for a new
user a database, which he can use to setup his own tables for his web site.

User abc should get his own database xyz.

I am not sure if I did it correct, and if it is safe to do so:

A
==
1. I created an empty database xyz (main page of phpmyadmin)
2. I added a new user on the Privileges page with:
User: abc
Host: Any (%)
Password: (yes)
Global privileges: 
    (Data:) SELECT, INSERT, UPDATE, DELETE, FILE
    (Structure:) CREATE, ALTER, INDEX, DROP, CREATE TEMPORARY TABLES
    (Administration:)    (nothing ticked)
    (Resource limits:)   (nothing ticked)

What does it mean so far? Can the user abc already access data of any
database?

B
==
I found "Database-specific privileges" for the user abc, where I added
the database xyz and ticked:
    (Data:) SELECT, INSERT, UPDATE, DELETE
    (Structure:) CREATE, ALTER, INDEX, DROP, CREATE TEMPORARY TABLES
    (Administration:)    (nothing ticked)

What confuses me is that I have already some databases setup for my own
web, but none of the users has "B" attached.
Currently I am going away from a single person using the database to
allow others also to use the database.

Thanks for enlightening me.

bye

Ronald







--- End Message ---
--- Begin Message ---
---- Ronald Wiplinger <[EMAIL PROTECTED]> wrote: 
> I would like to use this time phpmyadmin (2.11.3) to setup for a new
> user a database, which he can use to setup his own tables for his web site.
> 
> User abc should get his own database xyz.

Yup, you can do this.  Depending on how you are setting this up, you could 
theoretically put a separate phpmyadmin folder in each of the web folders of 
the users who use your services.

Have you RTFM and set it up as the documentation stated and then tested it by 
logging in as the new user?

http://www.phpmyadmin.net/home_page/docs.php

Wolf

--- End Message ---
--- Begin Message ---
This is more of a SQL question that PHP.  If you want to grant all
privileges to abc to database xyz (minus GRANT), you should run these
queries:

CREATE DATABASE xyz;
GRANT ALL PRIVILEGES ON xyz.* TO 'abc'@'somehost' IDENTIFIED BY
'somepassword';



-----Original Message-----
From: Ronald Wiplinger [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 10, 2008 9:22 AM
To: [EMAIL PROTECTED]
Subject: [PHP] phpmyadmin

I would like to use this time phpmyadmin (2.11.3) to setup for a new
user a database, which he can use to setup his own tables for his web site.

User abc should get his own database xyz.

I am not sure if I did it correct, and if it is safe to do so:

A
==
1. I created an empty database xyz (main page of phpmyadmin)
2. I added a new user on the Privileges page with:
User: abc
Host: Any (%)
Password: (yes)
Global privileges: 
    (Data:) SELECT, INSERT, UPDATE, DELETE, FILE
    (Structure:) CREATE, ALTER, INDEX, DROP, CREATE TEMPORARY TABLES
    (Administration:)    (nothing ticked)
    (Resource limits:)   (nothing ticked)

What does it mean so far? Can the user abc already access data of any
database?

B
==
I found "Database-specific privileges" for the user abc, where I added
the database xyz and ticked:
    (Data:) SELECT, INSERT, UPDATE, DELETE
    (Structure:) CREATE, ALTER, INDEX, DROP, CREATE TEMPORARY TABLES
    (Administration:)    (nothing ticked)

What confuses me is that I have already some databases setup for my own
web, but none of the users has "B" attached.
Currently I am going away from a single person using the database to
allow others also to use the database.

Thanks for enlightening me.

bye

Ronald







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


--- End Message ---

Reply via email to