[PHP] sorting arrays

2005-03-08 Thread Gabino Travassos
Hello List
I've looked at array_multisort( ), but it doesn't seem like the right 
function. Here's an example of my array, it's a listing of CD reviews:
$cds=array(array(Lowest of the Low, 20050105,9,Toronto), array(Heavy 
Blinkers,20041020,6,Chicago), array(Apple,Fiona,20050308,5,Seattle));

If I wanted to sort them alphabetically, no problem, just sort($cds).
If I want to sort them by date (the second item in the array) or by ranking 
(the third), how do I do that?

Is there something simple?
Many thanks.
Gabino 

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


Re: [PHP] Value in URL issue

2004-06-16 Thread Gabino Travassos
$_SERVER['QUERY_STRING'] should get anything after the ? in your url.

- Original Message - 
From: Mike R [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, June 16, 2004 1:45 PM
Subject: [PHP] Value in URL issue


 
 I have an issue where I have a value in a link like this:
 
 http://www.something.com/templates/nav.php?page=about
 
 But when the link is clicked on, the value of page is empty.  Is this a
 globals issue of some sort?
 
 Thanks,
 
 -Mike

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



Re: [PHP] Value in URL issue

2004-06-16 Thread Gabino Travassos
Maybe you should post all the relevant code.

- Original Message - 
From: Mike R [EMAIL PROTECTED]
To: Gabino Travassos [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, June 16, 2004 2:36 PM
Subject: RE: [PHP] Value in URL issue




 Nothing gets printed out with this.  :\

 -Mike



  -Original Message-
  From: Gabino Travassos [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, June 16, 2004 4:04 PM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP] Value in URL issue
 
 
  $_SERVER['QUERY_STRING'] should get anything after the ? in your url.
 
  - Original Message - 
  From: Mike R [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Wednesday, June 16, 2004 1:45 PM
  Subject: [PHP] Value in URL issue
 
 
  
   I have an issue where I have a value in a link like this:
  
   http://www.something.com/templates/nav.php?page=about
  
   But when the link is clicked on, the value of page is empty.  Is this
a
   globals issue of some sort?
  
   Thanks,
  
   -Mike
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

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


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



Re: [PHP] Javascript Question

2004-06-07 Thread Gabino Travassos
I would do two things.
1. Test your print() function on the same frame. Create a div called
printableText and see if you can print it. If that works, then your
print() function is okay.
2. Test your targeting. Use a different function, such as trying to change
the text or rollover an img in another frame. Then use the document.path
that worked.

BTW, I don't think parent is high enough.

And if anyone knows of a Javascript newsgroup this discussion should be on,
I would join it too.

- Original Message - 
From: GodFoca [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, June 07, 2004 8:47 AM
Subject: [PHP] Javascript Question


 Hey! Sorry for the OT, but since there seems to be no js newsgroup in
gmane,
 I thought maybe someone in here could answer this simple question.

 I am trying to use javascript's print() to print a frame FROM ANOTHER
 frame.

 This is the layout:

 frameset rows=*,40 frameborder=NO border=0 framespacing=0
 frame src=... name=pritableText
 frame src=... name=printButton scrolling=NO noresize
 /frameset

 In printButton I have a simple anchor:

 a href=# onClick=parent.printableText.focus();
 parent.printableText.print();

 Yet nothing happens. What's wrong?

 Thanks in advance,
 Nicolas Sanguinetti

 -- 
 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] Simplistic PHP tutorial

2004-05-25 Thread Gabino Travassos
 I've looked at the php.net tutorial, and though I'm learning some things
  from it, it's still a bit over my head. It seems to presuppose a comfort
 level with programming which I do not have.

 Can anyone recommend a simple, hand-holding, introductory tutorial
 suitable for someone with no programming experience to speak of?

Personally, if I was teaching someone programming concepts from scratch I
would start them with Javascript. It's mostly platform-independent, you
don't need to install any software, and you don't need to upload your files
to a server that has PHP installed. Most of the basics (functions,
variables, math) are the same in php, perl, flash, and Javascript, and
Javascript is the simplest one in terms of getting started and testing your
code quickest.

There are some differences, of course, but you'll always be double-checking
your syntax anyway.

I like the PHP book from Wiley. And MySQL/PHP Database Applications from MT
Books.
For Javascript, buy the cheapest, oldest used book you can find. Or Inside
Javascript from New Riders.

Luck.


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



[PHP] xml ignore whitespace

2004-05-17 Thread Gabino Travassos
Howdy

Here's where I'm at.

$DomDocument = domxml_open_file(myFile.xml);
$RootDomNode = $DomDocument-document_element();
print_r($RootDomNode);   // just to test

$listItems = $RootDomNode - child_nodes(); print_r(brthere are .
count($listItems). child nodesbr); // 35!
print_r($listItems);

When I run the above, it pulls in my XML file and counts how many childNodes
there are, then displays them. What I want to do then is run a for loop on
the childNodes, but ... I want to ignore the whitespace nodes. In Flash
there's an ignoreWhite function, is there anything similar in PHP?

I've poked around a bit, and it doesn't look like it.

Thanks for your time.

Gabino

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



[PHP] regular expressions php/perl/actionscript

2004-04-22 Thread Gabino Travassos
Hello

I'm wondering if Regular Expressions are the same in Perl and PHP (and
possibly Actionscript)? They look the same and smell the same, but if I see
a book in a store for Perl Regular Expressions that's $10 cheaper than the
PHP one (is there one?), then is it the same thing?

While we're on this topic, I'm looking to find an attribute in an XML and
replace it with a string variable I get from a form.

I can use:
$bgClrOld = preg_match('/backColour/',$s);  //  1
to find the attribute, but how do I find and replace
   backColour=a3b4c5
with
   backColour=$bgClrNew
?

TIA

Gabino

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



Re: [PHP] regular expressions php/perl/actionscript

2004-04-22 Thread Gabino Travassos
I forgot to mention that in my XML file, inside the quotes in this attribute
 backColour=xx  the x's will be variable..., so I need some kind of
wildcard to select everything from backColour + the next 8 or 9
characters, cuz it might be backColour=333990 or whatnot.

'backColour' will be a unique string in the XML file, but I'll have those
quotes and a variable RGB hex value to find and replace.

Can I do something like
$bgClrOld = ereg_match('/backColour/'+8chr,$s);
?

Merci

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



Re: [PHP] regular expressions php/perl/actionscript

2004-04-22 Thread Gabino Travassos

Thanks for the suggestions. Between the online manual and the books I have I
think I'll get there eventually. Sometimes my logic just sux. What I needed
to do was have the user fill out a form and if they make changes to the XML
file I would update the file. So, my long way around was to go through the
old XML file and create a string variable for every possible form field.
Then I would compare the /bgClrOld/ to /bgClr/ and if they were different I
would then update the file with an ereg_replace.

After some poking around, this seems to be the way to go. Only if the field
is not empty so I change it

if ($bgClr !=){
$bgClr=xx;
}

I still have some work to do, but ...

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



[PHP] transformation to htm file when downloaded

2004-04-15 Thread Gabino Travassos
Hello All

I'm just starting to get PHP, and I'm wondering about the security of the
code I write. It _seems_ that when I try to download the PHP file directly
(like using Save Target As...) it will download only as an HTML file and my
PHP code is gone. I've tried this on a few other people's sites, and this
seems to be the common behavior. Is there a way someone can extract my php
file without this transformation? What are some good security issues I
should know?

One of the things I'm starting with is a simple blog/guestbook. I have a
couple form fields and I strip_tags ... what else should I be doing? I want
to leave the guestbook pretty open, so I don't want a sign-in and
confirmation thingie. I don't even mind anonymity, cuz I can edit the
comments later if I want.

Thanks for your time.

Gabino

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



Re: [PHP] transformation to htm file when downloaded

2004-04-15 Thread Gabino Travassos
 GT seems to be the common behavior. Is there a way someone can extract my
php
 GT file without this transformation?

 In a nutshell - no.

 Not without your server being compromised (i.e. hacked into or
 misconfigured).

 GT One of the things I'm starting with is a simple blog/guestbook. I have
a
 GT couple form fields and I strip_tags ... what else should I be doing? I
want
 GT to leave the guestbook pretty open, so I don't want a sign-in and
 GT confirmation thingie. I don't even mind anonymity, cuz I can edit the
 GT comments later if I want.

 Check for SQL injection possibly? (assuming you are even using SQL)
 and make sure you addslashes (or test to see if that is being done for
 you) and that's about it.

 Depends how anal you want the script to be though :) I mean you
 could check everything.. from strings to integers, to string length,
 to IP address (flood control), to duplicate entries, etc etc etc.
 Really a how long is a piece of string scenario here.

Hey Richard,

Thanks for the quick response. I'm thinking of adding a check for the string
length, so someone doesn't copy and paste a dictionary into my guestbook,
but I'm not looking at flood control because the comments might be somewhat
conversational.

I have a couple PHP books (like the PHP Cookbook, PHP: Read Less, Learn
More) and a couple PHP/mySQL books and I can't seem to find anything about
that transformation. Are there other books that describe what actually
happens? Is that on php.net somewhere, and what kind of keywords should I
use to find it? I don't think transformation is the right word.

Also, perl has strict, which is to prevent other people from running your
scripts from their server. I added strip_tags to prevent someone from
running code on my server. Have I got my a** covered?

Thanks

Gabino

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



Re: [PHP] transformation to htm file when downloaded

2004-04-15 Thread Gabino Travassos
 If you are saving to SQL you can limit this from the SQL end as well
 as the PHP code, but it's worth doing at the PHP level too.

By contraining the size of the string to tiny or whatever, right? I could
also use Javascript, but I like that PHP is more of an invisible hand.

I'm not using mySQL yet, that's the next step. Some other day. I'm using PHP
to modify the original guestbook.html page, and for now because I don't
expect a lot of comments, I prefer the quick access. No using PHP to access
a sleepy database and finding the contents to fill the page and then display
it. I just don't need that level of performance yet. Maybe when I need a
second page of comments, but I don't want these comments to get carried
away. It's more a luxury item to comment on an editorial written on my
magazine. I'll have to get into mySQL when I start storing and saving more
DB info, a catalog of some sort, saving a user's log-in and settings, but it
seems like overkill for this tiny bit of functionality.

I presumed that if someone ran my file.php from the server that there would
be some kind of transformation to render the tags before they are displayed.
I find it fascinating that just moving the file off the server to your hard
drive with something like Save Target As... manages to do the same
transformation. That's one of the things I don't like about Javascript...
it's so open to scrutiny.

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