php-general Digest 12 Nov 2003 07:07:05 -0000 Issue 2410

Topics (messages 169197 through 169233):

Re: help create community newbie guide to security
        169197 by: Lowell Allen

How to adpated a javascrip with php...
        169198 by: Payne
        169205 by: Martin Towell
        169207 by: Burhan Khalid

Re: configure hangs on pwrite
        169199 by: John Nichel

Re: \n and <br>
        169200 by: Marek Kilimajer
        169202 by: Brian V Bonini

Philadelphia PHP Users Group
        169201 by: Edward Dudlik

Re: location=  Construct Doc
        169203 by: Mark
        169208 by: Eugene Lee

whois api's
        169204 by: Rolf Brusletto
        169209 by: Vail, Warren
        169218 by: Al

Miami User Group
        169206 by: Cesar Cordovez
        169223 by: David T-G

Unique ID
        169210 by: Dimitri Marshall
        169211 by: Marek Kilimajer
        169212 by: Javier Muniz
        169214 by: Boyan Nedkov
        169215 by: John W. Holmes

Time problem
        169213 by: Erin
        169216 by: Chris Shiflett
        169217 by: Vail, Warren
        169221 by: John W. Holmes

sorting files by date
        169219 by: Justin French
        169220 by: Martin Towell
        169222 by: David T-G

I meant 'PHP Atlanta user group'...
        169224 by: David T-G

Execute Background Process
        169225 by: apur kurub ver.1

nusoap
        169226 by: Larry Brown

Pear
        169227 by: Gary

Help with scripts to add records to a database
        169228 by: Mark
        169230 by: Mark
        169231 by: Rolf Brusletto
        169232 by: zhuravlev alexander

Can sudo be used for apache
        169229 by: tirumal b

Re: problem with mssql_query
        169233 by: Jason Wong

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 ---
> Lawrence Kennon wrote:
>> For a BBS I would like to let users post links to
>> various resources. They 'post' a message to the BBS
>> via a form and that is stored in a MySQL db, then the
>> content of their 'post' is available to other users on
>> the BBS. Currently I strip out all PHP/HTML with the
>> strip_tags() function. What I would really like to do
>> is allow a limited set of HTML tags (like the anchor
>> <a> tag) but at the same time implement reasonable protection.
> 
> Get yourself a bbcode parser from phpclasses.org so you can use things
> like [b] [/b], and [url=] [/url], etc. This is safer than trying to deal
> with actual HTML, imo. Then use htmlentities() on the data instead of
> strip_tags(), so the users can actually write something like <grin> and
> not have it stripped.

[snip]

I have a "best practice" question related to this thread. I usually store
data in MySQL without any translation, then use htmlspecialchars() before
displaying as HTML. This works well for a content management system where
administrators are entering data in forms and storing, but perhaps it's not
appropriate for storing information from website visitors. If that
information should be translated before storing, then I'd have some stuff
that needs htmlspecialchars() applied before displaying, and some stuff that
does not.

My question is, are there any disadvantages to always following the
procedure described below?

- Use htmlentities() on everything before storing in the database
- Retrieve and display in cms forms without any translation
- Retrieve and translate mnemonic codes (like [b] [eb] to <strong>
</strong>) before displaying as HTML
- Retrieve and use html_entity_decode() if needed for non-HTML use (like for
plain text email), or if I actually *WANT* to use stored HTML code (like for
HTML-formatted email)

TIA

--
Lowell Allen

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

I have a Javascript that I like to use with PHP/MYSQL, But I don't know how to mix the two...



<SCRIPT LANGUAGE = "JavaScript">
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);

if ((bName == "Netscape" && bVer >= 3) ||

(bName == "Microsoft Internet Explorer" && bVer >= 4)) br = "n3";

else br = "n2";

if (br == "n3") {

   boardNum = 0;
   boardSpeed = 4000;

   billboards = new Array();
   billboards[0] = new Image();
   billboards[0].src = "$x";
   billboards[1] = new Image();
   billboards[1].src = "$x";
   billboards[2] = new Image();
   billboards[2].src = "$x";
   billboards[3] = new Image();
   billboards[3].src = "$x";
   billboards[4] = new Image();
   billboards[4].src = "$x";
   billboards[5] = new Image();
   billboards[5].src = "$x";
   billboards[6] = new Image();
   billboards[6].src = "$x";
   billboards[7] = new Image();
   billboards[7].src = "$x";
   }

[I like to make $x to be called from the database...]


function rotateBoard() {

document.billboard.src = billboards[boardNum].src;

if (boardNum < billboards.length - 1) {

boardNum++;

} else {

boardNum = 0;

}

}

function jumpBillboard() {

window.location.href = url[boardNum];
}
</SCRIPT>

Thanks for any help you can give...

Payne
--- End Message ---
--- Begin Message ---
> I have a Javascript that I like to use with PHP/MYSQL, But I 
> don't know 
> how to mix the two...
> 
> <SCRIPT LANGUAGE = "JavaScript">
> bName = navigator.appName;
> bVer = parseInt(navigator.appVersion);
> 
>     if ((bName == "Netscape" && bVer >= 3) ||
> 
>         (bName == "Microsoft Internet Explorer" && bVer >= 
> 4)) br = "n3";
> 
>     else br = "n2";
> 
>     if (br == "n3") {
> 
>     boardNum = 0;
>     boardSpeed = 4000;
> 
>     billboards = new Array();
>     billboards[0] = new Image();
>     billboards[0].src = "$x";
>     billboards[1] = new Image();
>     billboards[1].src = "$x";
>     billboards[2] = new Image();
>     billboards[2].src = "$x";
>     billboards[3] = new Image();
>     billboards[3].src = "$x";
>     billboards[4] = new Image();
>     billboards[4].src = "$x";
>     billboards[5] = new Image();
>     billboards[5].src = "$x";
>     billboards[6] = new Image();
>     billboards[6].src = "$x";
>     billboards[7] = new Image();
>     billboards[7].src = "$x";
>     }
> 
> [I like to make $x to be called from the database...]
> 
> 
> function rotateBoard() {
> 
>   document.billboard.src = billboards[boardNum].src;
> 
>   if (boardNum < billboards.length - 1) {
> 
>     boardNum++;
> 
>   } else {
> 
>     boardNum = 0;
> 
>   }
> 
> }
> 
> function jumpBillboard() {
> 
> window.location.href = url[boardNum];
> }
> </SCRIPT>


Try something like this

     billboards = new Array();
<?
  $cursor = <<sql query here>>
  $i = 0;
  while ($something from database)
  {
?>
     billboards[<?=$i?>] = new Image();
     billboards[<?=$i?>].src = "<?=$something?>";
<?
    $i++;
  }
?>

Martin

--- End Message ---
--- Begin Message --- Payne wrote:

Hi,

I have a Javascript that I like to use with PHP/MYSQL, But I don't know how to mix the two...

Here is an example.

<?php

   /* do php stuff here, like set a value to $x */
   $x = 3;
?>

<script>
  funtion x() { var foo = <?php echo $x; ?>; alert(foo); }
</script>

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
-----------------------
"Documentation is like sex: when it is good,
 it is very, very good; and when it is bad,
 it is better than nothing."

--- End Message ---
--- Begin Message --- John Nichel wrote:

Hi,

Trying to get php 4.3.4 to configure on a Fedora 1 box, and the configure script keeps hanging on "checking whether pwrite works..."

I've tried it with and without mm support for sessions, but to no avail (it's checking for pwrite right after is does the session check). Can anyone lend a few brain cells?


The section of 'configure' that I believe this is coming from is....

  echo $ac_n "checking whether pwrite works""... $ac_c" 1>&6
echo "configure:73730: checking whether pwrite works" >&5
if eval "test \"`echo '$''{'ac_cv_pwrite'+set}'`\" = set"; then
  echo $ac_n "(cached) $ac_c" 1>&6
else

But most of that is greek to me. Does anyone understand what that's doing? What it might be looking for, and what might be causing it to hang? Thanks.

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

--- End Message ---
--- Begin Message --- Brian V Bonini wrote:
So just change it....

$string = nl2br($content->page_content);
$string = eregi_replace("<br />", "<br>", $string);


Why not directly str_replace(array("\r\n","\r","\n"), '<br>', $content->page_content);

--- End Message ---
--- Begin Message ---
On Tue, 2003-11-11 at 14:51, Marek Kilimajer wrote:
> Brian V Bonini wrote:
> > So just change it....
> > 
> > $string = nl2br($content->page_content);
> > $string = eregi_replace("<br />", "<br>", $string);
> > 
> 
> Why not directly
> str_replace(array("\r\n","\r","\n"), '<br>', $content->page_content);

You say tomato I say.... ;-)

--- End Message ---
--- Begin Message ---
>From all that I've gathered, the greater Philadelphia, PA, area is
woefully lacking in a PHP Users Group.  Last I checked, we were still one
of the ten largest cities in the country, so to quote Chris Rock, "That
ain't right!"

I have already done some legwork, but before I dive too deeply into this,
I should probably find out if anyone is interested.  If you are and/or
know someone who may be, please contact me off-list.

Thanks a lot.

Edward Dudlik
"Those who say it cannot be done
should not interrupt the person doing it."

wishy washy | www.amazon.com/o/registry/EGDXEBBWTYUU

--- End Message ---
--- Begin Message ---
--- Lee Stewart <[EMAIL PROTECTED]> wrote:
> It's version 4.0.3
> Lee

In v4.3.2, it throws a "Parse error: parse error, unexpected '=' in
/path/to/file/test.php on line 23".

> 
> Chris Shiflett wrote:
> > --- Lee Stewart <[EMAIL PROTECTED]> wrote:
> > 
> >>Here's a *working* section of code...  Note the
> >>    location = "browse.php";
> >>on line 23....
> > 
> > 
> > How does that not generate a parse error? I must be missing
> something.
> > 
> > It seems to me that either a dollar sign is missing, or the line
> is
> > intended to define a constant (although I prefer my constants to
> be
> > uppercase), in which case the wrong syntax is being used.
> > 
> > What version of PHP are you using that does not generate a parse
> error?
> > 
> > Chris
> > 
> > =====
> > My Blog
> >      http://shiflett.org/
> > HTTP Developer's Handbook
> >      http://httphandbook.org/
> > RAMP Training Courses
> >      http://www.nyphp.org/ramp
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


=====
Mark Weinstock
[EMAIL PROTECTED]
***************************************
You can't demand something as a "right" unless you are willing to fight to death to 
defend everyone else's right to the same thing.
***************************************

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

--- End Message ---
--- Begin Message ---
On Tue, Nov 11, 2003 at 01:46:33PM -0800, Mark wrote:
: > 
: > > --- Lee Stewart <[EMAIL PROTECTED]> wrote:
: > > 
: > >>Here's a *working* section of code...  Note the
: > >>  location = "browse.php";
: > >>on line 23....
: 
: In v4.3.2, it throws a "Parse error: parse error, unexpected '=' in
: /path/to/file/test.php on line 23".

It'd be helpful to see the rest of the code snippet.  But it kinda looks
as if it should be:

        $location = "browse.php";

--- End Message ---
--- Begin Message --- Hey all -

I'm currently working on a project which requires domain name information. Has anybody used, or can anybody suggest php tools to get whois information regarding any domain name? I'm trying to check out all options before having to register as a registrar for get access to a paid api.

Rolf Brusletto


--- End Message ---
--- Begin Message ---
I believe network solutions and all other sources of this kind of
information have been tightening access to more than the IP address,
because, it seems, some unscrupulous individuals have been using the
information to spam domain owners.  Since it appears that you are not a
domain registrar, or you would already have access, I can't help but wonder
how you plan to use this information that wouldn't meet with a lot of
flak????

somewhat curious,

Warren Vail

-----Original Message-----
From: Rolf Brusletto [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 11, 2003 2:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP] whois api's


Hey all -

I'm currently working on a project which requires domain name 
information. Has anybody used, or can anybody suggest php tools to get 
whois information regarding any domain name? I'm trying to check out all 
options before having to register as a registrar for get access to a 
paid api.

Rolf Brusletto


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

--- End Message ---
--- Begin Message ---
There is a PEAR Project that does exactly what you want:

http://pear.php.net/package/Net_Whois

Al

"Rolf Brusletto" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hey all -
>
> I'm currently working on a project which requires domain name
> information. Has anybody used, or can anybody suggest php tools to get
> whois information regarding any domain name? I'm trying to check out all
> options before having to register as a registrar for get access to a
> paid api.
>
> Rolf Brusletto
>

--- End Message ---
--- Begin Message --- And talking about user groups, is anybody interested in creating a Miami/Fort Lauderdale/Palm Beaches PHP user group?

Contact me, off the list please.

Cesar
--- End Message ---
--- Begin Message ---
Hi, all --

[Yes, this is intended to be a new thread.]

...and then Cesar Cordovez said...
% 
% And talking about user groups, is anybody interested in creating a 
% Miami/Fort  Lauderdale/Palm Beaches PHP user group?

Or US-GA-Atlanta :-)


% 
% Contact me, off the list please.

Same here.


Thanks & HAND

:-D
-- 
David T-G                      * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00000.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
Hi there,
Here's my situation:

I'm making a message board and I've decided the best way to go about the
structure is to have 3 tables, two of them will be "Posts" and "Replys".
Now, in order for this ti work, each post has to have a UniqueID - same with
the replys. Looking at another program, I can see that one way to do this is
to do it by rows (ie. count how many rows, add 1, then that is the ID). It
would be unique because no two rows would be 1 for example.

The problem I can see is that the database would become incredibly huge
(size wise I mean). I want to delete the posts after 30 days, and if I
delete the row, then that would mess up the row system.

Any suggestions?

Dimitri Marshall

--- End Message ---
--- Begin Message --- Dimitri Marshall wrote:
Hi there,
Here's my situation:

I'm making a message board and I've decided the best way to go about the
structure is to have 3 tables, two of them will be "Posts" and "Replys".
Now, in order for this ti work, each post has to have a UniqueID - same with
the replys. Looking at another program, I can see that one way to do this is
to do it by rows (ie. count how many rows, add 1, then that is the ID). It
would be unique because no two rows would be 1 for example.

The problem I can see is that the database would become incredibly huge
(size wise I mean). I want to delete the posts after 30 days, and if I
delete the row, then that would mess up the row system.

Any suggestions?

Have you heard about auto_increment? Read on: http://www.mysql.com/doc/en/example-AUTO_INCREMENT.html

--- End Message ---
--- Begin Message ---
auto_increment is not in the SQL standard, and not everyone uses MySQL.  To
be cross-compatible between databases use a Sequence:
http://pear.php.net/manual/en/package.database.db.intro-sequences.php
provides a brief introduction, the PEAR::DB class allows you to use
sequences easily.

Neither auto-increment nor sequences allow you to do what you're asking for
though, which is like database garbage collection.  If you really need
something like this you should implement it in a cron job that runs during
non-peak hours as it will be quite an expensive operation on a large table
(the best way I can think of would be to iterate over all table rows and
look for "gaps" in the table, and for each gap take the record with the
highest ID and change the ID to fill the gap, then update all replys to
match the new ID, after everything is finished reset the sequence to the
highest id in the modified table and you're done).  

Note from the MySQL manual for you auto_increment fans out there:

Posted by Jim Martin on Tuesday October 1 2002, @11:57am  

Just in case there's any question, the
AUTO_INCREMENT field /DOES NOT WRAP/. Once you
hit the limit for the field size, INSERTs generate
an error. (As per Jeremy Cole)

And the comment a few beyond that regarding being able to drop the index and
renumber doesn't help here, as there is an exterior resource (the reply
table) that will be broken as soon as the ids change.

If anyone has a better suggestion on how to do this I'd love to hear it :) 

-Javier

> -----Original Message-----
> From: Marek Kilimajer [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, November 11, 2003 3:30 PM
> To: Dimitri Marshall
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Unique ID
> 
> 
> Dimitri Marshall wrote:
> > Hi there,
> > Here's my situation:
> > 
> > I'm making a message board and I've decided the best way to 
> go about 
> > the structure is to have 3 tables, two of them will be "Posts" and 
> > "Replys". Now, in order for this ti work, each post has to have a 
> > UniqueID - same with the replys. Looking at another 
> program, I can see 
> > that one way to do this is to do it by rows (ie. count how 
> many rows, 
> > add 1, then that is the ID). It would be unique because no two rows 
> > would be 1 for example.
> > 
> > The problem I can see is that the database would become incredibly 
> > huge (size wise I mean). I want to delete the posts after 
> 30 days, and 
> > if I delete the row, then that would mess up the row system.
> > 
> > Any suggestions?
> 
> Have you heard about auto_increment? Read on: 
> http://www.mysql.com/doc/en/example-> AUTO_INCREMENT.html
> 
> -- 
> 
> PHP General Mailing List 
> (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
Dimitri Marshall wrote:
Hi there,
Here's my situation:

I'm making a message board and I've decided the best way to go about the
structure is to have 3 tables, two of them will be "Posts" and "Replys".
Now, in order for this ti work, each post has to have a UniqueID - same with
the replys. Looking at another program, I can see that one way to do this is
to do it by rows (ie. count how many rows, add 1, then that is the ID). It
would be unique because no two rows would be 1 for example.

The problem I can see is that the database would become incredibly huge
(size wise I mean). I want to delete the posts after 30 days, and if I
delete the row, then that would mess up the row system.

Any suggestions?

Dimitri Marshall


A standard solution in this case is to use one common table for all messages, both 'posts' and 'replays', distinguishing them by 'type' (TypeID, say 1 for post, 2 for replay), and then build a parent/child relationship between both type of messages in that table. In this way each message will have unique id. When you need all or some 'post' messages, use a query for selecting TypeID = 1, resp. TypeID = 2 for 'replay' messages.

Concerning the deletion of a message (post or replay), you should write a query which will recursively delete the message selected as well as all child messages assigned to that (parent) message. The easiest way to do this is to use triggers, but that depends on the database you work with.

To get closer to this approach and to find some nice examples, check out the following resources:

http://www.sqlmag.com/Articles/Index.cfm?ArticleID=8826
http://www.sqlteam.com/item.asp?ItemID=8866
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_qd_14_5yk3.asp
http://www.yafla.com/papers/sqlhierarchies/sqlhierarchies.htm

HTH,

Boyan
--

--- End Message ---
--- Begin Message --- Marek Kilimajer wrote:
Dimitri Marshall wrote:
I'm making a message board and I've decided the best way to go about the
structure is to have 3 tables, two of them will be "Posts" and "Replys".
Now, in order for this ti work, each post has to have a UniqueID - same with
the replys. Looking at another program, I can see that one way to do this is
to do it by rows (ie. count how many rows, add 1, then that is the ID). It
would be unique because no two rows would be 1 for example.

The problem I can see is that the database would become incredibly huge
(size wise I mean). I want to delete the posts after 30 days, and if I
delete the row, then that would mess up the row system.

Any suggestions?

Have you heard about auto_increment? Read on: http://www.mysql.com/doc/en/example-AUTO_INCREMENT.html

Keep reading about database design, too. You'll only need one table and a "parent-child" relationship. The initial post will have a parent of "zero" and "child" posts under it will have a parent column relating back to the original post.

I may not have explained that the best way, but there are plenty of articles out there about it. Have fun. :)

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Hi All,
    Sorry if this has been asked a 1000 times and if its easy to find in the
php manual but i cant seam to solve this.

How do i convert a timestamp in to a normal readable time & date ie

20031111155023

into

11th November 2003 @ 15:50:23


Many thanks, thought id ask someone is bound to have a snippet for this.



Regards

All



Erin

--- End Message ---
--- Begin Message ---
--- Erin <[EMAIL PROTECTED]> wrote: 
> How do i convert a timestamp in to a normal readable time & date ie
> 
> 20031111155023
> 
> into
> 
> 11th November 2003 @ 15:50:23

That's not a timestamp, first of all. It looks to me like you just need to
use substr() to parse out the elements however you want. You can see if
strtotime() can do anything with it, but I doubt it.

If you want to convert it to a real timestamp, look at the mktime()
function. Once you have a timestamp, it's very easy to work with, and you
can use date() to format it however you want.

Hope that helps.

Chris

=====
My Blog
     http://shiflett.org/
HTTP Developer's Handbook
     http://httphandbook.org/
RAMP Training Courses
     http://www.nyphp.org/ramp

--- End Message ---
--- Begin Message ---
Not sure how others would tackle this, but I would use something like

$readabledate = date("dS F Y @ H:i:s",
                strtotime(substr($timestamp,0,4)."-"
                         .substr($timestamp,4,2)."-"
                                 .substr($timestamp,6,2)." "
                                 .substr($timestamp,8,2).":"
                                 .substr($timestamp,10,2).":"
                         .substr($timestamp,12,2)));

Not sure this is bug free, but it should change your timestamp (yes it is a
database timestamp) into the readable format you described.  It's yours to
debug.

http://www.php.net/manual/en/function.date.php

Good luck,

Warren Vail

-----Original Message-----
From: Erin [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 11, 2003 4:00 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Time problem


Hi All,
    Sorry if this has been asked a 1000 times and if its easy to find in the
php manual but i cant seam to solve this.

How do i convert a timestamp in to a normal readable time & date ie

20031111155023

into

11th November 2003 @ 15:50:23


Many thanks, thought id ask someone is bound to have a snippet for this.



Regards

All



Erin

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

--- End Message ---
--- Begin Message --- Erin wrote:

Hi All,
    Sorry if this has been asked a 1000 times and if its easy to find in the
php manual but i cant seam to solve this.

How do i convert a timestamp in to a normal readable time & date ie

20031111155023

into

11th November 2003 @ 15:50:23

IFF the "timestamp" is coming from MySQL (which has that format), then you should use DATE_FORMAT() in your query to do the formatting.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message --- Hi,

I have a dir of files saved in the following format: YYYY-MM-DD.mp4. I know how to get the file names into an array, but I don't know how to sort the array so that the files appear in date order. My guess was to use strtotime() to get the date into a timestamp, then sort on the timestamp, but there MUST be an easier way :)

I've read through most of the array part of the manual, but can't see what I need.


Justin
--- End Message ---
--- Begin Message ---
surely sort() would do the trick?

Martin

> -----Original Message-----
> From: Justin French [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, 12 November 2003 12:13 PM
> To: php
> Subject: [PHP] sorting files by date
> 
> 
> Hi,
> 
> I have a dir of files saved in the following format: 
> YYYY-MM-DD.mp4.  I 
> know how to get the file names into an array, but I don't know how to 
> sort the array so that the files appear in date order.  My 
> guess was to 
> use strtotime() to get the date into a timestamp, then sort on the 
> timestamp, but there MUST be an easier way :)
> 
> I've read through most of the array part of the manual, but can't see 
> what I need.
> 
> 
> Justin
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> __________ Information from NOD32 1.552 (20031107) __________
> 
> This message was checked by NOD32 for Exchange e-mail monitor.
> http://www.nod32.com
> 
> 
> 
> 

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

...and then Justin French said...
% 
% Hi,

Hi!


% 
% I have a dir of files saved in the following format: YYYY-MM-DD.mp4.  I 

OK.  So what are you filming? :-)


% know how to get the file names into an array, but I don't know how to 
% sort the array so that the files appear in date order.  My guess was to 

If the filename has anything to do with the date, then just sort it.  MM
is numeric and not alphabetic, right?


% use strtotime() to get the date into a timestamp, then sort on the 
% timestamp, but there MUST be an easier way :)

Um, yeah :-)

If the filenames are *not* related to the actual dates, then just stat()
each file and sort based on those results.


% 
% I've read through most of the array part of the manual, but can't see 
% what I need.

I bet it's sort() :-)


% 
% 
% Justin


HTH & HAND

:-D
-- 
David T-G                      * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00001.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
Hi again --

...and then David T-G said...
% 
% [Yes, this is intended to be a new thread.]

GRRR...  It would help if I remembered to change the Subject: line, too.

Anyway, I'd like to see more PHP in Atlanta.


HAND

:-D
-- 
David T-G                      * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00002.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
dear all

i will execute background process like
$program &
is there posible in php to process that statement? and return to php
immediately;
---------------------------------------
rgds

[xm]
http://ilkomerz36.blogspot.com
http://geocities.com/amadarum

--- End Message ---
--- Begin Message ---
Does anyone here have any solid experience with nusoap?  Their list has
low volume and I am finding it difficult to find any useable examples or
descriptions of real life uses and how to configure the server/client.

In particular I'm currently trying to figure out the correct syntax to
produce wsdl using "$server->wsdl->addComplexType(..." to describe an
array of the form...

array([0]=>343454[1]=>SMITH[2]=>BOB[3]=>1969-03-17[4]=>234343444[5]2003-11-11 13:23:02)

where data types are string,string,string,date,string,datetime

It appears that the complexType would be a struct although this is
actually an array.  I just need someone who has had experience with this
toolkit for a couple of issues.

Thanks for any assistance,

Larry

--- End Message ---
--- Begin Message --- I have recently up graded to 4.3.4 and now my links to pear have quite working. I have tried replace pear with go-pear and it is not working. What am I doing wrong?

Old
ini_set('include_path', 'C:/php/pear/');
require_once 'PEAR.php';
require_once 'DB.php';

TIA
Gary

--- End Message ---
--- Begin Message ---
I am following the tutorial at
http://www.freewebmasterhelp.com/tutorials/phpmysql/
The source code is on the website on the left hand side
http://www.freewebmasterhelp.com/static/tutorials/phpmysql/example.zip


My software:
PHP version 4.3.4 on Windows 2000
MYSQL version 4.0.16 on Windows 2000
Apache version 1.3.29 on Windows 2000

The problem is I cannot get the database to add a new records aside from
the auto-increment field. All the other fields are left blank when the
add.html is subitted. 

I have the add.html with the following code exactly the same as the
source code.

<form action="insert.php" method="post">
First Name: <input type="text" name="first"><br>
Last Name: <input type="text" name="last"><br>
Phone: <input type="text" name="phone"><br>
Mobile: <input type="text" name="mobile"><br>
Fax: <input type="text" name="fax"><br>
E-mail: <input type="text" name="email"><br>
Web: <input type="text" name="web"><br>
<input type="Submit">
</form>


The insert.php
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database"); 

$query = "INSERT INTO contacts VALUES
('','$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query);

mysql_close();
?> 



Any help would be much appreciated.

Regards,
Mark

--- End Message ---
--- Begin Message ---
Sorry guys, I have tried all the suggestions so far with no luck.....

Regards,
Mark



try to include field name:
$query = "INSERT INTO contacts(first,$last,phone,mobile,fax,email,web)
VALUES ('$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query);
_______________________________
rgds
[xm]


> I am following the tutorial at 
> http://www.freewebmasterhelp.com/tutorials/phpmysql/
> The source code is on the website on the left hand side 
> http://www.freewebmasterhelp.com/static/tutorials/phpmysql/example.zip
>
>
> My software:
> PHP version 4.3.4 on Windows 2000
> MYSQL version 4.0.16 on Windows 2000
> Apache version 1.3.29 on Windows 2000
>
> The problem is I cannot get the database to add a new records aside 
> from the auto-increment field. All the other fields are left blank 
> when the add.html is subitted.
>
> I have the add.html with the following code exactly the same as the 
> source code.
>
> <form action="insert.php" method="post">
> First Name: <input type="text" name="first"><br>
> Last Name: <input type="text" name="last"><br>
> Phone: <input type="text" name="phone"><br>
> Mobile: <input type="text" name="mobile"><br>
> Fax: <input type="text" name="fax"><br>
> E-mail: <input type="text" name="email"><br>
> Web: <input type="text" name="web"><br>
> <input type="Submit">
> </form>
>
>
> The insert.php
> <?
> include("dbinfo.inc.php"); 
> mysql_connect(localhost,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
>
> $query = "INSERT INTO contacts VALUES 
> ('','$first','$last','$phone','$mobile','$fax','$email','$web')";
> mysql_query($query);
>
> mysql_close();
> ?>
>
>
>
> Any help would be much appreciated.
>
> Regards,
> Mark

--- End Message ---
--- Begin Message --- Mark wrote:

Sorry guys, I have tried all the suggestions so far with no luck.....

Regards,
Mark



try to include field name:
$query = "INSERT INTO contacts(first,$last,phone,mobile,fax,email,web)
VALUES ('$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query);
_______________________________
rgds
[xm]




I am following the tutorial at http://www.freewebmasterhelp.com/tutorials/phpmysql/
The source code is on the website on the left hand side http://www.freewebmasterhelp.com/static/tutorials/phpmysql/example.zip


My software: PHP version 4.3.4 on Windows 2000 MYSQL version 4.0.16 on Windows 2000 Apache version 1.3.29 on Windows 2000

The problem is I cannot get the database to add a new records aside from the auto-increment field. All the other fields are left blank when the add.html is subitted.

I have the add.html with the following code exactly the same as the source code.

<form action="insert.php" method="post">
First Name: <input type="text" name="first"><br>
Last Name: <input type="text" name="last"><br>
Phone: <input type="text" name="phone"><br>
Mobile: <input type="text" name="mobile"><br>
Fax: <input type="text" name="fax"><br>
E-mail: <input type="text" name="email"><br>
Web: <input type="text" name="web"><br>
<input type="Submit">
</form>


The insert.php
<?
include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO contacts VALUES ('','$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query);

mysql_close();
?>



Any help would be much appreciated.

Regards,
Mark





Mark - After the mysql_query($query); line.... add the following line

echo mysql_error();

run the script and try to add something again, if there is an error, it will tell you via mysql_error(); echo it out to the browser, and get back to me :)

Rolf Brusletto
http://www.phpExamples.net

--- End Message ---
--- Begin Message ---
On Tue, Nov 11, 2003 at 07:44:58PM -0800, Mark wrote:
> I am following the tutorial at
> http://www.freewebmasterhelp.com/tutorials/phpmysql/
> The source code is on the website on the left hand side
> http://www.freewebmasterhelp.com/static/tutorials/phpmysql/example.zip
> 
> 
> My software:
> PHP version 4.3.4 on Windows 2000
> MYSQL version 4.0.16 on Windows 2000
> Apache version 1.3.29 on Windows 2000
> 
> The problem is I cannot get the database to add a new records aside from
> the auto-increment field. All the other fields are left blank when the
> add.html is subitted. 
> 
> I have the add.html with the following code exactly the same as the
> source code.
> 
> <form action="insert.php" method="post">
> First Name: <input type="text" name="first"><br>
> Last Name: <input type="text" name="last"><br>
> Phone: <input type="text" name="phone"><br>
> Mobile: <input type="text" name="mobile"><br>
> Fax: <input type="text" name="fax"><br>
> E-mail: <input type="text" name="email"><br>
> Web: <input type="text" name="web"><br>
> <input type="Submit">
> </form>
> 
> 
> The insert.php
> <?
> include("dbinfo.inc.php");
> mysql_connect(localhost,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database"); 
> 
> $query = "INSERT INTO contacts VALUES
> ('','$first','$last','$phone','$mobile','$fax','$email','$web')";

        http://ru3.php.net/manual/en/security.registerglobals.php

        try 
        $query = "insert into contacts values 
('',".$_POST['first'].",".$_POST['last'].",".$_POST['phone'].",".$_POST['mobile'],",".$_POST['fax'].",".$_POST['email'].",".$_POST['web'].")";

        and so on ... 

> mysql_query($query);
> 
> mysql_close();
> ?> 
> 
> 
> 
> Any help would be much appreciated.
> 
> Regards,
> Mark
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
        
                                     -- zhuravlev alexander
                                           u l s t u  n o c
                                             ([EMAIL PROTECTED])

--- End Message ---
--- Begin Message ---
hello All,

  Can i use sudo to assign certain privileges for the
apache account as the webserver is running on that
account. Will it be possible.

Thank you

Tirumal 

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

--- End Message ---
--- Begin Message ---
On Tuesday 11 November 2003 23:07, bob pillford wrote:
> Hi all i have the following code which isnt working correctly and i cant
> work out why. Any help would be greatly appreciated as its sending me
> crazy!
>
> $query = "select refno from campaign where appdate between 'nov 07 2003'
> and 'nov 08 2003' "; $result=mssql_query($query,$numero);
> $numrows=mssql_num_rows($result);
> $row=mssql_fetch_row($result);
> echo $numrows;
> print_r($row);
>
>
> Now this returns: 23
> Array ( [0] => 1044998 )
>
> which is 23 for number of rows the query returns but it only ever stores
> the 1st element of the returned array in $row.. Can someone tell me where i
> am going wrong as i need access to the other 22 rows that this query
> returns.... I have echoed the query and run the out put under freetds tsql
> and get the correct result (this is what i use to access the ms sql server
> 2000).

mssql_fetch_row() only gets *one* row. To get the rest use something like a 
while-loop. For examples refer to the similar mysql_* functions.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
You will pay for your sins.  If you have already paid, please disregard
this message.
*/

--- End Message ---

Reply via email to