RE: Re[2]: [PHP] pop-up

2002-08-18 Thread Jason Soza

I just wrote something exactly like this today:

function news_window (headline_str)
{

var headline_link = /story.asp?headline= + escape(headline_str);

window.open(headline_link,'','scrollbars=yes,resizable=yes');
}

Now, if I needed to pass along more variables, I'd just add them to the
news_window () arguments, i.e. if I needed to pass along a text field and a
user id, I'd go:

function news_window (headline_str,text,user_id)

Try it, then let us know how it goes. Don't use the input tags - once you
make a function like the one above, call it with a
href=javascript:news_window(your_argument_here)/a. Also, try not to say
things like I don't think it will work if you haven't given it a shot yet.
I knew -nothing- of JavaScript before I needed to use the window.open()
function today, but now I know enough about it to make some useful scripts.
Try going to google.com and searching for 'javascript reference' - you will
likely find the results handy.

HTH
Jason Soza

-Original Message-
From: Mantas Kriauciunas [mailto:[EMAIL PROTECTED]]
Sent: Sunday, August 18, 2002 1:44 AM
To: Justin French
Cc: [EMAIL PROTECTED]
Subject: Re[2]: [PHP] pop-up


Hello Justin,

i don't think that this thing will pass 300 simbols successfuly
i take $nw_text from TEXTAREA and i need to pass it to pop-up (other
window) there it will generate preview of that text with some stuff...
but i need to pass also 2 more ...so total is 3 things...one text and
other ones is just like date and username






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




[PHP] preg_match help?

2002-08-17 Thread Jason Soza

I seriously need some help trying to make a match here. Obligatory
disclaimer: yes, I've searched google.com, I've read the PHP manual section
on preg_match(), and I've sat here for 3 hours trying to resolve this on my
own. :) Any help would be great:

I need to match everything between:

b$headline

Where $headline is a variable that will be filled out of a foreach() loop.
The pattern should return everything until it hits:

font face=Verdana size=3

The text file this is taken out of looks like:

font face=Verdana size=3bHeadline here/b/fontp

News story, blah, blah, blah...

font face=Verdana size=3bAnother headline/b/fontp

More news, blah, blah...

...

The contents of the text file echo correctly before the preg_match, but the
preg_match I've tried:

preg_match(!b[^]+(.*)font face=\Verdana\ size=\3\!, $contents,
$story);

Returns array(), so no matches are made. Any suggestions?

TIA,

Jason Soza



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




RE: [PHP] Re: Using fopen()/fread()/fscanf()

2002-07-23 Thread Jason Soza

Okay, I removed that line and I no longer get the invalid File-Handle
resource error, but I also don't get anything useful. Maybe my fscanf() line
needs some work? With this new code, if I print_r($headlines); I get 229 of
these: Array ( [0] = )

Code:
$filename =
fopen(http://www.kinyradio.com/juneaunews/latest_juneau_news.html;, r);

while($headlines = fscanf($filename, p style=\padding-left: 45\font
face=\Verdana\ size=\3\b%[a-zA-Z0-9,. ]/b/font)) {
print_r($headlines);
}
fclose($filename);

What the fscanf() code -should- be doing, or at least what I intend for it
to do, is grab everything between p style=padding-left: 45...b and
/b/font - is my code structured for that?

-Original Message-
From: Martin Towell [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 22, 2002 10:16 PM
To: 'Jason Soza'; David Robley; [EMAIL PROTECTED]
Subject: RE: [PHP] Re: Using fopen()/fread()/fscanf()


I'm thinking that you need to remove the:
   $contents = fread($filename, 100);
line. This is probably making the file pointer point to the end of the file.

-Original Message-
From: Jason Soza [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 23, 2002 4:17 PM
To: David Robley; [EMAIL PROTECTED]
Subject: RE: [PHP] Re: Using fopen()/fread()/fscanf()


I'm fairly certain that fopen() is working fine - I can echo $contents;
and it works great, but it displays the entire page that I fetched. I just
want certain parts of the page and unfortunately, fscanf() doesn't seem to
think $contents or $filename are valid. Just more info on this, I tried
replacing fscanf($filename,...) with fscanf($contents,...) and got the same
result.

Thanks,
Jason Soza


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




RE: [PHP] Re: Using fopen()/fread()/fscanf()

2002-07-23 Thread Jason Soza

Alright, I see that this is probably the way to go, but I'm dying here. I
have this:

$filename =
fopen(http://www.kinyradio.com/juneaunews/latest_juneau_news.html;, r);
$contents = fread($filename, 100);
preg_match_all(|font face=\Verdana\ size=\3\b+[-a-zA-Z0-9,. ]+|i,
$contents, $out);
print_r($out);

And it returns this:

Array ( [0] = Array ( [0] = Injured hiker [1] = Toy guns looked real
enough [2] = U-S Forest Service Chief visiting [3] = Millions in
compensation divided up [4] = Alaska Air [5] = One car [6] = Services [7]
= Talkeetna ) [1] = Array ( [0] = Injured hiker [1] = Toy guns looked
real enough [2] = U-S Forest Service Chief visiting [3] = Millions in
compensation divided up [4] = Alaska Air [5] = One car [6] = Services [7]
= Talkeetna ) )

This is definitely progress, but the headlines are truncated. I have a
feeling this has something to do with linebreaks, but I don't know how to
account for those. For example, $out[0][0] should read Injured hiker
rescued on Mt. Juneau and $out[0][2] should end with ...Alaska for the
first time.

The manual entries for preg_match and preg_match_all pretty much assume you
have a working knowledge of reg expressions, which I don't, and a google
search turned up a bunch of pages, none of which I could understand enough
to be of help. So, any pointers would be appreciated. Thanks!

Jason Soza

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 22, 2002 11:01 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Using fopen()/fread()/fscanf()


On Tuesday 23 July 2002 14:16, Jason Soza wrote:
 I'm fairly certain that fopen() is working fine - I can echo $contents;
 and it works great, but it displays the entire page that I fetched. I just
 want certain parts of the page and unfortunately, fscanf() doesn't seem to
 think $contents or $filename are valid. Just more info on this, I tried
 replacing fscanf($filename,...) with fscanf($contents,...) and got the
same
 result.


Not sure why you're using fscanf() and why it doesn't work. I would use
preg_match() on $contents.

--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Communications satellite used by the military for star wars.
*/


--
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] Newbie: Reading unix directory information from PHP

2002-07-23 Thread Jason Soza

Maybe opendir() and readdir() would work for you?

opendir():
http://www.php.net/manual/en/function.opendir.php

readdir():
http://www.php.net/manual/en/function.readdir.php

Jason Soza

- Original Message -
From: Paul Oh [EMAIL PROTECTED]
Date: Tuesday, July 23, 2002 3:03 pm
Subject: [PHP] Newbie: Reading unix directory information from PHP

 Hi, I'm just starting to learn PHP.  I couldn't find how to 
 execute unix
 command and read the result.  Basically, I just want to execute 
 ls -lrt
 and read and display the output.
 
 This may be very simple question, but for some reason, I couldn't 
 find any
 info on executing unix command from PHP.
 
 Thanks.
 
 -Paul
 
 
 
 -- 
 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] Re: Using fopen()/fread()/fscanf()

2002-07-23 Thread Jason Soza

I must be dumb because I still can't get it to work.

Using the following instead of my previous preg_match_all statement:
preg_match_all(|font face=\Verdana\ size=\3\b(.*)/b/font|i,
$contents, $out);

Gives me only the -last- 3 headlines on
http://www.kinyradio.com/juneaunews/latest_juneau_news.html. I've looked at
the source and there are indeed more matching tags than are being returned.
I've tried placing r+ in my fopen() statement to put the pointer at the
beginning of the file, but no luck there. I've also tried a bigger filesize
constant in fread(), still nothing.

Actually, I just noticed what the difference is with those last three -
their lines don't break in the source. The other lines have breaks, so the
/b/font land on the following line. Is there anything I can do to have
preg_match_all 'connect' the lines?

Any help would be great. Thanks!

Jason Soza

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 23, 2002 1:20 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Using fopen()/fread()/fscanf()


On Tuesday 23 July 2002 15:38, Jason Soza wrote:
 Alright, I see that this is probably the way to go, but I'm dying here. I
 have this:

   $filename =
 fopen(http://www.kinyradio.com/juneaunews/latest_juneau_news.html;, r);
   $contents = fread($filename, 100);
   preg_match_all(|font face=\Verdana\ size=\3\b+[-a-zA-Z0-9,.
 ]+|i, $contents, $out);
   print_r($out);

Assuming that the font and b tags are closed and you want everything in
between then try this:

  preg_match_all(|font face=\Verdana\ size=\3\b(.*)/b/font|i,
$contents, $out);

 The manual entries for preg_match and preg_match_all pretty much assume
you
 have a working knowledge of reg expressions, which I don't, and a google
 search turned up a bunch of pages, none of which I could understand enough
 to be of help. So, any pointers would be appreciated. Thanks!

You want to read up on Pattern Modifiers and Pattern Syntax, that's
where
all the regex black magic is explained.

--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
He's dead, Jim.
-- McCoy, The Devil in the Dark, stardate 3196.1
*/


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




[PHP] Spambot Defense Code

2002-07-23 Thread Jason Soza

Worked on this a bit tonight, thought it might help someone out there! I
looked at the bottomw of phpclasses.org at what they'd done to obfuscate
their e-mail address using JavaScript. While theirs is much more complex, I
couldn't figure a way to do it their way when you don't know the exact
user@domain of people in your database. I thought this might do the trick,
at least to some extent, by separating the user and domain in the source
code and not put them together until the mailto: link is clicked. Sorry if
something like this has been posted before - if so, here it is again! :)

script language=JavaScript
!--
?php

$email = [EMAIL PROTECTED];//replace with e-mail addy from db
$new_email = explode(@, $email); //separate into two sections based on
the @

print function hide_me()\n;
print {\n;
print var usr= '$new_email[0]';\n; //the user of user@domain
print var dom= '$new_email[1]';\n; //the domain of user@domain

print window.location=\mailto:\+usr+\@\+dom;\n;; //print JS to
recombine the parts
print }\n;
?
//--!
/script
a href=javascript:hide_me()E-mail me/A


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




[PHP] Using fopen()/fread()/fscanf()

2002-07-22 Thread Jason Soza

I think I'm pretty close to getting this right (maybe!), I've been reading
through the manual, but can't seem to work it out. I keep getting this
error:

[Mon Jul 22 19:03:24 2002] [error] PHP Warning:  Supplied argument is not a
valid File-Handle resource in index.php on line 66

I'm trying to open a URL, read the contents, then pull out specific info
found between specific HTML tags. This is what I have so far:

63| ?php
64| $filename =
fopen(http://www.kinyradio.com/juneaunews/latest_juneau_news.html;, r);
65| $contents = fread($filename, 100);
66| while($headlines = fscanf($filename, p style=\padding-left:
45\font face=\Verdana\ size=\3\b%[a-zA-Z0-9,. ]/b/font,
$headline)) {
67| extract($headlines);
68| print a
href=\http://www.kinyradio.com/juneaunews/latest_juneau_news.html\;$headli
ne/abr;
69| }
70| fclose($filename);
71| ?

Any ideas? Any other functions I could try instead of fscanf()?

TIA,
Jason Soza


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




RE: [PHP] Re: Using fopen()/fread()/fscanf()

2002-07-22 Thread Jason Soza

I'm fairly certain that fopen() is working fine - I can echo $contents;
and it works great, but it displays the entire page that I fetched. I just
want certain parts of the page and unfortunately, fscanf() doesn't seem to
think $contents or $filename are valid. Just more info on this, I tried
replacing fscanf($filename,...) with fscanf($contents,...) and got the same
result.

Thanks,
Jason Soza

-Original Message-
From: David Robley [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 22, 2002 8:37 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Using fopen()/fread()/fscanf()


In article [EMAIL PROTECTED], [EMAIL PROTECTED]
says...
 I think I'm pretty close to getting this right (maybe!), I've been reading
 through the manual, but can't seem to work it out. I keep getting this
 error:

 [Mon Jul 22 19:03:24 2002] [error] PHP Warning:  Supplied argument is not
a
 valid File-Handle resource in index.php on line 66

 I'm trying to open a URL, read the contents, then pull out specific info
 found between specific HTML tags. This is what I have so far:

 63| ?php
 64|   $filename =
 fopen(http://www.kinyradio.com/juneaunews/latest_juneau_news.html;, r);
 65|   $contents = fread($filename, 100);
 66|   while($headlines = fscanf($filename, p style=\padding-left:
 45\font face=\Verdana\ size=\3\b%[a-zA-Z0-9,. ]/b/font,
 $headline)) {
 67|   extract($headlines);
 68|   print a

href=\http://www.kinyradio.com/juneaunews/latest_juneau_news.html\;$headli
 ne/abr;
 69|   }
 70|   fclose($filename);
 71| ?

 Any ideas? Any other functions I could try instead of fscanf()?

That error indicates that fopen failed to open the requested file. Given
that the URL works fine in a browser, is it possible that your php is not
configured to do remote fopen? Check the setting of allow_url_fopen in
phpinfo()

It is a good idea to test the result of such calls before trying to use
the result:

fopen('Whatever') or exit('Couldn't get it, Boss!');

or

if(fopen('whatever') {
  do good things;
}else{
  bleat vigorously;
}

Cheers
--
David Robley
Temporary Kiwi!

Quod subigo farinam

--
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] Table Making

2002-07-11 Thread Jason Soza

Thanks for the code improvement, but that will still print results from left
to right, top to bottom, i.e. the items ascend left to right in the rows.
I'm not concerned with the actual order that they come out of MySQL in, just
how they're displayed.

Basically, instead of this:
1  2  3  4  5
6  7  8  9  10
11  12  13  14  15

I want this:
1  6  11
2  7  12
3  8  13
4  9  14
5  10  15

Thanks again for the help, though.

Jason Soza

-Original Message-
From: Analysis  Solutions [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 10, 2002 10:13 PM
To: PHP List
Subject: Re: [PHP] Table Making


Jason:

On Wed, Jul 10, 2002 at 10:04:45PM -0800, Jason Soza wrote:

 I have this nice piece of code to take my SQL result and organize it into
a
 nice 5 column table:

Nice is in the eye of the beholder...  Here's what I think is nice:

  echo table width=\100%\ border=\0\ align=\center\\n;
  echo  tr\n;

  while ($row = mysql_fetch_array($sql, MYSQL_ASSOC)) {
 echo '  td align=centera href=year.asp?year=';
 echo $row['grad_year'] . '' . $row['grad_year'] . /a/td\n;
  }

  echo  /tr\n;
  echo /table\n\n;

If you want to reverse the order, use an ORDER BY clause in your query
string.

--Dan

--
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409


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




[PHP] (OT) No Punishment for Erik Hegreberg, Yet...

2002-07-11 Thread Jason Soza

Well, my attempts at getting discipline for Erik Hegreberg will have to 
go unfinished for now. I guess a list admin would have to retrieve the 
original headers from Erik's original posts -before- they hit the 
mailing list software and got new headers and distributed. Any list 
admins out there want to help with that?

Seems kind of silly - if they keep e-mail transaction logs and they 
know the e-mail account of Mr. Hegreberg, they should be able to 
correlate my complaint. Oh well, 'twas a valiant effort!

Thanks everyone yesterday for sending me those headers.

In any case, here's the response from [EMAIL PROTECTED] (apparently the 
same as [EMAIL PROTECTED]):

Dear mr. Soza,

At 11:27 10.07.2002 -0800, you wrote:
It appears that you do have the full headers of the message in 
question, as they appeared on my machine. Since Mr. Hegreberg was 
sending these messages to a mailing list, the headers mostly show the 
mailing list information.

The headers you sent did not contain the necessary information. It 
seems the mailing-list strips away the important part of the headers, 
so that none of the headers you've received are sufficient.

We recommend that you contact the list administrator and ask if he/she 
can fix the problems with headers being removed, and if he has the 
original headers so that we can track down the users.


-- 
Consultant-ID 23
Abuse Response Team, Telenor Business Solutions
Email: [EMAIL PROTECTED]Fax: +47 22 77 19 98
http://www.online.no/abuse (Norwegian only)
 

Jason Soza



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




Re: [PHP] Table Making

2002-07-11 Thread Jason Soza

Just an idea I came up with after turning off my computer last night 
(don't ya hate that!) - I don't know how 'dirty' or 'crude' this would 
be, but in my head it seems like it would work. Basically, what if the 
while() printed multiple tables? In each table it made 5 rows, each row 
with one cell in it, so it would then be vertical. I'm just not sure 
how to incorporate into the loop (maybe a for() loop is better for 
this?) incremental queries, so that the first loop pulls rows 1-5, the 
next query 6-10, etc. until there are no more rows. Think this might 
work?

I will still try the array method suggested by a couple of people, 
but... I haven't really ever worked with arrays.

Pseudo code
Do my first query:
$i=0;   //define variable
$sql = mysql_query(SELECT grad_year FROM alumni LIMIT $i, 5 GROUP BY 
grad_year);

$grad_year=; //define variable - avoid errors

while ($row = mysql_fetch_array($sql)) {
extract($row);

if($i==1) {
print centertable width=\10%\ border=\0
\\n; //start table
 }
 
printf(trtd align=\center\a href=\year.asp?year=%s\%
s/abr/td/tr\n, $grad_year, $grad_year); //print links, one per 
row

if ($i==5) {
print /table\n; //end table on $i = 5 
 }

$i+5;


$grad_year=; //clear $grad_year
 
}
 
if ($i5) print /table\n; //end any rows with less than 5 columns

Jason Soza

- Original Message -
From: Justin French [EMAIL PROTECTED]
Date: Thursday, July 11, 2002 3:48 am
Subject: Re: [PHP] Table Making

 I hate to think what sort of a burden this would place on ther server,
 but...
 
 You could always find out how many rows there are, then run individual
 queries for each cell of the table.  In other words, to achieve 
 this layout:
 
 1 4 7
 2 5 8
 3 6 9
 
 You would do queries in this order:
 
 1
 4
 7
 2
 5
 8
 3
 6
 9
 
 Like I said, I shudder at the thought of how much this would load 
 the server
 (especially on large rows (lots of fields) or large tables (lots 
 of rows =
 lots of queries)), but if the layout is imperative, then maybe 
 this is an
 option...
 
 I can't see why you can't run it as
 
 1 2 3
 4 5 6
 7 8 9
 
 
 Cheers,
 
 Justin
 


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




Re: [PHP] Table Making

2002-07-11 Thread Jason Soza

This is exactly what I was looking for. Now I wish I could just leave 
work now to test it out!

Thanks everyone for your help on this, very appreciated!

Jason Soza

- Original Message -
From: Chris Boget [EMAIL PROTECTED]
Date: Thursday, July 11, 2002 9:05 am
Subject: Re: [PHP] Table Making

  be, but in my head it seems like it would work. Basically, what 
 if the 
  while() printed multiple tables? In each table it made 5 rows, 
 each row 
  with one cell in it, so it would then be vertical. I'm just not 
 sure 
  how to incorporate into the loop (maybe a for() loop is better 
 for 
  this?) incremental queries, so that the first loop pulls rows 1-
 5, the 
 
 Basically, you'd need an inner and outer loop.  Something like
 this should work (untested):
 
 $result = mysql( $dbname, $query );
 
 $numRows = mysql_num_rows( $result );
 
 echo table\n;
 for( $i = 0; $i  $numRows; $i++ ) {
  echo trtd\n;
  echo table\n;
 
  while( $dataArray = mysql_fetch_assoc( $result )) {
echo td . implode( /td/trtrtd, $dataArray ) . 
 /td/tr
  }  
 
  echo /table\n;
  echo /td/tr\n;
 
 }
 echo /table\n;
 
 You may need to fool around with it abit, but that should work...
 
 Chris
 
 
 


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




Re: [PHP] Re: Table Making

2002-07-11 Thread Jason Soza

Well, wouldn't that print a table with one row containing the results?

Again, what I'm looking for is a vertically laid-out table. So instead 
of:
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15

I want:
1 6 11
2 7 12
3 8 13
4 9 14
5 10 15

To give you an idea of why I want this, check out www.jdhsgrads.com - 
this is the site I'm currently working on. When you see the list of 
graduation years, your eye (well, at least mine) wants to follow the 
dates top to bottom, left to right. As it is now, you have to work to 
see the progression and find out where you want to go to locate a 
specific date.

I'm hoping the code I posted will create something like:
table
tr
td
table
trtd1941/td/tr
trtd1942/td/tr
trtd1943/td/tr
/table
/td
td
table
...

Make sense?

Jason Soza

- Original Message -
From: Lazor, Ed [EMAIL PROTECTED]
Date: Thursday, July 11, 2002 2:08 pm
Subject: RE: [PHP] Re: Table Making

 Will this work for you?
 
   $numFields = mysql_num_fields($Results);
   
   print table;
   while ($Row = mysql_fetch_array($Results))
   {
   print tr;
   for ($i = 0; $  $numFields; $i++)
   print td.$Row[$i]./td;
   print /tr;
   }
   print /table;
 
 
 
 -Original Message-
 I was wondering if the following might work:
 
 $cells = 10; //set desired number of cells per column
 $numRows = mysql_num_rows($result); //determine number of rows
 $numCols = ceil($numRows/$cells); //determine number of columns needed
 
 print centertable width=\100%\ border=\0\ 
 cellpadding=\0\ 
 cellspacing=\0\\n; //start main table
 
 for($i=0; $i$numCols; $i++) { 
 
 echo trtd align=\center\\n; //setup main row/cell
 
 echo table border=\0\ cellpadding=\0\ cellspacing=\0
 \\n; //setup secondary table
 
   while($dataArray = mysql_fetch_array($result)) { //print 
 results of SQL in secondary table
   extract($dataArray);
   $n++;
   
   printf(tr\ntd align=\center\ 
 valign=\center\href=\year.asp?year=%\%s/td\n/tr, 
$grad_year, $grad_year);
 
   if ($n==$cols) {
   echo /table\n; //close secondary table at 
 10 cells
   }  
 
 echo /td/tr\n; //close main row/cell
 
 }
 
 echo /table\n; //close main table


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




[PHP] Re: Table Making - All done!

2002-07-11 Thread Jason Soza

Thanks everyone that helped with this, I finally got it working - Ed's
version was the one I tweaked and got to work. It was pretty close to
working as-is, but needed an incrementing variable in the if(isset($Row))
statement to be used in the print $Row[] line. Here's the final working
code, if anyone else out there wants a vertically-displaying table:

$cols = 5;
$num_rows = mysql_num_rows($result);
$rows_col = ceil($num_rows / $cols);

print tabletr;

for ($i = 0; $i  $cols; $i++) {
print td;
for ($j = 0; $j  $rows_col; $j++) {
if (isset($array)) {
$a++;
print $array[$a] . br;
}
}
}

print /td/tr/table;

-Original Message-
From: Lazor, Ed [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 11, 2002 3:05 PM
To: 'Jason Soza'; Lazor, Ed
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] Re: Table Making


Well then...

$TotalCol = 5;
$NumRows = mysql_num_rows($Results);
$RowsPerCol = ceil($NumRows / $TotalCol);

print tabletr;

for ($i = 0; $i  $TotalCol; $i++)
{
print td;
for ($j = 0; $j  $RowsPerCol; $j++)
{
$Row = mysql_fetch_array($Results);
if (isset($Row))
print $Row[0] . br;
}
print /td;
}

print /td/table;



-Original Message-
From: Jason Soza [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 11, 2002 3:18 PM
To: Lazor, Ed
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Table Making


Well, wouldn't that print a table with one row containing the results?

Again, what I'm looking for is a vertically laid-out table. So instead
of:
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15

I want:
1 6 11
2 7 12
3 8 13
4 9 14
5 10 15

To give you an idea of why I want this, check out www.jdhsgrads.com -
this is the site I'm currently working on. When you see the list of
graduation years, your eye (well, at least mine) wants to follow the
dates top to bottom, left to right. As it is now, you have to work to
see the progression and find out where you want to go to locate a
specific date.

I'm hoping the code I posted will create something like:
table
tr
td
table
trtd1941/td/tr
trtd1942/td/tr
trtd1943/td/tr
/table
/td
td
table
...

Make sense?

Jason Soza

- Original Message -
From: Lazor, Ed [EMAIL PROTECTED]
Date: Thursday, July 11, 2002 2:08 pm
Subject: RE: [PHP] Re: Table Making

 Will this work for you?

   $numFields = mysql_num_fields($Results);

   print table;
   while ($Row = mysql_fetch_array($Results))
   {
   print tr;
   for ($i = 0; $  $numFields; $i++)
   print td.$Row[$i]./td;
   print /tr;
   }
   print /table;



 -Original Message-
 I was wondering if the following might work:

 $cells = 10; //set desired number of cells per column
 $numRows = mysql_num_rows($result); //determine number of rows
 $numCols = ceil($numRows/$cells); //determine number of columns needed

 print centertable width=\100%\ border=\0\
 cellpadding=\0\
 cellspacing=\0\\n; //start main table

 for($i=0; $i$numCols; $i++) {

 echo trtd align=\center\\n; //setup main row/cell

 echo table border=\0\ cellpadding=\0\ cellspacing=\0
 \\n; //setup secondary table

   while($dataArray = mysql_fetch_array($result)) { //print
 results of SQL in secondary table
   extract($dataArray);
   $n++;

   printf(tr\ntd align=\center\
 valign=\center\href=\year.asp?year=%\%s/td\n/tr,
$grad_year, $grad_year);

   if ($n==$cols) {
   echo /table\n; //close secondary table at
 10 cells
   }

 echo /td/tr\n; //close main row/cell

 }

 echo /table\n; //close main table


This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.

--
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] (OT) Erik Hegreberg - need headers for abuse@online.no

2002-07-10 Thread Jason Soza

Hey,

I got a response from [EMAIL PROTECTED] regarding Erik Hegreberg's little 
stunt yesterday and they want full headers from the message in 
question. I thought all headers were going with my message to 
[EMAIL PROTECTED] when I forwarded, but apparently they got stripped by 
my client.

Unfortunately, I deleted all of Erik's messages as they came in, so I'm 
hoping someone out there that still has at least one copy can either 
forward me a copy with all headers intact, or can copy/paste headers 
into a new message and send those to me.

Just want to make sure Erik is properly dealt with by his ISP. Thanks,

Jason Soza


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




[PHP] Table Making

2002-07-10 Thread Jason Soza

I'm driving myself crazy trying to visualize what I want to do, so I thought
I'd share the insanity and hope for some advice.

I have this nice piece of code to take my SQL result and organize it into a
nice 5 column table:

print centertable width=\100%\ border=\0\\n; //start table

$i=0;   //define variable - avoid errors
$grad_year=;  //define variable - avoid errors

while ($row = mysql_fetch_array($sql)) {
extract($row);
$i++;

if($i==1) {
print tr\n; //start table row on $i = 1
}

printf(td align=\center\a
href=\year.asp?year=%s\%s/abr/td\n, $grad_year, $grad_year);
//print links

if ($i==5) {
print /tr\n; //end table row on $i = 5 to get 5 columns
$i=0; //reset $i
}

$grad_year=; //clear $grad_year

}

if ($i5) print /tr\n; //end any rows with less than 5 columns

print /table/centerp\n; //end table
---END

Now, this works great for most things - it takes my SQL results and puts
them in a table sequentially, from left to right, top to bottom. So in this
case, the top-left cell displays 1941, the top-right cell displays 1945,
the next row starts with 1946 on the left and goes to 1950 on the right,
and so on.

What I want is rather than sorting left to right, top to bottom, I want to
sort top to bottom, left to right. So the top-left would still be 1941,
but rather than increasing to the right, it would increase down, then
continue at the top of the next column.

I'm thinking this might be an easy thing to do with some creative use of $i
and print, but I just can't think it out. I'm guessing $i would be used to
limit the amount of items in a column... But, I'm in need of some guidance
to get it right. I can't even begin to think where to start. Any help would
be great - thanks!

Jason Soza


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




Re: [PHP]%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

2002-07-09 Thread Jason Soza

Hmm.. I wonder if there's an [EMAIL PROTECTED] that we should all be 
forwarding these constructive e-mails to. Nothing like getting an 
account blocked!

Really though, Erik, go to http://www.php.net/unsub.php - it's easy.

If you have English problems or something, I'm sure there's a Norwegian 
translation somewhere.

Jason Soza

- Original Message -
From: Daniel Negron/KBE [EMAIL PROTECTED]
Date: Tuesday, July 9, 2002 11:28 am
Subject: Re: [PHP] %%
%)))
)))

 
 Is this retaliation ?
 
 **DAN**
 
 
 
 
 |+
 ||  Erik |
 ||  Hegreberg|
 ||  ehegrebe@onli|
 ||  ne.no|
 |||
 ||  07/09/02 03:27|
 ||  PM|
 |||
 |+
  
 ---
 ---|
  |
   
   |
  |  To: [EMAIL PROTECTED]   
   
   |
  |  cc:   
   
   |
  |  Subject: [PHP]
   
   |
  |   
 %%
%)))
)|  
|   ))  

   |
  
 ---
 ---|
 
 
 
 
 TT
 
 
 
 
 
 -- 
 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] Erik Hergreberg

2002-07-09 Thread Jason Soza

FWIW, I e-mailed this to [EMAIL PROTECTED], [EMAIL PROTECTED], and 
[EMAIL PROTECTED] - who knows if anything will come of it, just hope 
that some sort of discipline will be handed to Mr. Hergreberg!

Jason

-
Message:

Erik Hegreberg ([EMAIL PROTECTED]) is spamming php-
[EMAIL PROTECTED] Apparently, he can't figure out how to 
unsubscribe from the mailing list and is displeased with the amount of 
e-mail he's getting. At the bottom of each and every message posted to 
the mailing list is a footer with this:

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

Although this has been pointed out to Erik by several different people 
several different times, he has proceeded to flood the list with e-
mails with long subject lines similar to the subject line on this 
message and no body. There have been at least 25 or more in the past 5 
minutes.

This is a quite large mailing list so no doubt thousands of people are 
beginning to get quite annoyed with Mr. Hegreberg. If there's anything 
you can do to assure that he won't continue doing this, it would be 
much appreciated.

Thanks,
Jason Soza





- Original Message - 
From  Erik Hegreberg [EMAIL PROTECTED] 
Date  Tue, 9 Jul 2002 21:29:59 +0200 
To  [EMAIL PROTECTED] 
Subject  [PHP] 
¨æææ
æ 




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




RE: [PHP] Help and advice sought - search/replace

2002-06-27 Thread Jason Soza

Thanks for everyone's help. I didn't try this method, but I'll definitely
try it next time I do something like this. Here's the final code that I got
to work, and it works beautifully. Thanks again for your help on this!

The fwrite() function I threw in is fairly useless - it writes the final
output to the end of the NAMES.txt file, I suppose this could be modified to
write to a new file or whatever you want, but I found it easier to just
highlight and copy the output from the browser:

?php
$filename = NAMES.txt;

$fp = fopen($filename, r+);
echo $filename is now open for reading and writing...p;

$contents = fread($fp, filesize($filename));

$names = explode(\n, $contents);

foreach($names as $name) {
$new_name = ereg_replace('([^,]*), ([^ ]*)', '\\2 \\1', $name);
echo $new_namebr;
fwrite($fp, $new_name.chr(13).chr(10));
}

fclose($filename);
?

Thanks again,
J

-Original Message-
From: Niklas Lampén [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 26, 2002 10:06 PM
To: Php-General
Subject: RE: [PHP] Help and advice sought - search/replace


If your list looks like this:


Salo, Mika
Räikkönen, Kimi
Häkkinen, Mika


And there is no other commas in the list, you can do it something like
this:

?
$commaSeparatedList = join(\n, file(NAMES.txt));
$tabSeparatedList = preg_replace(, , \t, $commaSeparatedList);
$arrayOfTabSepList = explode(\n, $tabSeparatedList);
?

I think that'll do. I didn't test it thou.. :)


Niklas

-Original Message-
From: Jason Soza [mailto:[EMAIL PROTECTED]]
Sent: 27. kesäkuuta 2002 7:42
To: PHP-General Mailing List
Subject: [PHP] Help and advice sought - search/replace


Just looking for a pointer or functions I can use to do this...

I have a spreadsheet with a couple thousand entries that I'll be using
for populating a MySQL database. The spreadsheet has names listed in
last, first - the database I'll be populating has separate fields for
first and last names.

I exported the names column from the spreadsheet in tab-delimited format
and I figured I could come up with a quick PHP script that would open
the text file, find each instance of , , take all that's before that
delimiter and move it after all that's after that delimiter, inserting a
tab in between. So last, first would become first[tab]last.

So far, I've gotten:
?php
$filename = NAMES.txt; //name the file...
$fp = fopen($filename,r+); //open it...
echo Reading $filename...;

$contents = fread($filename, filesize($filename)); //read it...

$names = explode(\n, $contents);

foreach($names as $name);
echo $namebr;

fclose($filename);
?

Obviously, I've written in some stuff just so I can see what I'm doing,
the echo in the foreach for example. But I'm stuck on what to use to
actually separate and rewrite each $name. I'm assuming I'll have to
create a while() or for() loop and use a regular expression for this?
I'm not sure where to look. Any help would be great - just so I won't
have to go in and manually separate first and last names. Thanks!

Jason Soza


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

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail.
For more information, connect to http://www.F-Secure.com/

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail.
For more information, connect to http://www.F-Secure.com/

--
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] Help and advice sought - search/replace

2002-06-26 Thread Jason Soza

Just looking for a pointer or functions I can use to do this...

I have a spreadsheet with a couple thousand entries that I'll be using for
populating a MySQL database. The spreadsheet has names listed in last,
first - the database I'll be populating has separate fields for first and
last names.

I exported the names column from the spreadsheet in tab-delimited format and
I figured I could come up with a quick PHP script that would open the text
file, find each instance of , , take all that's before that delimiter and
move it after all that's after that delimiter, inserting a tab in between.
So last, first would become first[tab]last.

So far, I've gotten:
?php
$filename = NAMES.txt; //name the file...
$fp = fopen($filename,r+); //open it...
echo Reading $filename...;

$contents = fread($filename, filesize($filename)); //read it...

$names = explode(\n, $contents);

foreach($names as $name);
echo $namebr;

fclose($filename);
?

Obviously, I've written in some stuff just so I can see what I'm doing, the
echo in the foreach for example. But I'm stuck on what to use to actually
separate and rewrite each $name. I'm assuming I'll have to create a while()
or for() loop and use a regular expression for this? I'm not sure where to
look. Any help would be great - just so I won't have to go in and manually
separate first and last names. Thanks!

Jason Soza


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




RE: [PHP] rounding a number

2002-06-23 Thread Jason Soza

I think what you're looking for is number_format() - you can set decimal
places with it and used in combo with round(), ceil(), and/or floor(), you
should be able to achieved the desired result.

http://www.php.net/manual/en/function.number-format.php

HTH,

Jason Soza

-Original Message-
From: Phil Schwarzmann [mailto:[EMAIL PROTECTED]]
Sent: Sunday, June 23, 2002 7:35 PM
To: [EMAIL PROTECTED]
Subject: [PHP] rounding a number


I want to round a number to the nearest decimal place...

if the number is 4.623, I want it to display 4.6
if the number is 2.36, I want it to display 2.7

Is there a function that does this?  round(), ceil(), floor() don't do
this and I've checked through all the math functions in my handy-dandy
PHP Functions reference book.

Thanks for your help!!!

Or..if it's too hard to do that, I could just use a function that
chops off the end of some decimals, like...

if the number is 2.343234, I want just 2.3
or if the number is 2.545434534534534534, I want just 2.5

Thanks!!


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




[PHP] Stumped on a function

2002-06-21 Thread Jason Soza

I've been using the following function successfully for months, tonight I
literally copied/pasted it to another page I was creating, called it exactly
the same using the same data type, and I'm getting an incorrect result. The
function is supposed to take a standard MySQL CCYY-MM-DD date format and
convert it to a Month Day, CCYY format. Here's the function code:

function cleandate($indate) {
str_replace(-, /, $indate);
return date(F j, Y, strtotime($indate));
}

And I'm calling it with:

$newdate = cleandate($birthdate);

$birthdate is a MySQL DATE field and if I echo $birthdate I get
2002-11-04, which is what is entered for that $birthdate record. However,
when I echo $newdate using the above code, I get June 20, 2002 - today's
date.

Now, again I'm using this code as-is successfully on another page. I don't
understand why it's returning today's date on this page, but returning the
correct date on another page.

This is the error that PHP is throwing regarding the above code:
[Thu Jun 20 23:16:38 2002] [error] PHP Warning:  strtotime() called with
empty time parameter in test.php on line 19

Line 19 is the 'return' line in the function. I do not get this error in my
successful application of this code.

Any ideas? Thanks in advance...

Jason Soza


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




Re: [PHP] Stumped on a function

2002-06-21 Thread Jason Soza

To be honest, I didn't know I could format the date within my query. 
For some reason, I was under the assumption that since dates go into 
MySQL in a specific format, that's how they came out.

Anyway, thanks for pointing this out to me! Very helpful.

Jason Soza

- Original Message -
From: Jesper Brunholm [EMAIL PROTECTED]
Date: Friday, June 21, 2002 2:02 am
Subject: Re: [PHP] Stumped on a function

 John Holmes wrote:
  Why don't you just use DATE_FORMAT() in your query, then you 
 don't have
  to do any extra PHP code at all??
 
 you might want a link to that:
  
 
target=lhttp://www.mysql.com/doc/D/a/Date_and_time_functions.html - 
look 
 somewhat below the middle of the page
 
 function cleandate($indate) {
 str_replace(-, /, $indate);
 return date(F j, Y, strtotime($indate));
 }
 
 check the $indate - response from the db - if you give invalid 
 data 
 there then it will (probably) use a timestamp instead, whith now()-
 values...
  when I echo $newdate using the above code, I get June 20, 
 2002 -
  today's date.
 
 Regards
 
 Jesper Brunholm
 
 -- 
 Phønix - Danish folk music from young musicians - 
 http://www.phonixfolk.dk
 
 
 -- 
 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] Re: Code Structure/Errors

2002-06-16 Thread Jason Soza

Figured it was something simple. Part of the learning process, I suppose.
Thanks for the help!

Jason Soza

-Original Message-
From: Dan Koken [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 15, 2002 11:31 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Code Structure/Errors


Can simply set $i before the while.

I assume the $last_name is coming from the DB.

Not exactly sure what you want, but hope this helps.
good luck... Dan.
--
$i
= 0;
while ($row = mysql_fetch_array($result)) {
extract($row);
if (($i % 5) == 0) print tr\n;
$i++;
@$last_name .= '';
if($last_name  '')
print stuff here
 else
print other stuff
...
if (($i % 5) == 0) print /tr\n;
}




Jason Soza wrote:

 I'm just curious if there's a way to restructure my code so as to avoid
 getting Undefined Variable errors. I keep getting them and I know
they're
 nothing to worry about for the most part, I'd like to get rid of them
 without turning off error reporting if possible. In the following code, I
 get an undefined variable error for $i and for $last_name, is there
anything
 I can do to actually define them? $last_name is a variable produced by my
 MySQL query, $i is just a counter:

 while ($row = mysql_fetch_array($result)) {
   extract($row);
   $i++;
   if($i==1) {
   print tr\n;
   }

   if($last_name) {
   print stuff here
   } else {
   print other stuff
   }
 ...
   if ($i==5) {
print /tr\n;
$i=0;
}
   }

 Thanks!

 Jason Soza


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




[PHP] Code Structure/Errors

2002-06-15 Thread Jason Soza

I'm just curious if there's a way to restructure my code so as to avoid
getting Undefined Variable errors. I keep getting them and I know they're
nothing to worry about for the most part, I'd like to get rid of them
without turning off error reporting if possible. In the following code, I
get an undefined variable error for $i and for $last_name, is there anything
I can do to actually define them? $last_name is a variable produced by my
MySQL query, $i is just a counter:

while ($row = mysql_fetch_array($result)) {
extract($row);
$i++;
if($i==1) {
print tr\n;
}

if($last_name) {
print stuff here
} else {
print other stuff
}
...
if ($i==5) {
 print /tr\n;
 $i=0;
 }
}

Thanks!

Jason Soza


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




[PHP] Spam Bots/E-mail Addys

2002-06-13 Thread Jason Soza

Just curious...

If I have a site that stores information about people in a database, 
including e-mail addresses, and that information is only viewable when 
called via a user-specific variable, i.e. their alias, can spambots 
still harvest those e-mail addresses?

So for instance I have a page called 'users.php' and to find the e-mail 
address for John Smith, you'd follow a link that directs you to 
users.php?alias=johnsmith - I guess my main question is, can spambots 
follow those types of links, get the resulting page, and harvest the 
address off that?

Is there any way to combat this? Any PHP scripts, classes, functions 
that can 'hide' e-mail addresses? The site I'll be building needs to 
have the e-mail addresses available, but I don't want to subject users 
to more spam than they probably already get.

Jason Soza


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




Re: [PHP] Spam Bots/E-mail Addys

2002-06-13 Thread Jason Soza

So basically, to keep the address away from bots, keep it away from 
normal users. Okay, so something like this would be more effective:

Have a form with a hidden input of the user's alias, and an input of E-
mail me!, that form posts to an email.php script that uses the user's 
alias to pull the e-mail address out of the db and I suppose I could 
use JavaScript to popup a new window to enter the text of the e-mail 
and use mail() to send. Would displaying the e-mail address in that new 
window again be just as bad as displaying it on the main page?

I realize this isn't a new idea, but I'm assuming it's more secure than 
just keeping a mailto:[EMAIL PROTECTED] link around.

Thanks,

Jason Soza

- Original Message -
From: Stuart Dallas [EMAIL PROTECTED]
Date: Thursday, June 13, 2002 9:23 am
Subject: Re: [PHP] Spam Bots/E-mail Addys

 Basic fact: If a normal (anonymous) visitor can get at the email 
 addresses, so
 can a bot. It all depends on the bot, but there's no getting 
 around that basic
 fact.
 
 -- 
 Stuart



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




Re: [PHP] Different Problem [Re: Passing a Variable to PHP Viathe URL]

2002-06-11 Thread Jason Soza

Rather than just setting globals on in php.ini, try this:

Your printf() line is:
printf(Variables:  %s\nbr, $HTTP_GET_VARS[id]);

And your if() statement is:
if($id) {}

Where is $id set? It's probably not. $HTTP_GET_VARS[id] doesn't set 
$id. If you want the id variable in your if(), you need:
if($HTTP_GET_VARS[id]) {}

Or alternately do:
$id = $HTTP_GET_VARS[id]
if($id) {}

Although that's not necessary. Also, try using $_GET[id], as 
$HTTP_GET_VARS[] has been deprecated in newer versions.

HTH,

Jason Soza

- Original Message -
From: [EMAIL PROTECTED]
Date: Tuesday, June 11, 2002 8:16 am
Subject: [PHP] Different Problem [Re: Passing a Variable to PHP Via the 
URL]

 I found out that in fact PHP is creating a variable with the name 
 and value I'm passing through a URL from the querystring.  But 
 it's still not working as planned.
 
 The url server/test.php?id=1 creates the following results in my code:
 
 printf(Variables:  %s\nbr, $HTTP_GET_VARS[id]);
 
 This line works - there IS a variable named 'id' in my page and it 
 has the correct value, 1.
 
 if ($id) {}
 
 This fails.  If I test 'id' instead of '$id' then it works but my 
 page doesn't seem to equate 'id=1' with the presence of $id.
 
 $result = mysql_query(SELECT * FROM employees WHERE id=$id,$db);
 
 This doesn't work - again it seems $id isn't being treated 
 properly.  I get this error:
 
 Warning: mysql_fetch_array(): supplied argument is not a valid 
 MySQL result resource
 
 If I hardwire my page with the line '$id=1;' before the if 
 statement and the query everything works.
 
 So why isn't the variable from my URL being treated properly?
 
 Jesse
 


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




Re: [PHP] self processing forms

2002-06-10 Thread Jason Soza

Are you restarting Apache (or whatever webserver you're using) between 
edits to php.ini? I assume since you also posted this to php-win that 
you're using Win32. This would be my first step if you haven't done so 
already.

I got corrected on this before, saying that you -don't- have to restart 
between edits, but trust me, you do. I made changes to php.ini, saved, 
and no changes were noted until AFTER I restarted Apache. Apache does 
parse php.ini on startup because I entered invalid pathnames in various 
places as a test, and only on restart did I get a notice that the 
pathnames were invalid.

I'm using Win32, PHP v4.1.2 as a module (not CGI), Apache 1.3.something.

Jason Soza

- Original Message -
From: Bill Hudspeth [EMAIL PROTECTED]
Date: Monday, June 10, 2002 2:16 pm
Subject: [PHP] self processing forms

 I am using the O'Reilly Programming PHP manual, and have copied 
 the code
 from Example 7.3, p. 166. I have the magic_quotes_gpc set to ON in 
 php.ini(though toggling between on and off doesn't seem to have 
 any effect). My
 processed form reports 0.00F is -17.78C  regardless of the initial
 fahrenheit temperature I enter. Moreover, using another version of 
 thisscript, as shown in Example 7.4, p. 167, simply clears the 
 text field, and
 never returns an output. I can't figure out why I am not getting a 
 correctoutput - perhaps something in my php.ini file? A copy of 
 the code I am using
 (Example 7.3) is as follows:
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
 
 html
 head
 titleUntitled/title
 /head
 
 body
 
 ?php
 if ($_SERVER['REQUEST_METHOD'] == 'GET'){
 ?
 
 form action=?php echo $_SERVER['PHP_SELF'] ? method=POST
 Fahrenheit temperature:
 input type=text name=fahrenheit' /
 
 input type=submit name=Convert to Celsius! /
 /form
 
 ?php
 } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
 $fahr=$_POST['fahrenheit'];
 $celsius=($fahr - 32) * 5/9;
 printf(%.2fF is %.2fC, $fahr, $celsius);
 //echo The temperature in degrees celsius is $celsius;
 } else {
 die(This script only works with GET and POST requests.);
 }
 ?
 
 /body
 /html
 
 **
 
 Thanks much in advance, Bill


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




[PHP] PHP/MySQL

2002-06-09 Thread Jason Soza

I'm wondering how PHP handles result sets and other info gathered from
MySQL.

The reason I ask is I've been messing with mysql_connect() functions all
day, finally found a solution (or so I thought), then a couple hours later I
returned to my site and got an Unable to connect error.

When I make a change to the mysql_connect() function in my PHP script, then
save and reload that page, it doesn't seem to have any effect at the time.
For example, I don't allow any anonymous access to my MySQL server, but I
can take out host, user, and password information from mysql_connect(), save
and reload and it still loads as if the function worked.

I've already tried deleting all cached info through my browser (IE) and I've
made other PHP changes that do take effect, it's just the mysql_connect()
that doesn't seem to want to work.

The site is www.miatapix.net - I have it showing as working fine on my side,
someone else want to take a look at it and see what they get? And any help
for this? It's hard to troubleshoot things when results aren't immediately
available.

Thanks in advance,

Jason Soza


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




[PHP] mysql_connect()

2002-06-08 Thread Jason Soza

I posted this to the MySQL list as well, but haven't gotten an answer so
far. Just wonderin gif it may be a PHP problem I'm looking at. Anyway, this
is the text of the message I posted to MySQL, with a few edits:

I don't know if this is more of a PHP thing or a MySQL user issue that I'm
having trouble with.

I have this code:

/* Connecting, selecting database */
$link = mysql_connect()
or die(Could not connect: . mysql_error());
mysql_select_db(my_database) or die(Could not select database);

I've gone through the MySQL manual step-by-step on how to remove the
anonymous user (I'm using Win32) and add a password for the root user, then
create other users. I also have read the PHP manual concerning the
mysql_connect() function and use it accordingly, mysql_connect(host,
user, pass)

The problem is, when I put anything in the mysql_connect() function, I get:
Access denied for user: 'user@host' (Using password: YES)

Where user is whatever user I'm trying to connect with (have tried many) and
host is my server - I've tried both localhost (which gives me server not
found) and the actual hostname of my computer, which gives me the access
denied.

The weird thing is, this works with -just- mysql_connect(), and the
user/pass combos I'm using I use just fine to maintain and update the
database, i.e. these are known good user/pass combos.

Any idea what's happening?

Jason Soza


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




Re: RE: [PHP] Creating pop-up window and passing variable toit?

2002-06-04 Thread Jason Soza

Couldn't you also do:

a href=foobar.php?var1=1var2=2 target=_blankLink/a

I think you can subsitute Resource Window for _blank and get the 
same effect.

HTH

Jason Soza

- Original Message -
From: Martin Towell [EMAIL PROTECTED]
Date: Tuesday, June 4, 2002 3:55 pm
Subject: RE: [PHP] Creating pop-up window and passing variable to it?

 script
 function myopen()
 {
  window.open(foobar.html?var1=?= $var1; ?var2=?= $var2; ?);
 }
 /script
 click for new window
 
 
 -Original Message-
 From: Igor Portnoy [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, June 05, 2002 9:52 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Creating pop-up window and passing variable to it?
 
 
 How can I create a pop up window in my index.php (for example) 
 when user
 clicks on the link and pass value of the variable from my 
 index.php to
 this new window?


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




RE: [PHP] Previous Next Navigation

2002-06-03 Thread Jason Soza

I don't know if it's possible (or faster, or more efficient), but could 
you query your millions of records for those 3k - 5k, insert them into 
a temp table, then do your LIMIT queries on that table for your 
prev/next pages?

Just an idea!

Jason Soza
Juneau, Alaska

- Original Message -
From: Jay Blanchard [EMAIL PROTECTED]
Date: Monday, June 3, 2002 11:07 am
Subject: RE: [PHP] Previous  Next Navigation

 [snip]
 So you think it's more efficient and faster to load a 3 - 5 
 thousand row
 table into an array in memory and pass that around to all of your 
 scripts(through sessions?), rather than just passing a $page 
 variable and doing a
 query to return 30 rows on each page??
 
 If you pass a $Page variable, you can make your query like this:
 
 SELECT * FROM table LIMIT $Page*30,30
 
 Just increment and decriment $Page as you traverse the 
 results...easy, eh?
 [/snip]
 
 It's definitely faster, as for more efficient I would have to do 
 benchmarks.The original table consists of millions of rows and 
 each time you query with
 LIMIT the query traverses the entire set of records in the data to 
 get the
 proper CONDITIONS. Given that there are 3k -5k rows amongst the 
 millionsthis requires a lot of search time for each query. The 
 memory footprint of
 the 3k - 5k of records, even if the total memory needed for each 
 record is
 1k (which it is not), is 30k - 50k RAM, less than the size of most web
 pages. The LIMIT query, running on a slow server to simulate dial-up
 connections, takes anywhere from 1.3 to 2.2 minutes (been timing 
 it a lot
 today) to execute. Since efficiency is often lumped in with speed, 
 I would
 have to surmise that using an array in this instance would be more 
 efficientas well.
 
 Thanks!
 
 Jay
 
 
 
 
 
 
 -- 
 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] Re: stupid error, please kick me (and send me a solution)

2002-06-03 Thread Jason Soza

If this is truly the code you're using, you're missing the closing 
curly-brace after the else statement. I.e. this:
} else {
  echo font size=+1Your Information has successfully been 
entered into the database!/fontbr;

Should be this:
} else {
  echo font size=+1Your Information has successfully been 
entered into the database!/fontbr;
   }

HTH,
Jason Soza

- Original Message -
From: Jule Slootbeek [EMAIL PROTECTED]
Date: Monday, June 3, 2002 2:09 pm
Subject: stupid error, please kick me (and send me a solution)

 Hey guys,
 i'm getting this error with the following sql script using php:
 --error--
 Warning: Supplied argument is not a valid MySQL-Link resource in 
 /var/www/phpquiz/register_user.php on line 12
 --error--
 
 --script--
 $link_glob = mysql_connect('$host_glob', '$un_glob', '$pw_glob');
 $query = INSERT INTO user values('0', '$fname', '$lname', 
 '$email', 
 '$username', PASSWORD('$password');
   $result = mysql_db_query('$db_glob', '$query', 
 $link_glob'); if (!$result) {
   echo font size=+1Your Information 
 could not be entered into the database, 
 Please contact the 
 href=mailto:$webmasterwebmaster./fontbrbr . mysql_errno() 
 . 
 :  . mysql_error() . brbr;
   } else {
   echo font size=+1Your Information 
has 
 successfully been entered into the 
 database!/fontbr;
 
 -- 
 Jule Slootbeek
 [EMAIL PROTECTED] 
 
 http://blindtheory.cjb.net 


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




[PHP] Graphs using PHP

2002-05-30 Thread Jason Soza

Just want to run this by you all to check the feasibility of it.

I run a site that deals with cars, people can upload pics of their vehicle
and tell everyone else its year, color, 'generation', and where they're
located.

What I'd like to do is make some graphs on the front page that look like
gauges you'd see in a car, i.e. speedometer, tachometer, oil, etc. but these
would actually be graphs showing, for instance, how many of the cars on the
site are red, or whatever the most popular color is. So if a majority of the
cars were red, and red cars made up 57% of the total cars on the site, I'd
want a graphic of a speedometer with a needle that would be in a position
that represented 57%.

How difficult is this? I looked at some of the imagecreate() functions in
the manual, but they look like a language all their own and I'd like to know
if there's any easier way to do this that I'm overlooking. I'm thinking
doing some kind of image overlay is the way to go, but not sure. Any ideas
or pointers would be great, links to sample scripts would be excellent.
Thanks!

Jason Soza


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




Re: [PHP] voting using text files

2002-05-22 Thread Jason Soza

Using file locking, if two people tried to use the script at the same 
time, wouldn't there be an error for one of them?

My first guess at defeating this is having the script write a file 
named after the voter's IP. Have the file written to a different 
directory for whatever choices they have, then use readdir() to count 
the files in each directory, i.e. the number of votes for each choice. 
Then if that same IP tries to vote again, check it against votes 
already received and approve/deny it.

I guess another way, have files written with consecutive titles, vote1, 
vote2, vote3, inside each one, store their vote choice, their IP, and a 
timestamp.

I don't know, I'm not an expert! Just throwing out ideas.

Jason Soza

- Original Message -
From: 1LT John W. Holmes [EMAIL PROTECTED]
Date: Wednesday, May 22, 2002 5:46 am
Subject: Re: [PHP] voting using text files

 Use file locking, so only one instance of the script is writing to 
 the file
 at a time...
 
 www.php.net/flock
 
 ---John Holmes...
 
 - Original Message -
 From: Nick Wilson [EMAIL PROTECTED]
 To: php-general [EMAIL PROTECTED]
 Sent: Wednesday, May 22, 2002 9:38 AM
 Subject: [PHP] voting using text files
 
 
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
  hi all
  I have to build a php 'survey' app. but cannot use a db,
  clearly text files are the way but I wondered, before I start if 
 any of
  you have done similar and might offer any words of wisdom?
 
  Are there any inherent problems I need be aware of for example 
 (I can
  already think of one: what if 2 people try to vote at the same 
 time?)
  Just some general thoughts would be greatly appreciated ;)
  - --
  Nick Wilson //  www.explodingnet.com


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




Re: [PHP] voting using text files

2002-05-22 Thread Jason Soza

And this is why I'm not an expert!

I have a counter script on my page now that uses a flatfile to store 
IP's, but it also stores a timestamp. When someone visits the page, the 
current time is compared to the stored timestamp for that IP + whatever 
timeout period I set. If it's less, then that IP is not counted again. 
If it's more, than the previous entry is deleted and a new one written 
with a new timestamp. I have it set for 15 minutes just to keep people 
from sitting and hitting 'reload' to run up my counter.

Anyway, I figured the same type of thing could be used here, I just 
didn't explain it. Seems that someone else came up with a simpler 
solution anyhow!

Thanks for pointing out my idea's flaws... I'm a little biased, so I 
don't always see them myself.

Jason Soza

- Original Message -
From: Miguel Cruz [EMAIL PROTECTED]
Date: Wednesday, May 22, 2002 9:45 am
Subject: Re: [PHP] voting using text files

 On Wed, 22 May 2002, Jason Soza wrote:
  Using file locking, if two people tried to use the script at the 
 same 
  time, wouldn't there be an error for one of them?
 
 The second session would just have to wait for the first to finish 
 (which 
 should be an infinitessimal amount of time).
 
  My first guess at defeating this is having the script write a 
 file named
  after the voter's IP. Have the file written to a different 
 directory for
  whatever choices they have, then use readdir() to count the 
 files in
  each directory, i.e. the number of votes for each choice.  Then 
 if that
  same IP tries to vote again, check it against votes already 
 received and
  approve/deny it.
 
 Using IPs is a pretty lousy way of uniquely identifying users, 
 especially 
 for a purpose like this:
 
 1. If I dial in with a modem, I probably get a new IP each time I 
 connect, 
 so I can vote as often as I like.
 
 2. Many companies, ISPs, and even countries use proxy servers that
 aggregate thousands or millions of users behind a handful of IP 
 addresses.  
 One vote from China, Saudi Arabia or New Zealand and that could be 
 it for
 the country. Likewise AOL.
 
 Try cookies or something. Still can be defeated by the determined 
 ballot-box stuffer, but so can everything else that doesn't 
 require human 
 verification of identity.
 
 miguel


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




[PHP] Quick query question

2002-05-22 Thread Jason Soza

Alliteration at its finest...

This is slightly off-topic, so please reply offlist. It's a MySQL question
that I'm hoping someone can help me with. I figure since a large portion of
PHP programmers also use MySQL, this is a valid question to at least -post-
here. If I'm completely off about this, please let me know. I HAVE read the
relevant portions of the MySQL manual, FYI.

I discussed this a bit on the list a few weeks ago, it's about a project I'm
working on to consolidate 75 playlists into a database sortable by song,
album, and artist.

I have 3 tables as was suggested, one for songs, one for albums, one for
artists. Each has two columns, one being whatever information I'm entering,
and the other a MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY column.

I have 3 other tables containing two MEDIUMINT columns, these link each of
the 3 others. I have:
artists_tracks
tracks_albums
albums_artists

Each is setup so that the records represent 'links' - for example,
artists_tracks has artist_id and track_id columns. Each record is made up of
an artist_id and a matching track_id.

My problem is, when querying some records are lost. But only on a certain
query. For instance:
SELECT tracks.tracks, artists.artists
FROM tracks, artists, artists_tracks
WHERE tracks.id = artists_tracks.track_id AND artists.id =
artist_tracks.tracks_id

This works. It returns 614 records, each track mated with it's relative
artist. This same query works using albums and the tracks_albums table,
returning 614 records as well. Matching up albums to artists returns 413
records, which is the correct number.

However, the following query returns 451 instead of the expected 614 and I
can find no distinguishable pattern as to the records dropped:
SELECT tracks.tracks, albums.albums, artists.artists
FROM tracks, albums, artists, tracks_albums, albums_artists, artists_tracks
WHERE tracks.id = tracks_albums.track_id AND albums.id =
tracks_albums.album_id
AND albums.id = albums_artists.album_id  AND artists.id =
albums_artists.artist_id
AND artists.id = artists_tracks.artist_id  AND tracks.id =
artists_tracks.track_id

I've tried LEFT JOIN as well, and have tried numerous other suggestions out
of the manual, but everything turns up 451 records. I haven't been able to
track down WHY records are missing - it seems almost random. If I sort by
album, sometimes all songs from an album have been listed, sometimes only 3
of 5 or 7 of 10 are missing.

Any help would be greatly appreciated and I apolgize again for posting this
question here if it upsets anyone. I'm just really frustrated right now and
not wanting to join yet another mailing list for one question. Please reply
offlist. Thanks in advance.

Jason Soza


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




RE: [PHP] Quick query question

2002-05-22 Thread Jason Soza

I think I'm a little more embarrassed than anything - I don't get upset!
Thanks for letting me know, though.

BTW, did you know that www.gremlins.com.hk doesn't turn up anything? I get a
Cannot find server or DNS error

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 22, 2002 8:48 PM
To: Jason Soza
Subject: Re: [PHP] Quick query question


On Thursday 23 May 2002 12:07, you wrote:
 I'm sorry.

 I'm used to other lists where occasional off-topic posts are tolerated a
 little more. Didn't know really how this list would react, but I thought
 I'd give it a shot.

For me it probably depends on the circumstances. For instance if the list
was
low volume then I might be more inclined to tolerate (slightly) OT posts.
But
the php is such a high volume list and having to trawl through non-relevant
posts can be daunting.

 I've subscribed to the MySQL list and have posted my message there as
well.

good :)

 In the future I'll not post any off-topic stuff. Thanks,

Thanks for your understanding, some people get mighty upset when you ask
them
to stop posting OT stuff.

cheers
--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
The truth of a proposition has nothing to do with its credibility.  And
vice versa.
*/


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




RE: [PHP] Quick query question

2002-05-22 Thread Jason Soza

Well it just keeps getting better. I hit reply-to and the response went
here.

I apologize for this and my earlier off-topic post. I made a blatant mistake
in judgement.

Jason Soza

-Original Message-
From: Jason Soza [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 22, 2002 9:21 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Quick query question


I think I'm a little more embarrassed than anything - I don't get upset!
Thanks for letting me know, though.

BTW, did you know that www.gremlins.com.hk doesn't turn up anything? I get a
Cannot find server or DNS error

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 22, 2002 8:48 PM
To: Jason Soza
Subject: Re: [PHP] Quick query question


On Thursday 23 May 2002 12:07, you wrote:
 I'm sorry.

 I'm used to other lists where occasional off-topic posts are tolerated a
 little more. Didn't know really how this list would react, but I thought
 I'd give it a shot.

For me it probably depends on the circumstances. For instance if the list
was
low volume then I might be more inclined to tolerate (slightly) OT posts.
But
the php is such a high volume list and having to trawl through non-relevant
posts can be daunting.

 I've subscribed to the MySQL list and have posted my message there as
well.

good :)

 In the future I'll not post any off-topic stuff. Thanks,

Thanks for your understanding, some people get mighty upset when you ask
them
to stop posting OT stuff.

cheers
--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
The truth of a proposition has nothing to do with its credibility.  And
vice versa.
*/


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




RE: [PHP] Feelin' dumb...

2002-05-18 Thread Jason Soza

Thanks everyone for your help on this, this is the final code:

if ($num_pages = 2) {
for ($i=0, $p=1; $i$num_pages; $i++, $p++) {
$j = ($i==0) ? $i : $j+20;
printf(| a href=\test.php?type=allpage=%s\Page 
%s/a | ,
$j, $p);
}
}

Because of the way MySQL uses LIMIT, I found that using LIMIT 1, 20 and
LIMIT 21, 20 leaves out the 1st and 20th records. So I had to change $i to 0
to get them back. However, this left me with Page 0 | Page 1 - not cool,
so I added $p into the loop, but started it at 1 so I'd have a variable to
use for correct page numbers.

Oh and I had to change $i=$num_pages to just $i$num_pages because with
$i=0, I was getting an extra iteration. What a learning experience!

Thanks again,

Jason Soza

-Original Message-
From: Richard Baskett [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 8:47 PM
To: Jason Soza; PHP General
Subject: Re: [PHP] Feelin' dumb...


Ok Im feeling dumb also now *hehe*  What I said about putting the $number
line below the printf line.. Don¹t listen to me :)  Now that I know what you
want.. I know there is cleaner and better code, but it works :)

if ($num_pages = 2) {
  for ($i=1; $i=$num_pages; $i++) {
$j = ($i==1) ? $i : $j+20;
echo | a href=\test.php?page=$j\Page $i/a | ;
  }
}

Rick

Be kind. Everyone you meet is fighting a hard battle - John Watson

 From: Jason Soza [EMAIL PROTECTED]
 Date: Fri, 17 May 2002 20:44:30 -0800
 To: Richard Baskett [EMAIL PROTECTED], PHP General
 [EMAIL PROTECTED]
 Subject: RE: [PHP] Feelin' dumb...

 The 20 is inserted into a MySQL LIMIT query. Page 1 = LIMIT 1,20 to get
the
 first 20 records from 1, then Page 2 = LIMIT 21,20 to get the next 20,
etc.

 I think I see the error here.

if ($num_pages = 2) {
for ($i=1; $i=$num_pages; $i++) {
$number = ($i * 20) + 1;
printf(| a href=\test.php?page=%s\Page %s/a | , $number,
 $i);
 }
 }

 Is ALMOST right... Except that the I need the first iteration to return 1.
 In this case, it returns 21, so the next iteration is 41. Follow me? I
need
 1, 21, not 21, 41. Almost there I think, unfortunately, I need to jet.
I'll
 be thinkin' on this one while DJing, definitely!

 Thanks again for everyone's help.


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




[PHP] Using PHP for NULLs

2002-05-18 Thread Jason Soza

I thought this was a MySQL question, or something that could be solved using
a creative SQL string, but after looking through the MySQL manual, I don't
think I can handle this with the database alone. According to the manual,
MySQL always sorts NULL values first - I want them last. I have a last_name
field that sometimes contains people's last names, sometimes they choose not
to enter their last names. I want those who don't enter a last name to end
up last on the list.

Right now I have: $result = mysql_query(SELECT * FROM new_miatapix ORDER BY
last_name LIMIT $page, 20);

Am I going to have to do two queries here, then store them somehow using an
array? It seems like I'm going to have to do one query to get all NULL
values for last_name, then do another query to get all NOT NULL values for
last_name, but how would I handle that after I get it to PHP?

Or can I use some PHP function to sort $result to place all NULL values
last? I'd check the PHP manual, but it seems to not be responding well at
the moment.

Thanks,

Jason Soza


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




RE: [PHP] Re: Using PHP for NULLs

2002-05-18 Thread Jason Soza

Thanks for the help! I spent more time looking at IFNULL() when I should've
just been looking at IF(). Thanks again, sorry for the off-topic!

Jason Soza

-Original Message-
From: Dan Koken [mailto:[EMAIL PROTECTED]]
Sent: Saturday, May 18, 2002 11:16 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Using PHP for NULLs


I do believe it is a MySql question!!

What's wrong with the old standard way as:

$result = mysql_query(
SELECT *,
if (last_name is NULL,'zzz end',last_name) as last_name_sort
FROM   new_miatapix
ORDER BY last_name_sort
LIMIT $page, 20);


Good Luck.. HTH..
Dan..
===
Jason Soza wrote:

 I thought this was a MySQL question, or something that could be solved
using
 a creative SQL string, but after looking through the MySQL manual, I don't
 think I can handle this with the database alone. According to the manual,
 MySQL always sorts NULL values first - I want them last. I have a
last_name
 field that sometimes contains people's last names, sometimes they choose
not
 to enter their last names. I want those who don't enter a last name to end
 up last on the list.

 Right now I have: $result = mysql_query(SELECT * FROM new_miatapix ORDER
BY
 last_name LIMIT $page, 20);

 Am I going to have to do two queries here, then store them somehow using
an
 array? It seems like I'm going to have to do one query to get all NULL
 values for last_name, then do another query to get all NOT NULL values for
 last_name, but how would I handle that after I get it to PHP?

 Or can I use some PHP function to sort $result to place all NULL values
 last? I'd check the PHP manual, but it seems to not be responding well at
 the moment.

 Thanks,

 Jason Soza




--
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] ob_start() and ob_gzhandler

2002-05-17 Thread Jason Soza

Just wondering what would cause the following:
I have a 512/128 cable connection through my ISP that I'm hosting my 
sites through. I have a 10gb/mo transfer limit (u/l and d/l) so when I 
saw mention of the ob_gzhandler (and mod_gzip for Apache), that kind of 
got me interested in it.

Anyway, I created a test page, put -just- ?php ob_start(); ? at the 
top, then some lines of HTML, and loaded it. I got all the HTML code 
displayed - shouldn't I have gotten a white screen since I had no ?php 
ob_flush(); ? tag at the bottom? This isn't making sense. Then I tried 
?php ob_start(ob_gzhandler); ? and ?php ob_flush(); ? at the 
bottom - same results.

Am I doing something wrong? Shouldn't the ob_start() by itself just 
load all output into a buffer and not display it until I call ob_flush
()? And how would I know if ob_gzhandler works? I'm running PHP and 
Apache on Windoze, PHP is version 4.2.0 I think, Apache is 
1.3.something.

TIA

Jason Soza



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




Re: [PHP] ob_start() and ob_gzhandler

2002-05-17 Thread Jason Soza

Hmmm... So if I -wanted- to buffer the entire page using ob_gzhandler, 
I wouldn't use ob_implicit_flush(), correct? Or would this be 
beneficial in this case? The way I read the manual page on 
ob_implicit_flush() is that it flushes after each output call. Would 
that mean that ob_start(ob_gzhandler) would compress the output, then 
ob_implicit_flush() would display that compressed output at each call?

Either way, is there any way to tell if my output is really being 
compressed by ob_gzhandler?

Jason Soza

- Original Message -
From: Miguel Cruz [EMAIL PROTECTED]
Date: Friday, May 17, 2002 10:39 am
Subject: Re: [PHP] ob_start() and ob_gzhandler

 On Fri, 17 May 2002, Jason Soza wrote:
  Am I doing something wrong? Shouldn't the ob_start() by itself 
 just 
  load all output into a buffer and not display it until I call 
 ob_flush ()?
 
 Or when you get to the end of execution...
 
   http://php.net/ob_implicit_flush
 
 miguel
 
 
 -- 
 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] Feelin' dumb...

2002-05-17 Thread Jason Soza

Okay, I'm apologizing right now for this, but I hope it's at least
tolerable. I have this:

for ($i=1; $i=$num_pages; $i++) {
// print stuff here
}

For each loop, I want to add 20 to $i, so after the first iteration, I have
21, then 41, 61, etc. I've tried $i+20, $i + 20, I've tried looking in the
manual, but I assume this is some C-type function, and I'm not familiar with
C!

Any helpers?

Jason Soza


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




RE: [PHP] Feelin' dumb...

2002-05-17 Thread Jason Soza

Well, I tried that but the page doesn't finish loading... I.e. a script that
normally doesn't take more than a second to load just sits there. With $i++,
everything's fine - with $i+20, the browser says it's loading, but all I
have is a white screen for about 30 seconds... Then it times out.

-Original Message-
From: Richard Baskett [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 7:15 PM
To: Jason Soza; PHP General
Subject: Re: [PHP] Feelin' dumb...


Hmm... Wouldn¹t you just do this?:

for ($i=1; $i=$num_pages; $i+20) {
  // print stuff here
}

Rick

The vision must be followed by the venture. It is not enough to stare up
the steps - we must step up the stairs. - Vance Havner

 From: Jason Soza [EMAIL PROTECTED]
 Date: Fri, 17 May 2002 19:19:28 -0800
 To: [EMAIL PROTECTED]
 Subject: [PHP] Feelin' dumb...

 Okay, I'm apologizing right now for this, but I hope it's at least
 tolerable. I have this:

 for ($i=1; $i=$num_pages; $i++) {
 // print stuff here
 }

 For each loop, I want to add 20 to $i, so after the first iteration, I
have
 21, then 41, 61, etc. I've tried $i+20, $i + 20, I've tried looking in the
 manual, but I assume this is some C-type function, and I'm not familiar
with
 C!

 Any helpers?

 Jason Soza


 --
 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] Feelin' dumb...

2002-05-17 Thread Jason Soza

Thanks Craig, that worked!

I wonder why the other suggestions weren't working. They seemed logical
enough, I even tried variations of your suggestion, first I tried:

for ($i=1; $i=$num_pages; $number = $i + 20) {}

That wasn't working, still was getting the 30 second timeout. Then I tried:

for ($i=1; $i=$num_pages;) { $number = $i + 20; }

Since the manual says any of the expressions can be left blank. That still
executed beyond the 30 seconds and timed out.

Anyways, your suggestion is MUCH faster! Thanks for everyone's help -

Jason

-Original Message-
From: Craig Vincent [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 7:36 PM
To: Jason Soza; [EMAIL PROTECTED]
Subject: RE: [PHP] Feelin' dumb...


 For each loop, I want to add 20 to $i, so after the first
 iteration, I have
 21, then 41, 61, etc. I've tried $i+20, $i + 20, I've tried looking in the
 manual, but I assume this is some C-type function, and I'm not
 familiar with
 C!

Well this is a bit of a detour from the other suggestions however since you
haven't gotten a successful solution yet how about

for ($i=1; $i=$num_pages; $i++) {
$number = ($i * 20) + 1;
// print stuff here
}

The results would be $number = 21 on first run, then 41, then 61 etc (which
I believe is what you are looking for).  Note the parenthesis in the $number
line are not needed however I typically code with them as it makes it easier
to understand the code with less though =)

Sincerely,

Craig Vincent



--
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] Feelin' dumb...

2002-05-17 Thread Jason Soza

Makes sense. Thanks!

Now... I have this little problem:
if ($num_pages = 2) {
for ($i=1; $i=$num_pages; $i++) {
$number = ($i * 20) + 1;
$page = $i+1;
printf(| a href=\test.php?page=%s\Page %s/a | , $number, $page);
}
}

I want $page to be $i + 1, but when I do $page = $i+1;, $i somehow gets
evaluated into the for() loop and an additional iteration is completed. So
basically if I do it this way, I get I'll get 1, 21, 41, when really only 1
and 21 are valid. If I put in $page = $i++; it works correctly, but $i is 1
when I want it to be two. If I take out $page = and put in $i where $page is
in the printf() statement, I get the extra iteration again. Any ideas?

-Original Message-
From: Craig Vincent [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 7:56 PM
To: Jason Soza; [EMAIL PROTECTED]
Subject: RE: [PHP] Feelin' dumb...


 I wonder why the other suggestions weren't working. They seemed logical
 enough, I even tried variations of your suggestion, first I tried:

 for ($i=1; $i=$num_pages; $number = $i + 20) {}
 for ($i=1; $i=$num_pages;) { $number = $i + 20; }

The problem with these two statements was that the loop would be indefinate.
Without the third option $i is never incremented (unless you manually
increment it from within the loop).  So with your examples $i would always
be 1 and would therefore always be = $num_pages unless $num_pages was zero
or negative.

Sincerely,

Craig Vincent



--
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] Feelin' dumb...

2002-05-17 Thread Jason Soza

When I use that, here:

if ($num_pages = 2) {
for ($i=1; $i=$num_pages; $i+=20) {
echo $i;
}
}

I get 1, or whatever I set $i= in the first expression. No other iterations.
When I use Craig's way, it works - kinda. Based on what I'm using this code
in, I should get two iterations. I'm counting the number of rows from my DB,
dividing it by 20, that's the number of pages I have - currently I have 22
records, so 2 pages. Here's what I use for that:

$sql = mysql_query(SELECT * FROM table);
$num_rows = mysql_num_rows($sql);
$num_pages = ceil($num_rows/20);

So why would I only get 1 iteration? 22/20 = 1.2 rounded up to 2. This
satisfies the if ($num_pages = 2) statement and initiates the loop. $i
starts as 1, then should loop once more. If I set $i=0, I echo 0. What
gives?

I may not be able to answer anymore tonight, have to DJ for 4 hours
beginning in about 35 minutes, so I need to get ready for that, but
certainly anymore ideas would be great. Thanks!

-Original Message-
From: Tom Rogers [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 7:40 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Feelin' dumb...


Hi
What you need is
for ($i=1; $i=$num_pages; $i+=20) {
   // print stuff here
}

Tom

At 01:19 PM 18/05/2002, Jason Soza wrote:
Okay, I'm apologizing right now for this, but I hope it's at least
tolerable. I have this:

for ($i=1; $i=$num_pages; $i++) {
 // print stuff here
 }

For each loop, I want to add 20 to $i, so after the first iteration, I have
21, then 41, 61, etc. I've tried $i+20, $i + 20, I've tried looking in the
manual, but I assume this is some C-type function, and I'm not familiar
with
C!

Any helpers?

Jason Soza


--
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] Feelin' dumb...

2002-05-17 Thread Jason Soza

I think I figured this out -

Since I only have 2 pages, the first iteration of the loop sets $i greater
than than the number of pages, i.e. $i becomes 21, which is greater than 2,
so the second iteration stops there. Am I seeing this right?

So Craig's way worked because $i was left alone in the for() expressions and
only modified in the statement, therefore on the second iteration, $i was 2
and thus it satisfied the second expression and iterated once more.

I *think* I'm understanding this correctly, though if others see it
differently, please let me know!

-Original Message-
From: Jason Soza [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 8:24 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Feelin' dumb...


When I use that, here:

if ($num_pages = 2) {
for ($i=1; $i=$num_pages; $i+=20) {
echo $i;
}
}

I get 1, or whatever I set $i= in the first expression. No other iterations.
When I use Craig's way, it works - kinda. Based on what I'm using this code
in, I should get two iterations. I'm counting the number of rows from my DB,
dividing it by 20, that's the number of pages I have - currently I have 22
records, so 2 pages. Here's what I use for that:

$sql = mysql_query(SELECT * FROM table);
$num_rows = mysql_num_rows($sql);
$num_pages = ceil($num_rows/20);

So why would I only get 1 iteration? 22/20 = 1.2 rounded up to 2. This
satisfies the if ($num_pages = 2) statement and initiates the loop. $i
starts as 1, then should loop once more. If I set $i=0, I echo 0. What
gives?

I may not be able to answer anymore tonight, have to DJ for 4 hours
beginning in about 35 minutes, so I need to get ready for that, but
certainly anymore ideas would be great. Thanks!

-Original Message-
From: Tom Rogers [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 7:40 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Feelin' dumb...


Hi
What you need is
for ($i=1; $i=$num_pages; $i+=20) {
   // print stuff here
}

Tom

At 01:19 PM 18/05/2002, Jason Soza wrote:
Okay, I'm apologizing right now for this, but I hope it's at least
tolerable. I have this:

for ($i=1; $i=$num_pages; $i++) {
 // print stuff here
 }

For each loop, I want to add 20 to $i, so after the first iteration, I have
21, then 41, 61, etc. I've tried $i+20, $i + 20, I've tried looking in the
manual, but I assume this is some C-type function, and I'm not familiar
with
C!

Any helpers?

Jason Soza


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


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




[PHP] Making Multiple Pages

2002-05-16 Thread Jason Soza

I have some ideas on how this should be done, but I'm at work and can't 
really test them, so I was thinking maybe I could run it by you all and 
maybe get some feedback and/or new ideas.

I have a PHP/MySQL-generated page that displays image thumbnails. 
Currently, I have a loop that makes a table and table rows, fills the 
rows with the thumbnails, then when there's no more information, it 
completes whatever row it's on with blank td's, then closes the table.

This was working fine, but my site is actually attracting more traffic 
than I originally thought, and I'm getting more image submissions. It's 
getting to where it's no longer practical to arrange all the thumbnails 
onto one page, I need to have like 25 on one page, then have the script 
create a link at the bottom so users can click and see the next 25.

I'm thinking I need to use some kind of row count language in the 
script, i.e. first count how many rows are in the MySQL table, if it's 
less than 25, just display them all. If there's more than 25, display 
only 1 - 25, then create a link to view 26 - 50, etc.

Is that what I need to be looking into? Any other ideas would be 
appreciated. Thanks!

Jason Soza


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




Re: [PHP] Making Multiple Pages

2002-05-16 Thread Jason Soza

Great! I think that's the SQL function I needed.

Now for the PHP part - I'm a bit fo a newbie at writing code, so bear 
with me here. My query string is currently something like:

$sql = mysql_query(SELECT * FROM mytable WHERE color=$color);

So I would modify that to read:

$sql = mysql_query(SELECT * FROM mytable WHERE color=$color LIMIT $i, 
25);

Where $i = 1 To get just the first 25 records. I think I'm confused on 
how to set $i and create links. Would I just initially set $i = 1; 
then make links that point to:

myscript.php?color=redi=25

Then have a $_GET['i'] variable in my script and set $i equal to that?

Your help is appreciated. Thanks again.

Jason Soza

- Original Message -
From: Kevin Stone [EMAIL PROTECTED]
Date: Thursday, May 16, 2002 10:53 am
Subject: Re: [PHP] Making Multiple Pages

 $query = SELECT * FROM mytable LIMIT $i, 20;
 
 Where 20 is the number of rows to retrieve and $i is the starting row.
 
 By incrementing $i + 20 you can do next, prev buttons, or parse 
 the total
 number of rows into page links (prev - 1, 2, 3, 4, 5, 6.. 10.. 20 -
 next).
 
 Search www.mysql.com for more information about using LIMIT in 
 your queries.
 
 -Kevin
 
 - Original Message -
 From: Jason Soza [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, May 16, 2002 12:31 PM
 Subject: [PHP] Making Multiple Pages
 
 
  I have some ideas on how this should be done, but I'm at work 
 and can't
  really test them, so I was thinking maybe I could run it by you 
 all and
  maybe get some feedback and/or new ideas.
 
  I have a PHP/MySQL-generated page that displays image thumbnails.
  Currently, I have a loop that makes a table and table rows, 
 fills the
  rows with the thumbnails, then when there's no more information, it
  completes whatever row it's on with blank td's, then closes 
 the table.
 
  This was working fine, but my site is actually attracting more 
 traffic than I originally thought, and I'm getting more image 
 submissions. It's
  getting to where it's no longer practical to arrange all the 
 thumbnails onto one page, I need to have like 25 on one page, 
 then have the script
  create a link at the bottom so users can click and see the next 25.
 
  I'm thinking I need to use some kind of row count language in the
  script, i.e. first count how many rows are in the MySQL table, 
 if it's
  less than 25, just display them all. If there's more than 25, 
 display only 1 - 25, then create a link to view 26 - 50, etc.
 
  Is that what I need to be looking into? Any other ideas would be
  appreciated. Thanks!
 
  Jason Soza
 
 
  --
  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] Reading dir contents...

2002-05-13 Thread Jason Soza

Use opendir(), readdir(), and closedir() -

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

HTH,

Jason Soza

- Original Message -
From: Ashley M. Kirchner [EMAIL PROTECTED]
Date: Monday, May 13, 2002 9:50 am
Subject: [PHP] Reading dir contents...

 
Take this function:
 
  function randomImg() {
$numargs = func_num_args();
$ImgArray = array($numargs-1);
$arg_list = func_get_args();
$ImgDir = $arg_list[0];
srand((double)microtime()*1234567);
$img = $arg_list[rand(1,count($arg_list)-1)];
while(!$img) {
  $img = $ImgArray[rand(1,count($ImgArray))];
}
return $ImgDir/$img;
  }
 
 
...it assumes two things:  $arg_list[0] is a variable (which 
 is always
 passed) that ends up being $ImgDir, and then there's $arg_list[1-
 n] where 'n'
 is 1 .  Right now, I'm calling this function like so:
 
? echo randomImg(home, bg01.gif, bg02.gif, bg03.gif); ?
 
However, I'd like to change it so that I don't have to specify 
 the image
 names ($arg_list[1..n]), but just the first variable.  I'd like 
 for it to grab
 whatever it finds in that folder (passed as the variable), and 
 use.  This way I
 can have any number of images in that folder without having to 
 edit my pages
 every time to add or remove more.  And what if the image name 
 changes, once
 again I have to manually fix the function call in my pages.
 
Can PHP do this; open that directory, read its contents and 
 use it (if so,
 how?)  Or do I have to go to Perl for this?
 
 --
 W | I haven't lost my mind; it's backed up on tape somewhere.
  +
 
  Ashley M. Kirchner mailto:[EMAIL PROTECTED]   .   303.442.6410 
 x130  IT Director / SysAdmin / WebSmith . 
 800.441.3873 x130
  Photo Craft Laboratories, Inc.. 3550 Arapahoe 
 Ave. #6
  http://www.pcraft.com . .  ..   Boulder, CO 80303, 
 U.S.A.
 
 
 
 -- 
 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: RE: [PHP] Genus who came up with Self Destruct Code Copy Pro tection

2002-05-13 Thread Jason Soza

I think the point of all this, and I'm sure I'll be corrected if I've 
misunderstood, you can spend your time encrypting, obfuscating, 
whatever, but either your program will get distributed as-is, reverse 
engineered, etc. If someone wants to do it, they'll do it.

Using your example, sure, you're not going to leave your door unlocked 
because there are a million lock-pickers out there you know could get 
through your lock. But by locking your door, do you feel safe? Someone 
could come in a glass window as easily as they pick your lock. 
Determined thiefs can get around even the biggest doors with the 
biggest locks. Look at all the bank robberies that have taken place 
over the past century.

I guess the bottom line, you can do what you want with your code, but 
that doesn't make it hack-proof (or anti-distributable!).

Jason Soza

- Original Message -
From: SP [EMAIL PROTECTED]
Date: Monday, May 13, 2002 1:48 pm
Subject: RE: [PHP] Genus who came up with Self Destruct Code  Copy 
Pro tection

 Everyone is arguing that these encoders can be
 cracked.  Does anyone know of one, have you done
 it yourself?  How long did it take?  I mean I'm
 not going to leave my door unlocked cuz someone
 can pick it open.
 
 -Original Message-
 From: Miguel Cruz [mailto:[EMAIL PROTECTED]]
 Sent: May 13, 2002 3:29 PM
 To: Udo Giacomozzi
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Genus who came up with Self
 Destruct Code  Copy
 Pro tection
 
 
 On 13 May 2002, Udo Giacomozzi wrote:
  If the whole thing is designed the right way.
  A copy protection I like for example are
 dongles. Ok, they are not
  applicable to PHP and aren't 100% secure either
 [don't want to start a
  discussion about this now]. But this system
 makes no problems for the
  people that have the dongle.
 
  That was why first came up with this question.
 As a PHP beginner I wanted
  to know if there are elegant ways to make a
 acceptable copy protection.
 
  There seem to be only 3 possibilities:
  - zend encoder
  - a code obfuscator like POBS
  - encrypting the source code and then decrypting
 it in realtime
 
 All of these have weaknesses. And therefore the
 whole exercise is moot. It
 only takes one person with some free time to break
 your protection
 scheme, and then the cat's out of the bag. Once it
 has been broken, it
 will spread and then it won't matter how complex
 your scheme was.
 
 I really doubt there is any software out there
 that isn't being traded by
 high-school kids, even if they have no idea what
 it's for. The only
 exceptions would be something so arcane and
 obscure that nobody ever had
 an interest in cracking it.
 
 miguel


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




RE: [PHP] Genus who came up with Self Destruct Code CopyPro tection

2002-05-13 Thread Jason Soza

For what it's worth, it's been my experience that people that have the 
freetime to hack other people's work find pleasure in hacking other 
people's work, regardless of the time and talent it takes. If they had 
the motivation to write their own programs, they'd have a good 
programming job. Maybe they do anyway, but as it is, they find a hobby 
in 'exposing security flaws' in other's programs.

Jason Soza

- Original Message -
From: Collins, Robert [EMAIL PROTECTED]
Date: Monday, May 13, 2002 2:06 pm
Subject: RE: [PHP] Genus who came up with Self Destruct Code  Copy 
Pro tection

 This thread was started to discuss how a contract programmer can 
 protecthimself from getting ripped of by an dishonest person or 
 company not every
 little hacker in the world.
 
 SNIP
 It only takes one person with some free time to break your protection
 scheme, and then the cat's out of the bag.
 /SNIP
 
 If they had the talent or the free time they would have programmed it
 themselves because most of the time it takes longer to backwards 
 engineer a
 program than it does to write it from scratch.
 
 Robert W. Collins II 
 Webmaster 
 New Orleans Regional Transit Authority 
 Phone : (504) 248-3826 
 Email : [EMAIL PROTECTED] 
 
 -- 
 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] Variable Prob

2002-05-12 Thread Jason Soza

Argh!

I hate it when one little annoying thing starts up right when I think I have
the coding finished! I have the following code:

if($last_name) {
printf(%s
%s'sbrb%s/bbr%s\n/td,$first_name,$last_name,$year,$color);
} else {
printf(%s'sbrb%s/bbr%s\n/td,$first_name,$year,$color);
}

So if the person has a last name in the database, print John Doe's 1990
Red and if they don't, print John's 1990 Red.

This is in a while() statement, and it works except that on one particular
query, the last record that comes up has a NULL value for the last name, but
rather than printing $first_name's it prints $first_name $last_name using
the last name of the previous record!

Am I missing something there? Do I need to clear out a variable somewhere?
It seems like since $last_name isn't even called in the else statement, it
shouldn't even be showing up!

Jason Soza


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




RE: [PHP] Variable Prob

2002-05-12 Thread Jason Soza

Thanks for the debugging tip... Seems that the 'else' statement wasn't being
called at all, so for some reason $last_name was evaluating to true even
though there's a NULL entry for that record/field. I used a different query,
where a person with a NULL last_name showed up first, and the 'else'
statement still wasn't being called but there was no $last_name showing.

Anyway, I added ORDER BY last_name to my mysql_query() statement and for
some reason the 'else' statements started working. Any ideas on why that
would be? I'm glad it works now, but I'm a little confused as to why it
works.

Thanks again.

-Original Message-
From: Miguel Cruz [mailto:[EMAIL PROTECTED]]
Sent: Saturday, May 11, 2002 11:06 PM
To: Jason Soza
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Variable Prob


It would seem the only way this could happen is if $last_name evaluates to
true. Two suggestions:

1) Make some extra change in one of the printf statements so you can see
which one is really being called.

2) If that doesn't illuminate anything, show a little more code.

miguel

On Sat, 11 May 2002, Jason Soza wrote:
 Argh!

 I hate it when one little annoying thing starts up right when I think I
have
 the coding finished! I have the following code:

 if($last_name) {
   printf(%s
 %s'sbrb%s/bbr%s\n/td,$first_name,$last_name,$year,$color);
   } else {
   printf(%s'sbrb%s/bbr%s\n/td,$first_name,$year,$color);
   }

 So if the person has a last name in the database, print John Doe's 1990
 Red and if they don't, print John's 1990 Red.

 This is in a while() statement, and it works except that on one particular
 query, the last record that comes up has a NULL value for the last name,
but
 rather than printing $first_name's it prints $first_name $last_name using
 the last name of the previous record!

 Am I missing something there? Do I need to clear out a variable somewhere?
 It seems like since $last_name isn't even called in the else statement, it
 shouldn't even be showing up!

 Jason Soza


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




RE: [PHP] help with sort problem

2002-05-12 Thread Jason Soza

I actually asked this same type of question not too long ago. Just separate
the name field into first_name and last_name - it'll be better in the long
run. It's not as hard as it sounds - dump your table, use some program that
will read comma delimited stuff and export as tab-delimited (I used Excel),
separate the first and last names, modify your table to have the correct
columns, clear it, add the data back in (LOAD DATA...)

It may require some modification of your scripts you already have, but
really it's just much cleaner this way. I didn't want to do it simply
because I was lazy and using PHP to do this for me seemed to be the easier
choice. It's not, and doing it that way is far from efficient.

HTH,

Jason Soza

-Original Message-
From: John Holmes [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 12, 2002 1:26 PM
To: 'PHP-General'
Subject: RE: [PHP] help with sort problem


You really want to handle this in your database. If you need data to be
in two fields, first name and last name, then put it in your database
that way. Save yourself some time. How easy is it to just add another
text field in your form, and insert one more variable into the
database???

Whatever kind of hack you come up with in PHP is going to be a waste
of time and memory.

---John Holmes...

 -Original Message-
 From: Nick Wilson [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, May 12, 2002 9:23 AM
 To: php-general
 Subject: [PHP] help with sort problem

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hi all,
 I hope someone might help me with a little puzzle...

 I have bunch of db results and one of the fields is 'name',
 I want to see if there are 2 parts to it like FirstName LastName and
if
 so order by the last name.

 I can see explode() being the php function I need here but am a little
 lost as to what will happen if there is only one word in the name var.

 If someone can suggest what I might do that would be great!
 many thanks...
 - --
 Nick Wilson //  www.explodingnet.com



 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.0.6 (GNU/Linux)

 iD8DBQE83pbjHpvrrTa6L5oRAv5XAJsFAXLb0puFyeknXoaGL7rYUHGxVACdHxt8
 ej2/Y56p75z5jZ43DvSbDzo=
 =8rzj
 -END PGP SIGNATURE-


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




[PHP] Layout Help

2002-05-10 Thread Jason Soza

Hey all... I really do want to thank everyone for all the help and 
advice you give. I know my questions sometimes are probably more 
annoying than anything else, but your input really does help.

Anyway, I have a stack of 76 playlists I need to consolidate and 
display. These are from radio shows, so each playlist has the date, the 
name of the radio show, and anywhere from 20 - 27 tracks, artists, and 
albums on them.

I know I could simply stick these into a MySQL database using fields 
like, date, show, track1, artist1, album1, track2, artist2, album2, 
etc. but would that really be efficient and would I be able to use PHP 
effectively to retrieve all that information and display it correctly?

Has anyone out there done a similar project? If so, what was your 
approach? Thanks in advance,

Jason Soza


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




[PHP] Date Q

2002-05-09 Thread Jason Soza

If I have a MySQL field full of dates and other info, and my PHP script
displays all this, how would I isolate the min and max in the date field?
Like I want to print something like:

Information, from 01-03-2001 through 01-03-2002

If someone could give me an example or point me to the manual section that
describes this, that'd be great. Thanks!

Jason Soza


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




RE: [PHP] Date Q

2002-05-09 Thread Jason Soza

Thanks for the code, but I already have:
$result = mysql_query(SELECT * FROM table);

And I use while ($row = mysql_fetch_array($result)) along with extract($row)
to get my data.

It's been my general understanding that querying twice in one script is bad.
How do I incorporate your code into my script w/o querying again?

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 09, 2002 8:59 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Date Q


On Friday 10 May 2002 13:02, Jason Soza wrote:
 If I have a MySQL field full of dates and other info, and my PHP script
 displays all this, how would I isolate the min and max in the date field?
 Like I want to print something like:

 Information, from 01-03-2001 through 01-03-2002

 If someone could give me an example or point me to the manual section that
 describes this, that'd be great. Thanks!

   select min(datefield) as mindate, max(datefield) as maxdate from table;

--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
QOTD:
The only easy way to tell a hamster from a gerbil is that the
gerbil has more dark meat.
*/


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




Re: [PHP] File upload problem

2002-05-07 Thread Jason Soza

For what it's worth, I ran into this the other day, except I'm not 
using the MAX_FILE_SIZE tag in the form. I have a variable set in the 
action script that is set to the max size in KB, I take the user's 
filesize, divide it by 1024 to get it to KB, then run an 'if' statement 
to decide whether to upload it or not.

Anyway, in my php.ini settings, I have a max size of 8M - when I tried 
uploading a 10M file using IE6, the script simply did not execute 
beyond the file upload stage, i.e. it didn't upload the entire file, 
then give me the 'Cannot find server...' page. If I can remember this 
correctly, it just went directly to a white screen, as if there were a 
parse error involved. I checked the error logs and it said that the 8M 
file limit was exceeded. But it did this without waiting for the entire 
file to be uploaded first.

Jason Soza

- Original Message -
From: Jason Wong [EMAIL PROTECTED]
Date: Tuesday, May 7, 2002 8:49 am
Subject: Re: [PHP] File upload problem

 On Tuesday 07 May 2002 19:09, David Freeman wrote:
-Original Message-
Hmm, after a bit of testing I find that the MAX_FILE_SIZE
tag is useless to say the least (probably because no browsers 
 support
  it?)
 
  That's somewhat of a shame I guess but I can hardly claim to be
  surprised - especially as I've just spent much of my time in the 
 last couple of days wrestling with browser rendering 
 compatibility issues for
  a client's web site - from which my only significant conclusion 
 was that
  Netscape sucks.
 
1) you still have to wait for the whole 5MB to be uploaded
2) php sees the MAX_FILE_SIZE setting is exceeded then
discards the file
 
  An opportunity to do something lost - although I guess you might 
 be able
  to do some javascripting to achieve the same.  But then, that 
 wouldn't require you to have the hidden field either.
 
 Done some more tests. The good news is that it seems that browsers 
 can and do 
 respect the limits set on the server (php.ini). For example in 
 php.ini I set 
 the post_max_size to 32M then when I upload a 33M file, the 
 browser has a 
 quick word with the server and ascertains that the file is over 
 the limit and 
 stops.
 
 The bad news is that out of Opera, NN and IE only Opera works 
 properly in 
 this respect. NN uploads the file then gives Network Error: 
 Connection reset 
 by peer. IE uploads the file then gives Cannot find server, page 
 cannot be 
 displayed (!!).
 
 These were quick and dirty tests and should not be taken as gospel.
 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications 
 Development *
 
 /*
 If a man has talent and cannot use it, he has failed.
   -- Thomas Wolfe
 */


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




[PHP] Sorting, sort of

2002-05-06 Thread Jason Soza

I have a 'name' field in a MySQL table that contains people's first and 
last names, i.e. John Smith - but some people may choose not to 
include their last name, so they're just John in the table, or they 
may choose to include themselves and someone else, but not the last 
name, John and Jane.

I'm thinking the easiest way to sort by last name, which is what I want 
to do, is to just go into MySQL and make 'first_name' and 'last_name' 
fields, but if there's a way to do this with PHP that'd be great, so 
then I wouldn't have to mess with the table and data.

Anyhow, I've looked up sort() and asort() in the PHP manual, but I'm 
not sure how I'd go about this. I assume I'd use some kind of function 
to read the 'name' field to the first space, take what it finds after 
the space and put it into an array, then have some if/else statement to 
deal with the lack of a space or the presence of multiple spaces, then 
use sort() on that array. 

Just looking for some guidance, maybe a specific function or bit of 
code. Anything that'd help. Or if this would be more easily addressed 
by reconfiguring my MySQL table, just let me know.

Thanks,
Jason Soza


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




Re: [PHP] Sorting, sort of

2002-05-06 Thread Jason Soza

It's actually not that large of a table, but it'll still be a PITA to 
get all of the data reinserted.

I have about 50 records with the following fields:
'gen', 'year', 'color', 'name', 'email', 'location', 'misc', 'pic1', 'pi
c2', 'pic3', 'pic4'

So basically, I guess I want to rename 'name' to 'first_name', add 
another column for 'last name', then update each record to separate the 
first and last names into their respective columns, eh?

I suppose the easiest way is to save/export the table as a tab-
delimited txt file, make my first/last name changes that way, change 
the layout of the table, then update the table using the new txt file?

Sorry for the newbie (and MySQL) questions - I'm not a programmer or DB 
admin by trade, just volunteered to make a website and got caught up 
with PHP and MySQL. I'm learning, really I am! (And having fun too!)

Jason Soza

- Original Message -
From: 1LT John W. Holmes [EMAIL PROTECTED]
Date: Monday, May 6, 2002 11:46 am
Subject: Re: [PHP] Sorting, sort of

 You _definetly_ want to do this in your database, not with PHP and 
 arrays.Databases are made to do this kind of sorting for you.
 
 I would modify your table first, adding in another column for 
 first_name,then modify your form so that all data going in from 
 now on is correct. The
 hard part will be getting the data you have now into the correct 
 format. How
 big of a table are we talking?
 
 ---John Holmes...


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




Re: [PHP] if cant use header what should i use? or how to dothis?

2002-05-03 Thread Jason Soza

I think it's because you need an absolute URL in there as opposed to 
the relative one you're using, i.e. Location: 
http://www.example.com/menu?pg=news;

Try that, and try looking here:
http://www.php.net/manual/en/function.header.php

HTH,

Jason Soza

- Original Message -
From: Mantas Kriauciunas [EMAIL PROTECTED]
Date: Friday, May 3, 2002 4:59 pm
Subject: [PHP] if cant use header what should i use? or how to do this?

 Hey PHP General List,
 
  I have code like this(code starts at 100 line and has lots of
  outputs):
if($news==del) {
if(!$nr) {
   show_news_menu();
   show_news_del();
} 
else if($nr) { 
  if($do_del) {
$online = 
 @mysql_connect($db_address,$db_user,$db_pass) or die(MySQL Not 
 Connected);mysql_select_db($db_name,$online) or 
 die(NO DATABASE FOUND);
if (!$result = @mysql_query(DELETE FROM news 
 WHERE id = \$nr\) ) {
  echo Query Error;
}
die;
   }
   else if($do_cancel) {
   Header(Location: menu?pg=news);  wrong
   } else {
 show_news_menu();
 show_news_del();
  ECHO SOME HTML STUFF(comments) 
   }
}
 
 }
 
 i have problem with Header, how should i change it? any suggestions?
 is there any other function to redirect? or should i make some
 fucntion my self..or what shoud i do ?
 thanks
 
 :--:
Have A Nice Day! 
 Mantas Kriauciunas A.k.A mNTKz
 
 Contacts:
 [EMAIL PROTECTED]
 Http://mntkz-hata.visiems.lt


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




[PHP] ereg

2002-05-02 Thread Jason Soza

Hoping someone can help me here. I'm working with someone else's code and
I'm not familiar with ereg_replace(), can someone provide me an alternative
to the following?

ereg_replace([^a-z0-9._], ,
ereg_replace ( , _,
ereg_replace(%20, _,
strtolower($original_name;

Basically, I want to enter $original_name and have it come out $new_name,
converting all spaces to underscores, upper to lowercase, and whatever that
first line does. :)

I've read through the manual and what I got was that preg_replace() is
probably faster... Anyhow, I looked up preg_replace() and as a newbie to
PHP, the given examples look like a language all their own.

Thanks,
Jason


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




Re: [PHP] Parse Error - Help? (AGAIN)

2002-04-25 Thread Jason Soza

Sorry for the length of the code, but I felt I described the problem, 
(parse error, last line) and if I hadn't posted the entire code I 
probably would've been asked to. This list can be a little confusing 
for a newbie: just a couple days ago I read someone saying too much 
information is better than not enough and now I'm getting that I 
posted too much. I'm still learning! :)

What does the ! in if(!isset($id)) { $id = 0; } do? I think I get what 
this bit does in general: checks if $id has been assigned anything, if 
it's empty it gets assigned 0. Correct? Then I can use if($id) 
statements later on without having PHP return Undefined Variable 
errors. Right?

Thanks for your help, I'll work on my PHP listetiquette.

Jason Soza

- Original Message -
From: 1LT John W. Holmes [EMAIL PROTECTED]
Date: Thursday, April 25, 2002 5:35 am
Subject: Re: [PHP] Parse Error - Help? (AGAIN)

 I don't have your original code (which, btw, you shoudn't ever 
 post that
 much code without explicitly saying what the error was, what line 
 it was
 one, highlighting that line, and saying what you've done so far), 
 but these
 errors are caused by not giving a default value to a variable, 
 basically.
 If you have something like this:
 
 if($id = 5)
 {
  //whatever
 }
 
 and $id hasn't been assigned a value, then you'll get that 
 warning. In
 previous versions of PHP, you wouldn't get the warning, you'd just get
 FALSE.
 
 So, before you test the value of a variable, or echo the value 
 out, make
 sure you've assigned it something.
 
 if(!isset($id)) { $id = 0; }
 
 Hopefully that's not too confusingit's hard to explain.
 
 ---John Holmes...


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




Re: [PHP] Parse Error - Help? (AGAIN)

2002-04-25 Thread Jason Soza

Yeah, I think I'd rather fix the errors rather than just not see them. 
I'd still know they were there and it'd bug me!

Thanks everyone for your help!

Jason Soza

- Original Message -
From: Nathan [EMAIL PROTECTED]
Date: Thursday, April 25, 2002 9:14 am
Subject: Re: [PHP] Parse Error - Help? (AGAIN)

 I'll second that one... always better to code with 
 register_globals = Off and E_ALL reporting level
 IMHO.
 
 # Nathan
 
 - Original Message -
 From: Philip Olson [EMAIL PROTECTED]
 To: Maxim Maletsky (PHPBeginner.com) [EMAIL PROTECTED]
 
  To stop receiving the messages from undefined variables add this 
 at top
  of your files:
 
  error_reporting(55);
 
 Or better yet, keep as you're doing and develop with E_ALL
 and fix those E_NOTICE errors correctly! ;)
 
 Regards,
 Philip Olson


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




[PHP] Combining Variables

2002-04-24 Thread Jason Soza

Okay, I think this is an easy thing but I can't figure it out:

I have a script that will be uploading (up to) 4 files:
$file1
$file2
$file3
$file4

Each $file variable has associated $original_name, $filesize, and $filename
variables. Each file:

$original_name = $HTTP_POST_FILES['userfile1']['name'];

that gets uploaded needs to 1) have the filename modified:



Jason Soza
'98 Black Grand Cherokee IAMB4U
'92 Classic Red Miata IMB4U2
Juneau, Alaska
http://www.phrog-net.com/miata/


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




RE: [PHP] Combining Variables

2002-04-24 Thread Jason Soza

Well that was embarrassing. I guess [CTRL]+[ENTER] sends mail in Outlook!
Let's try that again:

Okay, I think this is an easy thing but I can't figure it out:

I have a script that will be uploading (up to) 4 files:
$file1
$file2
$file3
$file4

Each $file variable has associated $original_name, $filesize, and $filename
variables. Each file:

$original_name = $HTTP_POST_FILES['userfile1']['name'];

that gets uploaded needs to 1) have the filename modified:

$filename1 = ereg_replace([^a-z0-9._], ,
 ereg_replace ( , _,
 ereg_replace(%20, _,
 strtolower($orig_name;

2) the extension compared to a list of 'forbidden' extensions,
3) the filename compared to filenames already in existence in the upload
directory,
and 4) uploaded.

Can I do this without writing separate filename, extension, existing, and
uploading scripts? Can someone point me in the right direction here?

Thanks,
Jason Soza


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




[PHP] Parse Error - Help?

2002-04-24 Thread Jason Soza

Can someone take a look at this code for me? I'm pretty new to programming,
but looking at it I think it should work. I'm not saying there aren't plenty
of errors, because I'm sure there are. I'm getting a parse error on the last
line, and I can't see any reason for it. All of my ifs and functions are
closed as far as I see. I guess I'm just looking for an unbiased eye here,
I've been staring at this for a couple hours now. If you have comments on to
how I could simplify this code, that'd be great too. Otherwise, I just need
it to get it working. Thanks in advance -

Jason Soza


?php

// general config

$timestamp = date(mdY);
$id = time();
$upload_path = incoming/; // path to your upload directory
$extval_use = 1;// turns on/off extension validation

// mail config

$xmailer = [EMAIL PROTECTED];
$xsender = [EMAIL PROTECTED];
$from = [EMAIL PROTECTED];
$to = [EMAIL PROTECTED];
$subject = Form submission;
$boundary = b.md5(uniqid(time()));

// form config

$name = $_POST[name];
$email = $_POST[email];
$location = $_POST[location];
$color = $_POST[color];
$year = $_POST[year];
$misc = $_POST[misc];

// extension config

$extval = array(php, php3, asp, bat, exe, com, jsp, cfml,
shtml, dtcl);
$filesize_limit_use = 1; // turns on/off size check
$filesize_limit = 2048; // file size limit (in kB)

// messages
$message[fileisbig] = File is bigger than upload limit ( .
$filesize_limit . kB);
$message[invext] = Files of this type are not allowed, sorry.;
$message[incomplete] = Upload is incomplete.;
$message[complete] = Upload succesfully completed.;
$message[uploadbutton] = Upload;
$message[uploadtxt] = File for upload: ;
$message[fileexists] = File already exists;

// Define functions

function filesize_check ($filesize) {

  if($filesize_limit  $filesize) {
 echo pfont color='red'center
  . $message[fileisbig]./font/center/p;
 $rc = 1;
  }

}

function ext_valid ($filename) {

 $extget = substr( strrchr($filename, .), 1);

 $found = in_array($extget, $extval);

 if ( $found ) {
echo pfont color='red'center
   . $message[invext]./font/center/p;

$rc = 2;
}

function file_upload ($filename) {

  if ( file_exists($upload_path.$timestamp.-.$id.-.$filename) ) {
 echo pfont color='red'center
. $message[fileexists]./font/center/p;

  } else {
 if( move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'],
   $upload_path.$timestamp.-.$id.-.$filename) ) {
echo pcenter . $message[complete]./center/p;
 } else {
echo pfont color='red'center
   . $message[incomplete]./font/center/p;
 }

  }
}

function filename_mod ($filename) {
ereg_replace([^a-z0-9._], ,
ereg_replace ( , _,
ereg_replace(%20, _,
strtolower($orig_name;
}

$rc = 0;

if($filesize_limit_use=1) {
  $filesize1 = $HTTP_POST_FILES['userfile1']['name'] / 1024; //filesize
in kB
  $filesize2 = $HTTP_POST_FILES['userfile2']['name'] / 1024; //filesize
in kB
  $filesize3 = $HTTP_POST_FILES['userfile3']['name'] / 1024; //filesize
in kB
  $filesize4 = $HTTP_POST_FILES['userfile4']['name'] / 1024; //filesize
in kB
   }


if ( isset($HTTP_POST_VARS[upload]) ) {


if ($HTTP_POST_FILES['userfile1']['name']) {
$orig_name1 = $HTTP_POST_FILES['userfile1']['name'];
$filename1 = filename_mod ($orig_name1);
filesize_check ($filesize1);
if ( $rc == 0 ) {
if($extval_use=1) {
ext_valid ($filename1);
}
}
if ( $rc == 0 ) {
file_upload ($filename1);
}
}

if ($HTTP_POST_FILES['userfile2']['name']) {
$orig_name2 = $HTTP_POST_FILES['userfile2']['name'];
$filename2 = filename_mod ($orig_name2);
filesize_check ($filesize2);
if ( $rc == 0 ) {
if($extval_use=1) {
ext_valid ($filename2);
}
}
if ( $rc == 0 ) {
file_upload ($filename2);
}
}

if ($HTTP_POST_FILES['userfile3']['name']) {
$orig_name3 = $HTTP_POST_FILES['userfile3']['name'];
$filename3 = filename_mod ($orig_name3);
filesize_check ($filesize3);
if ( $rc == 0 ) {
if($extval_use=1) {
ext_valid ($filename3);
}
}
if ( $rc == 0 ) {
file_upload ($filename3);
}
}

if ($HTTP_POST_FILES['userfile4']['name']) {
$orig_name4 = $HTTP_POST_FILES['userfile4']['name'];
$filename4 = filename_mod

RE: [PHP] Parse Error - Help?

2002-04-24 Thread Jason Soza

Found it - just added another curly brace to the end of the code and it
worked, so I searched up from there and found:

function ext_valid ($filename) {

 $extget = substr( strrchr($filename, .), 1);

 $found = in_array($extget, $extval);

 if ( $found ) {
echo pfont color='red'center
   . $message[invext]./font/center/p;

$rc = 2;
}

This function should have another curly brace at the end. Aha! Thanks for
your help!

Jason

-Original Message-
From: Tyler Longren [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 24, 2002 7:22 PM
To: Jason Soza; [EMAIL PROTECTED]
Subject: Re: [PHP] Parse Error - Help?


Copy and paste the parse error into your e-mail.  Also, try placing another
} at the end of the code.  If you're missing a closing bracket somewhere,
that will take care of it.

Tyler Longren
Captain Jack Communications
www.captainjack.com
[EMAIL PROTECTED]


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




RE: [PHP] Parse Error - Help? (AGAIN)

2002-04-24 Thread Jason Soza

Yike, now I wish I hadn't found it:

[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Wrong datatype for second
argument in call to in_array in beta_up.asp on line 61
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:
upload_path in beta_up.php on line 73
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:
timestamp in beta_up.php on line 73
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:  id in
beta_up.php on line 73
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:
HTTP_POST_FILES in beta_up.php on line 78
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:
upload_path in beta_up.php on line 79
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:
timestamp in beta_up.php on line 79
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:  id in
beta_up.php on line 79
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:
message in beta_up.php on line 83
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:
filename3 in beta_up.php on line 177
[Wed Apr 24 19:42:18 2002] [error] PHP Warning:  Undefined variable:
filename4 in beta_up.php on line 178

What more do I have to do to define variables? I name what each variable is
with normal conventions - what would cause the above error messages? I think
the one that's most disturbing is the in_array() warning, need that to work!

Again, any help would be greatly appreciated!

Jason

-Original Message-
From: Jason Soza [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 24, 2002 7:56 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Parse Error - Help?


Found it - just added another curly brace to the end of the code and it
worked, so I searched up from there and found:

function ext_valid ($filename) {

 $extget = substr( strrchr($filename, .), 1);

 $found = in_array($extget, $extval);

 if ( $found ) {
echo pfont color='red'center
   . $message[invext]./font/center/p;

$rc = 2;
}

This function should have another curly brace at the end. Aha! Thanks for
your help!

Jason

-Original Message-
From: Tyler Longren [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 24, 2002 7:22 PM
To: Jason Soza; [EMAIL PROTECTED]
Subject: Re: [PHP] Parse Error - Help?


Copy and paste the parse error into your e-mail.  Also, try placing another
} at the end of the code.  If you're missing a closing bracket somewhere,
that will take care of it.

Tyler Longren
Captain Jack Communications
www.captainjack.com
[EMAIL PROTECTED]


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




Re: [PHP] If else question

2002-04-23 Thread Jason Soza

I don't know how much this is worth, but it helped me deal with an 
if/else statement that was killing me.

I just coded a very simple if/else statement like so:

?PHP
$a = 1;
$b = 2;

if($a  $b) {
echo A is smaller than B;
}
else {
echo B is smaller than A;
}
?

And I made SURE that worked. Once it did, I started adding things, 
making sure it worked after each change until I got it where I wanted 
it. Once it did what I wanted, I copied it into my working script. 
Sometimes it works to just start over with something simpler, then work 
your way back up.

HTH,

Jason Soza

- Original Message -
From: Jennifer Downey [EMAIL PROTECTED]
Date: Tuesday, April 23, 2002 10:26 am
Subject: Re: [PHP] If else question

 Ok I have hard coded $quantity so it does = 0 and else still prints.
 Maxim Maletsky ) [EMAIL PROTECTED] wrote in message
 004701c1eaf1$c915c6b0$92e3021a@machine52">news:004701c1eaf1$c915c6b0$92e3021a@machine52...
 
  Try this, Jennifer:
 
  Without messing the rest of your code, change the line:
 
  $quantity = $row['quantity'];
 
  With this one:
 
  $quantity = 0;
 
  In other words: hardcode it for testing.
 
  If else always prints, then you are missing something in your 
 query. Otherwise you've got something wrong in your code.
 
 
 
 
 
  Sincerely,
 
  Maxim Maletsky
  Founder, Chief Developer
 
  www.PHPBeginner.com   // where PHP Begins


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




[PHP] Question for Linux users...

2002-04-23 Thread Jason Soza

Don't want to start a war or anything, so e-mail me your responses 
offlist if necessary, but I'd like to know what Linux distro you like 
best and why.

I'm currently using Win2K Pro/Apache as my server platform and... Well, 
after 5 months I remember why I originally had Linux on there. I just 
really like the security that is inherent in Linux. I switched to Win2K 
after doing a major computer overhaul and having Linux installation 
problems at 2am - I wanted to go to bed knowing I had a working system, 
I had a Win2K CD available, so... Plus I could use it as a 3rd client 
in multiplayer games when my little bro came over. It hasn't been BAD, 
I mean it's had excellent uptime, no crashes, no security breeches 
(that I'm aware of), but I'm finding myself longing for Linux!

Anyhow, I've used both Mandrake and Slackware distros, but am now 
leaning toward Debian or SuSe. If you have other suggestions or 
whatever, please share. Remember, NO HOLY WARS! Offlist is okay if you 
think your comments might spark something. :)

Thanks in advance,

Jason Soza


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




Re: [PHP] Question for Linux users...

2002-04-23 Thread Jason Soza

I actually need to apologize for this post. Wasn't intended for this 
list. If you do feel like responding, please offlist.

Sorry,
Jason Soza

- Original Message -
From: Erik Price [EMAIL PROTECTED]
Date: Tuesday, April 23, 2002 1:49 pm
Subject: Re: [PHP] Question for Linux users...

 
 On Tuesday, April 23, 2002, at 05:40  PM, Jason Soza wrote:
 
  Anyhow, I've used both Mandrake and Slackware distros, but am now
  leaning toward Debian or SuSe. If you have other suggestions or
  whatever, please share. Remember, NO HOLY WARS! Offlist is okay 
 if you
  think your comments might spark something. :)
 
 Offlist is actually appropriate for any response to this thread.
 
 
 
 Erik
 
 
 
 
 
 
 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]


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




Re: [PHP] Attachments

2002-04-22 Thread Jason Soza

I actually was using other scripts I'd found, written by different 
authors. I did this to try to save time, but this hasn't been the case.

All I was looking to do was have someone fill out a form, hit submit, 
and I would have the contents of the form e-mailed to me, and any 
attachments would be sent as well.

I think that since that last upload script works and the two scripts 
that sent the attachments via e-mail didn't work, I'm just going to try 
my hand at writing my own script using the mail() function. I'll just 
have the script e-mail me the form contents and upload the files to an 
incoming directory with a timestamp prefix, so I can match the e-mails 
with the uploads. This should be a fairly straightforward task, correct?

Jason Soza

- Original Message -
From: Jason Wong [EMAIL PROTECTED]
Date: Monday, April 22, 2002 0:54 am
Subject: Re: [PHP] Attachments

snip
 1) Did *you* write both the php  perl scripts? Just checking, if 
 you wrote 
 both, then you might have made the same mistake in both ;-) If 
 they're by 
 independent authors then the chances of the same mistake are 
 slightly lower.
 
 2) Just to really confirm that the upload process is not the 
 problem can you 
 try sending a local existing file using your scripts?
 
 3) In your scripts I can't see where the attachments (ie the 
 files) gets 
 encoded to base64. Have I missed something?
 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications 
 Development *
 
 /*
 Who are you?
 */
/snip


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




RE: [PHP] Attachments

2002-04-21 Thread Jason Soza

I haven't been able to identify what process actually truncates the file.
All I know is that it's not my mailserver. I don't believe it's in the
coding either, as both Perl and PHP do this, and both work great otherwise.
Anyhow:

This reads the file from the form:
function get_file($filename){

$return = '';
if($fp = fopen($filename, 'rb')){
while(!feof($fp)){
$return .= fread($fp, 1024);
}
fclose($fp);
return $return;

}else{
return FALSE;
}
}

This adds any files to a list of attachments:
function add_attachment($file, $name = '',
$c_type='application/octet-stream', $encoding = 'base64'){
$this-attachments[] = array(
'body'  = 
$file,
'name'  = 
$name,
'c_type'   
 = $c_type,
'encoding' 
 = $encoding
  );
}

This adds a MIME subpart for the attachment:
function add_attachment_part($obj, $value){

$params['content_type'] = $value['c_type'];
$params['encoding'] = $value['encoding'];
$params['disposition']  = 'attachment';
$params['dfilename']= $value['name'];
$obj-addSubpart($value['body'], $params);
}

This is out of the build mail function, adding the text and attachments to
an e-mail:
case $text AND $attachments:
$message = $this-add_mixed_part();
$this-add_text_part($message, $this-text);

for($i=0; $icount($this-attachments); $i++)
$this-add_attachment_part($message, 
$this-attachments[$i]);
break;

Anything look wrong so far?

Just in case this may help, here's the part of the Perl script that adds
files to the e-mail. This script results in a truncation the same way as the
PHP script:

sub attachFilesToMail {
my $type = shift;
my $msg = shift;
my $hasBody = shift;
my ($key, $file);
while (($key, $file) = each %{$CONFIG{$type}}) {
($debug)  print STDERR examining attachment $key, $file\n;
next unless ($key =~ /(\d+)file/  -f $file);
my $attachNum = $1;
$file =~ m!/([^/]+)$!;
my $filename = $1;
my $mime_type =
$CONFIG{$type}-{${attachNum}mime};
($debug)  print STDERR Attaching a mime type of $mime_type for
$filename ($key)\n;
unless ($mime_type) {
$mime_type = (!$fhBug  -T $file) ? 'text/plain' :

'application/octet-stream';
}
my @stats  = stat($file);
($debug)  print STDERR Attaching $file ($stats[7] bytes)  .
 to email\n;
my $data = { Path = $file,
 ReadNow = 1,
 Filename = $filename
 };
unless ($mime_type =~ /^text\//) {
$data-{'Encoding'} = base64;
}

if (!$hasBody) {
$$msg-data(This is a MIME message with attachments);
}
my $m = $$msg-attach(%$data);
$m-attr(content-type = $mime_type);
}
}
-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 21, 2002 12:10 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Attachments


On Sunday 21 April 2002 06:02, Jason Soza wrote:
 They actually vary as to where they become truncated - some are at 633
 bytes, some are at 1kb. The odd thing is that the PHP script I'm using to
 process the form actually pics up the correct filesize, it reports it to
me
 under a $filesize variable I've setup. It'll report, say
file2_filesize...:
 69147 but the actual attachment is 1kb.

Please post your code.

 Like I said, I have this same problem using both Perl scripts and PHP
 scripts. In php.ini my post_max size is 8M and upload_max_filesize is 2M.
 Looking through the Apache mailing list archives, it looks like others
 running Apache on win32 have experienced the same problems, but there are
 no answers. I'm a little stumped myself!

Have you narrowed down

RE: [PHP] Attachments

2002-04-21 Thread Jason Soza

Hmm... Okay, I used this script I found on hotscripts - it copies the entire
file to the specified directory:

  echo pcenterTrying to upload to: 
 . $upload_path . $filename . /center/p\n;

  if ( file_exists($upload_path.$filename) ) {
 echo pfont color='red'center
. $message[fileexists]./font/center/p;

  } else {
 if( move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'],
   $upload_path.$filename) ) {
echo pcenter . $message[complete]./center/p;
 } else {
echo pfont color='red'center
   . $message[incomplete]./font/center/p;
 }

Now why would this work but the e-mail scripts not?


-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 21, 2002 10:13 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Attachments


On Monday 22 April 2002 01:51, Jason Soza wrote:
 I haven't been able to identify what process actually truncates the file.

This should be the easiest to nail down. Add a bit of code so that when the
file gets uploaded, it gets copied somewhere, then you can manually check
its
size. Obviously, if the filesize is OK then the problem is further down the
line (probably the mail code).

--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
f u cn rd ths, itn tyg h myxbl cd.
*/

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

2002-04-20 Thread Jason Soza

Sorry for the thread thing, I wasn't aware I was causing probs. I usually
just use Reply to save having to enter the e-mail address, just laziness.
I'll keep from doing in this in the future, thanks for letting me know.

I'm using 'POST' in my forms - any other ideas or places I could check?
Thanks again.

Jason

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 8:36 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Attachments


On Saturday 20 April 2002 12:29, Jason Soza wrote:

 Using both Perl and PHP to send mail with attachments from forms, the
 attachments get truncated. Since both Perl scripts and PHP scripts do
this,
 I'm ruling out coding error, and since my mailserver has been receiving
 e-mails from other sources and has transmitted the whole attachments from
 them, I'm ruling it out too. Does anyone know if Apache has some sort of
 limitation on attachments? Is there a setting for this in httpd.conf? I
 don't have any .htaccess files laying around, just httpd.conf and virtual
 hosts. Is there like a max_file_size thing I need to mess with?

If you're using GET in your form(s) change it to POST.

Also, please do not reply to an existing thread and change the subject. This
messes up the threading for those of us who use an intelligent mail client.
Start your own thread.

--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
QOTD:
If it's too loud, you're too old.
*/


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




RE: [PHP] Attachments

2002-04-20 Thread Jason Soza

They actually vary as to where they become truncated - some are at 633
bytes, some are at 1kb. The odd thing is that the PHP script I'm using to
process the form actually pics up the correct filesize, it reports it to me
under a $filesize variable I've setup. It'll report, say file2_filesize...:
69147 but the actual attachment is 1kb.

Like I said, I have this same problem using both Perl scripts and PHP
scripts. In php.ini my post_max size is 8M and upload_max_filesize is 2M.
Looking through the Apache mailing list archives, it looks like others
running Apache on win32 have experienced the same problems, but there are no
answers. I'm a little stumped myself!

I've found that even PHP upload scripts I've gotten from hotscripts.com
don't execute correctly either. A bit discouraging, as this problem is
seriously affecting a website I was hoping to have completed this weekend.

Thanks for your help,
Jason

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Saturday, April 20, 2002 3:32 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Attachments

 I'm using 'POST' in my forms - any other ideas or places I could check?
 Thanks again.

There are a couple of settings in php.ini you could look at:

post_max_size
upload_max_filesize


Have you tried varying size attachments to see at what point the attachments
become truncated?

--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Refreshed by a brief blackout, I got to my feet and went next door.
-- Martin Amis, _Money_
*/


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




[PHP] Truncated files

2002-04-19 Thread Jason Soza

I don't have the code I used right in front of me, so I'm sorry that I 
can't give specifics, but maybe someone may have an idea about this off 
the top of their head.

I have a script that processes a form on my site where people can 
submit information and upload files. The files don't upload to a 
directory; they're attached to an e-mail and sent along with whatever 
information they give.

However, when the e-mail reaches me and I look, the file size is down 
to 646 bytes or so (from a 300kb file) and the file is unreadable. Any 
ideas?

Thanks,
Jason


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




[PHP] Attachments

2002-04-19 Thread Jason Soza

I apologize in advance, this question most likely doesn't belong here, but
if anyone can help that'd be great:

Using both Perl and PHP to send mail with attachments from forms, the
attachments get truncated. Since both Perl scripts and PHP scripts do this,
I'm ruling out coding error, and since my mailserver has been receiving
e-mails from other sources and has transmitted the whole attachments from
them, I'm ruling it out too. Does anyone know if Apache has some sort of
limitation on attachments? Is there a setting for this in httpd.conf? I
don't have any .htaccess files laying around, just httpd.conf and virtual
hosts. Is there like a max_file_size thing I need to mess with?

Again, I apologize for the off-topic nature of this, just looking for some
help.

Thanks,
Jason


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




RE: [PHP] Nasty DoS in PHP

2002-04-18 Thread Jason Soza

Very odd indeed. Well, here's my setup:
Windoze2K
PHP 4.1.2
Apache 1.3.something
Accessing it via IE 6.0, although this should not have any bearing on
anything

I'd be interested in knowing your versions and the versions of the first guy
that posted about this. Maybe he has the same setup as me, or close enough,
but both of us are different from you. My browser just kept loading and
loading like all was well, while task manager was skipping all over the
place and I had to wait 5 - 10 seconds after I moved my mouse for the cursor
to move. I timed the script, and after 30 secs, it was still going (although
I stopped it soon thereafter to keep from having to reboot). So I reset
php.ini's execution time limit down to 5 seconds and ran it twice more, and
both times it went well past 5 seconds.

Of course, none of this bothers me as I won't be putting while(01) {
header(A) } into any of my scripts, nor was I ever planning on it! :)

-Original Message-
From: Jason Murray [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 10:13 PM
To: 'Jason Soza'; [EMAIL PROTECTED]
Subject: RE: [PHP] Nasty DoS in PHP


 Mine produced the same error message as yours, Jason, but the memory
 and CPU usage continued until I hit the 'stop' button on the browser.
 It seemed to have overridden both time and memory limits, as it had
 racked up 320 megs of my RAM by the time I stopped it.

It certainly didn't do that here, but it could be a difference between
RAM, PHP and Apache versions (simple paranoia ;)) that causes it.

PHP clearly sent the error *to my browser* and the browser stopped loading
immediately (thus, the fatal error was indeed fatal, and PHP terminated
at that time).

J


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




RE: [PHP] Displaying Results

2002-04-17 Thread Jason Soza

I used this workaround - if you see something inherently wrong with it, let
me know:

printf(a href='http://www.mydomain.net/index.asp?type=%s%s=%s'b%s/b
(%s)/abr,$by,$by,$$by,$$by,$total)

So that the output goes like a
href=http://www.mydomain.net/index.asp?type=type1type1=value;type 1
(total#)/a

And that gets passed to this:
$type = $HTTP_GET_VARS[type];
$value = $HTTP_GET_VARS[$type];
$result = mysql_query(SELECT * FROM cars WHERE $type ='$value');

Little more work, but is this safe to use? It's been working great!

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 16, 2002 9:58 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Displaying Results


On Wednesday 17 April 2002 08:21, Jason Soza wrote:
 Sorry, I just noticed that the count() function will do at least the
 first part of my question, i.e. SELECT year, COUNT(*) FROM cars GROUP
 BY year

 But the second part still has me a bit stumped. I know that you can
 pass a variable using something like script.php?year=1991, but doesn't
 that assume that in your script you have something like:
 $query = (SELECT * FROM mytable WHERE year=$year)

 So the $year is the only variable that gets replaced by the script.php?
 year=1991 you called it with. How could I make it so that the
 entire 'year=$year' part of the query gets replaced by what comes after
 the ? in script.php?year=1991  ?

You can do something like:

  script.php?qry=year%3D1991

%3D is the url encoding for '='.

Then in your script:

  $query = (SELECT * FROM mytable WHERE $qry)


--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
The chief danger in life is that you may take too many precautions.
-- Alfred Adler
*/

--
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] Arranging Data

2002-04-17 Thread Jason Soza

How would I have a script display results in a table, but make it so 
that once 3 or 4 results are displayed in one table row, a new table 
row would be started?

Right now I have something like:
printf(img src='%s'br,$pic1);

And all the records for $pic1 come out into a single column which, if I 
had many records, could get unwieldy. I'm looking to do something like:
print(table);
print(tr);
printf(tdimg src='%s'/td,$pic1

Where instead of one table row being created with endless td's, the 
printf() function would print just 3 records, then another 'tr' tag 
would be printed to start a new row, where printf() could print the 
next 3 records, and so on. Is this possible?

Thanks in advance,
Jason


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




Re: [PHP] Nasty DoS in PHP

2002-04-17 Thread Jason Soza

For what it's worth, I just ran this script on my server, and despite 
the 30 second time limit and 8mb memory limit in php.ini, the script 
ran longer than 30 secs, CPU usage went between 60% and 100% and my 
memory usage reached 352000 before I stopped it.

As far as a DoS, I don't think so. A bug? Possibly. Bad coding? Yep. :)

Jason Soza

- Original Message -
From: CC Zona [EMAIL PROTECTED]
Date: Wednesday, April 17, 2002 6:21 pm
Subject: Re: [PHP] Nasty DoS in PHP

 In article p05100304b8e3cee5ab0c@[210.49.237.250],
 [EMAIL PROTECTED] (Richard Archer) wrote:
 
  At 8:55 PM -0400 17/4/02, Justin Farnsworth wrote:
  
  This is a rather meaningless thread.  It is a
  security issue that is displaced.
  
  If PHP is not honoring the time limit and memory usage directives
  when outputting headers, then this is a bug in PHP.
 
 A big if, since the OP has not yet verified that the time limit 
 and 
 memory limit are in effect at the outset of the loop as supposed.  
 Someone 
 else want to test for this scenario?  Someone, that is, who can 
 deliberately bring down their server without getting kicked off 
 permanently?
 Meanwhile...
 
  If this allows a DoS attack, then this is a very real security 
 problem.
 Why should it?  Even if there is a verifiable bug allowing 
 time/memory 
 limits to be exceeded when header() goes into an infinite loop, 
 how could 
 someone exploit this from the outside?  If a scripter is letting 
 any random 
 web visitor put their script into an infinite loop, then the 
 results are at 
 *least* as much the scripter's fault as PHP's.  Ditto for the 
 scripter who 
 sets the infinite loop himself while allowing the web user to 
 specify what 
 function gets executed in the loop.  And if neither of these is 
 happening, 
 then where's the DoS?  As has already been pointed out, someone 
 bringing 
 down their own server with their own code, isn't a DoS.  It's 
 usually poor 
 coding, and _possibly_ (see above) attributable to a bug, but it's 
 not a 
 DoS.
 
 As far as I can tell, the only security problem here is the usual 
 one: 
 figuring out who is clueful enough and responsible enough to be 
 trusted 
 with access to operations which can compromise the server.
 
 Whether there is a bug or not remains an open question.  I'll be 
 curious to 
 hear whether anyone is able to reproduce a server crash in spite 
 of 
 set_time_limit(30) and ini_set(memory_limit,8M) conditions.
 
 -- 
 CC



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




RE: [PHP] Nasty DoS in PHP

2002-04-17 Thread Jason Soza

It shows the memory and CPU time being used by apache. I have PHP 
installed as a module, that may be why. (?)

Jason Soza

- Original Message -
From: Martin Towell [EMAIL PROTECTED]
Date: Wednesday, April 17, 2002 6:37 pm
Subject: RE: [PHP] Nasty DoS in PHP

 Is that memory usage used by PHP or apache?
 
 -Original Message-
 From: Jason Soza [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 18, 2002 12:35 PM
 To: CC Zona
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Nasty DoS in PHP
 
 
 For what it's worth, I just ran this script on my server, and 
 despite 
 the 30 second time limit and 8mb memory limit in php.ini, the 
 script 
 ran longer than 30 secs, CPU usage went between 60% and 100% and 
 my 
 memory usage reached 352000 before I stopped it.
 
 As far as a DoS, I don't think so. A bug? Possibly. Bad coding? 
 Yep. :)
 
 Jason Soza


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




RE: [PHP] Nasty DoS in PHP

2002-04-17 Thread Jason Soza

Interesting, check out my apache error log:
[Wed Apr 17 18:35:53 2002] [error] PHP Fatal error:  Maximum execution time
of 30 seconds exceeded in d:\html\loop.asp on line 7

So PHP recognized the max execution time of 30 seconds being exceeded, but
neither it nor apache shut down the script.

Jason

-Original Message-
From: CC Zona [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 7:04 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Nasty DoS in PHP


Do you have a PHP binary compiled too?  If Apache can be taken out of the
equation and the script still exceed memory/time limits, that would sure
appear to be a PHP bug. (FWIW, I can't find an existing bug report about
this behavior at bugs.php.net.  Perhaps you and the OP could run backtraces
and open a new bug report?)


In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Soza) wrote:

 It shows the memory and CPU time being used by apache. I have PHP
 installed as a module, that may be why. (?)

 Jason Soza

 - Original Message -
 From: Martin Towell [EMAIL PROTECTED]
 Date: Wednesday, April 17, 2002 6:37 pm
 Subject: RE: [PHP] Nasty DoS in PHP

  Is that memory usage used by PHP or apache?
 
  -Original Message-
  From: Jason Soza [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, April 18, 2002 12:35 PM
  To: CC Zona
  Cc: [EMAIL PROTECTED]
  Subject: Re: [PHP] Nasty DoS in PHP
 
 
  For what it's worth, I just ran this script on my server, and despite
  the 30 second time limit and 8mb memory limit in php.ini, the script
  ran longer than 30 secs, CPU usage went between 60% and 100% and my
  memory usage reached 352000 before I stopped it.

--
CC



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




RE: [PHP] Nasty DoS in PHP

2002-04-17 Thread Jason Soza

Mine produced the same error message as yours, Jason, but the memory and CPU
usage continued until I hit the 'stop' button on the browser. It seemed to
have overridden both time and memory limits, as it had racked up 320 megs of
my RAM by the time I stopped it.

Jason

-Original Message-
From: Jason Murray [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 9:57 PM
To: 'CC Zona'; [EMAIL PROTECTED]
Subject: RE: [PHP] Nasty DoS in PHP


 So that was both as an Apache mod and a CGI binary?  Sounds like it's
 reproducible.

Running as an Apache module here, it terminated as expected at 30 seconds.

Jason


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




[PHP] Displaying Results

2002-04-16 Thread Jason Soza

Suppose I want a script that goes into a table, looks up all records in 
a given field, and groups and displays the results like so:
match1 (1)
match2 (5)
match3 (6)

So basically it looked at the field 'matches' and found a total of 12 
records, 1 record for match1, 5 records for match2, and 6 records for 
match3. It would also be handy for the output to be a link so when you 
clicked on it, it would pass a query on to the database querying for 
just that particular field, like:
SELECT * FROM table WHERE match=match1

Can someone point me in the right direction for this? Or show me an 
example script that would accomplish this? Any help would be great. 
Thanks a lot!

Jason



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




Re: [PHP] Displaying Results

2002-04-16 Thread Jason Soza

Sorry, I just noticed that the count() function will do at least the 
first part of my question, i.e. SELECT year, COUNT(*) FROM cars GROUP 
BY year

But the second part still has me a bit stumped. I know that you can 
pass a variable using something like script.php?year=1991, but doesn't 
that assume that in your script you have something like:
$query = (SELECT * FROM mytable WHERE year=$year)

So the $year is the only variable that gets replaced by the script.php?
year=1991 you called it with. How could I make it so that the 
entire 'year=$year' part of the query gets replaced by what comes after 
the ? in script.php?year=1991  ?

Thanks in advance 
Jason

- Original Message -
From: Jason Soza [EMAIL PROTECTED]
Date: Tuesday, April 16, 2002 2:49 pm
Subject: [PHP] Displaying Results

 Suppose I want a script that goes into a table, looks up all 
 records in 
 a given field, and groups and displays the results like so:
 match1 (1)
 match2 (5)
 match3 (6)
 
 So basically it looked at the field 'matches' and found a total of 
 12 
 records, 1 record for match1, 5 records for match2, and 6 records 
 for 
 match3. It would also be handy for the output to be a link so when 
 you 
 clicked on it, it would pass a query on to the database querying 
 for 
 just that particular field, like:
 SELECT * FROM table WHERE match=match1
 
 Can someone point me in the right direction for this? Or show me 
 an 
 example script that would accomplish this? Any help would be 
 great. 
 Thanks a lot!
 
 Jason
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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




[PHP] PHP/MySQL Query Prob

2002-04-15 Thread Jason Soza

Hey... new to the list, but didn't have time to lurk and watch the traffic,
kind of in a bind here. I apologize in advance if I do something wrong...

Using this code:
?php
$link = mysql_connect()
or die(Could not connect);
mysql_select_db(mydb) or die(Could not select database);

$result = mysql_query(SELECT * FROM cars WHERE year=1991);
extract(mysql_fetch_array($result));

while ($row = mysql_fetch_object($result)) {
$generation = $row-generation;
$year = $row-year;
$owner = $row-owner;
$email = $row-email;
$pic1 = $row-pic1;
$tmb1 = $row-tmb1;
printf(img src='%s'br, $pic1);
printf(small%s/smallbr,$generation);
printf(b%s/bbr,$year);
printf(%sbr,$owner);
printf(a href=mailto:'%s'%s/ap, $email, 
$email);
printf(a href='%s'img src='%s' border=0/ap, 
$pic1, $tmb1);
}

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);
?

I'm successfully able to retrieve and display information for year='1991'.
It works great. However, if I replace '1991' with any other year that I KNOW
there's a matching record for, I get no results. So if I were to replace
year='1991' with year='1990', no results would be produced although the same
query given directly in MySQL will give results. Make sense? This same
problem happens with other fields too, it seems really selective. I can use
WHERE color='red' and get results, but color='black' returns nothing,
although there are matching records. Taking out the WHERE in the above code
will return all but the first record in the table. I fixed that just by
putting a dummy record first, but that still shouldn't be happening.

Any ideas? I need to get this fixed but I'm not sure what's wrong!

Thanks in advance,
Jason
(PHP 4.1.2 Win32)
(MySQL 3.23 Win32)


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