Re: [PHP] does your mail() base64 encode messages?

2005-03-19 Thread John W. List
 Try mail([EMAIL PROTECTED],test script,Foo!);

Thanks very much for your suggestion- It did not fix the problem but
it provided a pointer to a workaround.

It appears that my host base64 encodes message bodies if any sort of
header- even an empty one- is supplied. This is a problem the sysadmin
is looking into but for now I have to live with it.

The empty header caused mail() to put a \n in between the headers and
the MIME headers for the base64 encoded stuff. This in turn caused
mail readers to view the message as a plain text message that happened
to contain a base64 encoded string so the recipient saw gibberish.
Removing the empty header resulted in a plain text message, putting a
valid header in the headers parameter caused the mail to be viewed by
the mail reader as a normal base64 encoded message and thus readable
by the recipient. Unfortunately mail()'s habit of doing this base64
encoding precludes me from doing anything with MIME multipart messages
because all the multipart separators, HTML etc become visible as plain
text, but at least I can send emails containing plain text.

And so to the commercial application which originally showed up this
problem. Its mail code had an extra \n at the end of its headers.
Removing this made it possible for it to send plain text emails,
albeit base64 encoded ones, from this host. I've used this application
from quite a few other customers hosts in the past so this \n is not
normally a problem, but I've never used a host that exhibits this
behaviour. As well as removing this \n I had to comment out the lines
that sent multipart emails but at least now I'm in business.

As to the problem itself, I'm none the wiser. As I see it it can only
be either PHP or Sendmail that is doing this. I've never had this or
any other version of PHP do this to me before but since as I
understand it Sendmail is only being used as a mail relay here I cant
place the blame anywhere else but a possible bug in PHP 4.3.10's
mail() function. It's not a bug, it's a feature!:)

I guess it's all extra experience.
John W. List

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



[PHP] does your mail() base64 encode messages?

2005-03-18 Thread John W. List
I have an unexpected and perplexing problem.
PHP's mail() function is base64 encoding all message bodies as an
ill-formed MIME attachment resulting in the recipient seeing an
uninteligable base64 encoded string. This only happens to my account
with my host and neither I or the sysadmin can see why as there are no
special configuration settings for me. The host is running PHP4.3.10.

Here's what is happening:
This code
?php
mail ( [EMAIL PROTECTED], test script, Foo!, ); 
?

Results in this mail being recieved.

(message starts here)
Delivered-To: [EMAIL PROTECTED]

snip all the SMTP Recieved: headers for clarity/

To: [EMAIL PROTECTED]
Subject: test script
Message-Id: [EMAIL PROTECTED]
Date: Fri, 18 Mar 2005 10:33:06 + (GMT)
From: [EMAIL PROTECTED] (httpd)

Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: BASE64

Rm9vIQ==
(message ends here)

On every other PHP host I've used I would have expected a simple
string Foo! instead of the Mime-version stuff and the base64 encoded
string.

I'm sure I can get round this if I have to by using one of the PHP
mail classes that are out there. But I'd prefer not to as one of the
pieces of software I'm using is commercial and if I alter it I'll
invalidate my support for it.
Has anyone else seen this problem? I'd be interested to know what's happening.
John W. List

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



Re: [PHP] sessions not working when page redirects

2004-08-10 Thread John W. Holmes
From: Angelo Zanetti [EMAIL PROTECTED]
 Im having a slightly weird problem with my session variables. when on a
 certain page call it A, I register a session variable and assign it a
 value. I then test if it is registered successfully and has the correct
 value on the same page, that works no problem. After that page A
 redirects to page B:

 header(Location: ../admin/include/B.php);

This should be a complete URL to begin with:
http://www.yourdomain.com/whatever/admin/include/B.php

 After this I do the exact same test on page B to test for successful
 registration and value and I get that the session variable is not
 registered. on page B I do have session_start(); at the top. I even do
 2 tests to on the session variable:

Using IE?

Try using session_write_close() right before you redirect with the header()
and be sure to put exit() directly after header(). Should look like this
anytime you want to redirect.

session_write_close();
header(...);
exit();

If that doesn't work, then pass the session ID in the URL when you redirect
like someone else mentioned.

---John Holmes...

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



Re: [PHP] SQL Functions

2004-08-10 Thread John W. Holmes
From: Dan Joseph [EMAIL PROTECTED]
  In order to get all of the data back you are going to have to loop
  through it and return the array so that it will be available for
  manipulation.
 
 Hmm.. I suspected this might be the case.  I have modified my
 functiona  bit:
 
 function selectRows( $sql )
 {
 $count = 0;
 
 $results  = mysql_query( $sql, DB::connect() );
 
 while ( $data = mysql_fetch_array( $results ) )
 {
 foreach ( $data as $name = $value )
 {
 $array[$count][$name] = $value;
 }
 
 $count++;
 }
 
 return $array;
 }

Change that to:

$array = array();
$results  = mysql_query( $sql, DB::connect() );
while($data = mysql_fetch_array($result))
{ $array[] = $data; }

return $array;

No need to loop through $data. 

---John Holmes...

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



Re: [PHP] PHP/MySQL based webmail?

2004-08-10 Thread John W. Holmes
From: raditha dissanayake [EMAIL PROTECTED]

 What has squirrelmail/horde scalability got to do with PHP?

Is this the mantra of the PHP list, now? Come on... those are both programs
written in PHP and discussing how better one is over the other is perfectly
good traffic for this list. I'd be very interesting in seeing cold hard
numbers as for which one scales better.

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



Re: [PHP] SQL Functions

2004-08-10 Thread John W. Holmes
From: Dan Joseph [EMAIL PROTECTED]
  Of course, this begs the question of why you're re-implementing what
  has been done so many times in the past.
 
  http://pear.php.net/package/DB
  http://pear.php.net/package/MDB
  http://pear.php.net/package/MDB2
  http://adodb.sourceforge.net/
  http://www.phpclasses.org/browse/package/20.html

 I'm building a class for use with our PHP applications.  Packages
 like what you've linked me to are nice, but we need a little flexibility
 here, so we're writing a few methods of our own.

So have your class extend one of these and only rewrite what they do not
implement. That's one of the big ideas behind OO programming.

The procedure your original question was about is already implemented in
ADOdb, for example:

http://phplens.com/lens/adodb/docs-adodb.htm#getall

---John Holmes...

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



Re: [PHP] PHP5 OOP

2004-08-10 Thread John W. Holmes
From: Joel Kitching [EMAIL PROTECTED]

 Hello, I'm trying to get the hang of OOP here but can't quite figure
 out how to relate these classes.  I've got one for the main project,
 one for the database, and one for a user.  Somehow I need to get the
 user access to the database, without cumbersome constructor calls
 involving a copy of the instance of the class itself.

 // main project class
 class gfusion {
 protected static $db;
 function __construct() {
 $this-db = new db;
 }
 }


 // database class
 class db {
 private $link;
 private $query;
 private $result;
 ...
 function query($query);
 function fetch_row();
 function fetch_rows();
 ...
 }


 // user class
 class user {
 private $id;
 private $group_id;
 private $login;
 private $password;
 /* Somehow I need to get the db class instance here. */

 function __construct($id = false) {
 if (is_numeric($id)) {
 print_r($this);
 $this-db-query('SELECT * FROM user WHERE id = ' . $id);
 $user_info = $this-db-get_row();

 $this-id = $user_info['id'];
 $this-group_id   = $user_info['group_id'];
 $this-login  = $user_info['login'];
 $this-password   = $user_info['password'];
 }
 }
 ...
 }


 I tried extending the user class from the project class, but that
 didn't work, because the $db var was empty.  I tried changing it to
 static, but it didn't inherit the $db variable for some reason.  So,
 how can I make this work, so I can write a bunch of classes that can
 blindly use $this-db or something similar without having to worry
 about setting it in the constructor?  I thought about setting it as a
 global, but that didn't seem very... OOP.

See here: http://www.php.net/manual/en/language.oop5.decon.php

and note this: Note: Parent constructors are not called implicitly. In order
to run a parent constructor, a call to parent::__construct() is required.

---John Holmes...

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



Re: [PHP] Cannot redeclare function

2004-08-10 Thread John W. Holmes
From: Alex Hogan [EMAIL PROTECTED]
 I have a registration page that hasn't changed in several weeks.  Today
 it decided to freak-out by throwing an error;
 'Cannot redeclare myfunctionname() on line 10 of myfunctions.inc'

 Nothing has changed in either the calling page, or the function.  The
 only thing that has changed since these files were put into production
 is the upgrade on php to 5.

Did your error_reporting level change with the upgrade? This was more than
likely silently ignored with PHP4 and now showing as a warning/error in PHP5
or just dependent upon your error_reporting level.

---John Holmes...

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



Re: [PHP] Re: php tools

2004-08-10 Thread John W. Holmes
From: Jay Blanchard
 Open http://www.google.com in the browser of your choice
 Type PHP IDE in the little box that appears there.
 Click on the links of returned results.

I clicked on all of the links and nothing happened except for some web pages
appearing. Now what?

---John Holmes...

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



Re: [PHP] download script

2004-08-10 Thread John W. Holmes
Aaron Todd [EMAIL PROTECTED] wrote in message

  $file = /home/dlr/test/.$_GET['file'].;

 Why would this be a security hole if I do not filter the file

 name before I use it?

http://www.yourdomain.com/yourfile.php?file=../../path/to/any/file/on/machine

---John Holmes...

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



Re: [PHP] complex array and smarty

2004-08-09 Thread John W. Holmes
From: adwinwijaya [EMAIL PROTECTED]
 Assume I have array that looks like :

 Array(
 'type'-'Fiction',
 'notes'-'Fiction books from a-z',
 'list'- Array(
  'list'-  [0]-array(
   'title'-'xzy',
   'id'-'1')
[1]-array(
   'title'-'abcd',
   'id'-'2')
)
 )

 Now, I want to display it using smarty os it looks like

 ---
 Books Result:
 
 1. Type: Fiction
Notes: bla bla bla bla
--
ID |   Title
--
1  | xzy
2  | abcd
--
 2. Type: Non-Fiction
Notes: bla bla bla bla
--
ID |   Title
--
3  | ABCDEFEGH
4  | LALALALLA
--
 can I do like that with smarty ? and how to do that ?
 I knew to use array, but for this array, I dont know how to do that

You need to come up with a better way to format that array based on how you
want to display it. You can then use {foreach}

http://smarty.php.net/manual/en/language.function.foreach.php

---John Holmes...

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



Re: [PHP] Working with a new design client

2004-08-09 Thread John W. Holmes
From: charles kline [EMAIL PROTECTED]

 I have never used Smarty, which I understand might be a big help in
 these situations. One concern of mine is that I have a tight budget on
 this project and don't want to spend a lot of time learning a new
 system unless I have to.

Smarty is one solution, but the concept you need to employ is separating
your display (mainly HTML) from your business logic (the PHP classes). Make
them separate files and then they only edit the templates and don't touch
your PHP code. You can make them plain HTML pages and just include() them,
read them and eval() them, or use any templating solution. It's going to be
the best way to do this.

Probably telling you what you already know, but it sounded like you just
needed to be told it! ;)

---John Holmes...

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



Re: [PHP] How PHP handles multiple inclusions of the same file?

2004-08-09 Thread John W. Holmes
From: Justin Patrin [EMAIL PROTECTED]
  eval($script);
  use_cached_code();

 Ick! eval() is evil!

You have benchmarks to back that up or experience?

I did a benchmark between using include(), eval(), smarty, pattemplate, and
a few others and include() and eval() are always the fastest.

Really depends upon what kind of features you need and what you consider
evil. ;)

---John Holmes...

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



Re: [PHP] Browsers on terminal server

2004-08-05 Thread John W. Holmes
From: Lester Caine [EMAIL PROTECTED]
 I am using
 $_SERVER[REMOTE_ADDR]
 to get address of the browser accessing the system and then using
 gethostbyaddr() to get the machine name.

 This worked great until I came to a site using M$ Terminal Server to
 provide the terminals. We still need to know what machine we are talking
 to, so we can identify the room, and flag the correct set of displays,
 but $_SERVER[REMOTE_ADDR] seems to be giving only the IP address of
 the TS machine.

 Anybody been here already. Is it possible to identify the terminal that
 is browsing on the other side of TS. Any pointers to some help to
 restore operation in this situation.

I really doubt it. I'd recommend searching MSDN for some answers. If it was
available to PHP, you'd see it on a phpinfo() screen or somewhere in
$_SERVER, but I doubt it is.

---John Holmes...

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



Re: [PHP] What does \\0 means?

2004-08-05 Thread John W. Holmes
From: John Nichel [EMAIL PROTECTED]
On Thursday 05 August 2004 07:39, Jay offered up the following tid-bit of
information :
 Found the following code in the PHP manual:
 $text = http://www.somelink.com;;
 echo(ereg_replace([[:alpha:]]+://[^[:space:]]+[[:alnum:]/],
  a href=\\\0\\\0/a, $text));

 What does \\0 means, i have seen this before with \\1 and \\2

 Well, I'm not much of a ereg guy...more preg, but if I had to take a
guess,
 the \\0 in ereg is like $1 in perl regular expressions.  ie it's replacing
 the \\0 with the first match found in the expression.  Run the
script...I'm
 betting it will out put...

 a href=http://www.somelink.com;http://www.somelink.com/a

 Course, if I'm wrong, someone on the list will be quick to lay the smack
 down on me, and you'll get the correct answer. ;)

oo.ooo... can I do it?? ;)

\\0 is actually the entire string that was matches. \\1 would be the first
parenthesized substring, \\2 the second, etc.

Don't worry, I had to look in the manual to be sure, too. :)

---John Holmes...

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



Re: [PHP] Passing user entered data to DB

2004-08-05 Thread John W. Holmes
From: Jordi Canals [EMAIL PROTECTED]
 John Holmes wrote:

  $uservar = htmlspecialchars(strip_tags($uservar));
 
  You don't need to use strip_tags _and_ htmlspecialchars()... unless you
  want strip_tags to get rid of such malicious and deadly content such as
  grin and wow. Just use htmlspecialchars().

 Well, my idea was to apply both: I do not want to get any tag in the
 user input and prevent showing the html tags in the later output. For
 that I've applied strip_tags()

 To apply htmlspecialchars() after that Is done to convert double quotes,
 and ampersand to html entities. Not appliying it has two efects: Strings
 with quotes does not show correct in input boxes. Strings with
 ampersands do not pass the W3C validator. And just to convert lt and gt
 signs when used alones like ... 5  2.

 Just that are my reasons to apply both: Security and get a clean string.

There's no added security by using strip_tags and you're just removing
content that the user wanted to include. I guess it depends upon what this
text is. If you apply htmlspecialchars() to a string that contains HTML,
Javascript code, etc, the code will not be evaluated, so there is no
security risk.

I don't know what the purpose of the text your recieving is, but if I
entered Use an img tag for that and you stripped out img, it would
suck. If you just applied htmlspecialchars(), then when you redisplayed my
text, either in regular HTML or in a text box, then you'd see exactly what I
entered. The img text would not be evaluated as HTML and no actual image
box would be shown.

If you can't tell, I _hate_ the strip_tags function as it needlessly removes
content and the allowable_tags gives a false sense of security.

---John Holmes...

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



Re: [PHP] How pass form variable to window.open()

2004-08-05 Thread John W. Holmes
From: CHAN YICK WAI [EMAIL PROTECTED]

 in the form, for example, i have input type=text.. name=student ...

 and input type=button onClick=window.open('url?student=$student', )

 It seems to me not working.

Define not working because that's how you do it. Well, actually, you need
to echo $student, unless this whole thing is already in an echo

---John Holmes...

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



Re: [PHP] dynamic RAM file for real media

2004-08-05 Thread John W. Holmes
From: Daniel Guerrier [EMAIL PROTECTED]

 I am using PHP to dynamically create real audio links.
 The question is I was creating one .ram file for each
 real media file that I wanted to stream.  The .ram
 files need to have absolute urls (which I do not
 like).  I saw a few sites that use one .ram file but
 pass it a variable http://url.ram?id=555.

Never done it, but I'd guess that the server would be set up for PHP to
parse .ram requests (at least in this directory). Then, from within PHP
you'd grab the $id value, locate the appropriate real audio file, send the
appropriate headers and then readfile() the audio file.

---John Holmes...

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



Re: [PHP] How pass form variable to window.open()

2004-08-05 Thread John W. Holmes
From: CHAN YICK WAI [EMAIL PROTECTED]

 How about if this $student is actually a text field, when this html
 generated by php script, it has no value, so the onClick line is
 ...url?student=$student without value, when I click, it reads nothing,
how
 should I do?

Javascript.

---John Holmes...

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



Re: [PHP] filling out HTML forms

2004-08-05 Thread John W. Holmes

- Original Message - 
From: Amanda Hemmerich [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, August 05, 2004 12:39 PM
Subject: [PHP] filling out HTML forms


 So, we are trying to design an account management page that allows users
 to manage all of their computer accounts in one place.  We want to allow
 them to change their passwords for all of their accounts in one place,
 unfortunately, we don't have access to one of the machines to change their
 password.  This machine has a web form available that allows users to
 change their passwords online, and we were hoping to somehow use the
 information that the users entered on our form to fill out the other form.

You can use cURL or one of the PEAR classes to have your PHP script fill out
the form on the remote computer... will take some work, but it's possible.

Actually, you could just simulate a POST / GET request to the file that
handles the form processing instead of actually attempting to fill out the
form. Again, cURL and some PEAR classes will help here.

---John Holmes...

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



Re: [PHP] Why do I keep getting a 501 mail error?

2004-08-05 Thread John W. Holmes
From: Brian Dunning [EMAIL PROTECTED]

 Developing on a Windows server to be deployed on Linux. I get SMTP
 server response: 501 Bad address syntax. Here's my code:

 $mail_from = 'My Name [EMAIL PROTECTED]';
 $mail_server = 'mail.servername.com'; // This is hosted externally
 ini_set(SMTP, $mail_server);
 ini_set(sendmail_from, $mail_from);
 $mail_to = $first_name $last_name $email;
 mail($mail_to, Here is my subject, Please click this link to
 activate your  account:\n\n$http_root.owner.php?id=$entry_code, To:
 $mail_to\nFrom: $mail_from\nContent-type: text/plain\nMailer:
 PHP/.phpversion());

 I read about trying \r\n instead of \n in the headers, but it didn't
 seem to make any difference, and \n is working on other mail actions on
 this same server.

 Thanks for any clues...  :)

The first step is to see if you can send a mail using a very basic call to
mail(), simply: mail('[EMAIL PROTECTED]','subject','message');

If that works, then you can move on by slowly adding the code you have
above.

Why do you have two To: headers? That'll mess things up. remove the one from
the extra headers parameter.

---John Holmes...

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



Re: [PHP] Log transaction for audit

2004-08-05 Thread John W. Holmes
From: CHAN YICK WAI [EMAIL PROTECTED]

 I'm writing an application that requires log every transactions users
done,
 e.g. update which record, delete which record, something like that.

 I guess one way is whenever I issue a mysql_query(), I also insert this
 query in whole into another table together with the user name, so I can
log
 and retrieve it out for audit.

 Will you have that kind of experience? How can I do it comprehensively,
e.g.
 no too big additional coding effort, easy to manage, reliable, etc.

Sounds like you just need to write a wrapper for mysql_query() that logs
what's going on.

function my_mysql_query($query)
{
log_query($query);
return mysql_query($query);
}

and use my_mysql_query() everywhere instead of mysql_query.

---John Holmes...

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



Re: [PHP] filling out HTML forms

2004-08-05 Thread John W. Holmes
From: John Nichel [EMAIL PROTECTED]:
  You can use cURL or one of the PEAR classes to have your PHP script fill
  out the form on the remote computer... will take some work, but it's
  possible.
 
  Actually, you could just simulate a POST / GET request to the file that
  handles the form processing instead of actually attempting to fill out
  the form. Again, cURL and some PEAR classes will help here.

 But the OP would still have to have access to at least the HTML of the
other
 form right?  cURL can't fill out form on another site if the HTML isn't
set
 up to do it, can it?

 like :
 input type=text name=foo /
 vs.
 input type=text name=foo value=?php echo ( $foo ); ? /

You'd have to know what elements are in the form. You wouldn't actually fill
out the form, just create the appropriate request to the page that does the
form processing. As simple as a URL if it's method is get or using
cURL/PEAR classes/contexts to create the post request.

---John Holmes...

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



Re: [PHP] Log transaction for audit

2004-08-05 Thread John W. Holmes
From: Jason Wong [EMAIL PROTECTED]
 On Friday 06 August 2004 01:47, John W. Holmes wrote:

  Sounds like you just need to write a wrapper for mysql_query() that logs
  what's going on.
 
  function my_mysql_query($query)
  {
  log_query($query);
  return mysql_query($query);
  }
 
  and use my_mysql_query() everywhere instead of mysql_query.

 If that is indeed what is required just simply use MySQL's own logging
system.
 Only feasible if you have control of the MySQL server, MySQL manual for
 details.

True. http://dev.mysql.com/doc/mysql/en/Binary_log.html

I assume there's probably some application level information that'd need to
be logged also, that probably isn't contained in the query.

---John Holmes...

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



Re: [PHP] periodic file writing error (fputs)

2004-08-05 Thread John W. Holmes
From: Sarah Gray [EMAIL PROTECTED]
 Once a sale is completed a record is written to a log file on the
 server.
 
 $filename = $dir. /. $logType._.$today..txt;
 $fp = fopen($filename, a+);
 fputs($fp, $logEntryStr);
 fclose($fp);

Consider this:

1. User A completes a transaction.
2. Script A reads the log file
3. User B completes a transaction
4. Script B read the log file
5. Script A write the new line to what was read in #2
6. Script B write the new line to what was read in #4

Now what's in the file? Only what Script B wrote.

http://us2.php.net/flock

---John Holmes...

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



Re: [PHP] Re: POST superglobal is empty

2004-08-04 Thread John W. Holmes
From: Dan Phiffer [EMAIL PROTECTED]
 Jason Davidson wrote:

  How about
  print_r($_REQUEST);

 That also fails to reflect posted data. $_GET is working as expected.

There's nothing in PHP that would not let POST values get through. Are you
sure this isn't a web server issue only allowing GET requests to pages that
it serves?

---John Holmes...

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



Re: [PHP] multiple checkboxes

2004-08-03 Thread John W. Holmes
From: Robert Sossomon [EMAIL PROTECTED]

 You need to do:
 input type=checkbox name=checkBoxGroup1 value=first/
 input type=checkbox name=checkBoxGroup2 value=second/

 Keeping the name the same makes them a RADIO button and you will only
 get the last one.

This is a valid solution, but it's really just easier to make them into an
array like many others have suggested. Using this method, you would need to
loop through all of the possible checkBoxGroupX values to see which ones
were checked or get a list or count of them. Making them into an array makes
it as simple as count($_POST['checkBoxGroup']) or
implode(',',$_POST['checkBoxGroup']), etc...

---John Holmes...

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



Re: [PHP] pconnect...

2004-08-02 Thread John W. Holmes
From: bruce [EMAIL PROTECTED]

 since pconnect is not supported in php5, i'm wondering if the issue is
that
 mysql no longer supports the underlying functions to implement pconnect,
or
 if the decision to leave it out was based upon other factors.

 also, is there anybody i can talk to who has looked at the actual code
 within the earlier php4 regarding the pconnect issue?

Are you still on this issue? pconnect() doesn't do what you think it does.
If you want to write you're middle-man database connection manager then
you can use the regular connection method.

---John Holmes...

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



Re: [PHP] Re: php inventory control software

2004-08-02 Thread John W. Holmes
From: John Nichel [EMAIL PROTECTED]
 Steve Douville wrote:
  Take a look at www.oscommerce.com

 Does oscommerce still require register_globals to be on?

 http://php.resourceindex.com/Complete_Scripts/Shopping_Carts/

Even if it does, you can't instantly equate that as being a Bad Thing. I'm
sure you know this, but for other's sake, you can program securely even if
you have register_globals ON... you just have to know what you're doing and
use good programming practices.

The register_globals setting doesn't matter... it's whether you choose to
accept the programmers code as being secure enough for your needs or not.

;)

---John Holmes...

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



Re: [PHP] COUNT(*) Output Question

2004-08-02 Thread John W. Holmes
From: Tom Ray [Lists] [EMAIL PROTECTED]

 $count=mysql_query(SELECT sku, COUNT(*) FROM orders GROUP BY sku);

 But my question is how do I use PHP to output the COUNT(*) results? When
 I run the command when I'm logged into mySQL I get the following:

I assume you're fetching associative arrays from the result and $r['sku']
works, but you're not sure how to get the COUNT(*) value? Well,
$r['COUNT(*)'] would work, but you could also use an alias:

SELECT sku, COUNT(*) AS mycount FROM orders GROUP BY sku

and then use $r['mycount'] to retrieve the value (after using
mysql_fetch_assoc/array, of course).

---John Holmes...

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



Re: [PHP] multiple checkboxes

2004-08-02 Thread John W. Holmes
From: Josh Close [EMAIL PROTECTED]

 Very simple question.
 
 When making multiple checkboxes, you put the name the same for a few
 to group them together
 
 form action=process.php method=post
 input type=checkbox name=checkBoxGroup value=first /
 input type=checkbox name=checkBoxGruop value=second /
 /form
 
 So they are grouped but then submitting them I only get the last
 value check.
 
 ? print_r($_POST); ?
 
 How would I get all the boxes check when grouping them by using the
 same name for all checkboxes in the name field?

Make them an array:

input type=checkbox name=checkBoxGroup[] value=first /
input type=checkbox name=checkBoxGruop[] value=second /

Note the [] on the name.

---John Holmes...

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



Re: [PHP] PHP - mySQL query question

2004-07-25 Thread John W. Holmes
Karl-Heinz Schulz wrote:
I have a simple question (not for me).
Why does this query does not work?
$links_query = mysql_query(select id, inserted, title, information,
international from links WHERE international = y; order by inserted desc
LIMIT 0 , 30);
The information for the international fields are:
Field: international
Type: char(1)
Null: No
Default:n
The error is - Warning: mysql_fetch_row(): supplied argument is not a valid
MySQL result resource in
Your query has failed. You'd know this if you checked mysql_error() 
after running your query.

$result = mysql_query(...) or die(mysql_error())
Your query fails because you need quotes around the y and you need to 
remove the semi-colon.

$links_query = mysql_query(select id, inserted, title, information,
international from links WHERE international = 'y' order by inserted 
desc LIMIT 0 , 30) or die(mysql_error());

Also, why are you selecting the international column when you're 
filtering the results to rows that have y for international. You 
already know what international is, why select it in your query?

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: PHP editor that doesn't require installation

2004-07-24 Thread John W. Holmes
rush wrote:
John W. Holmes [EMAIL PROTECTED] wrote in message
Does anyone know of a good windows PHP editor that I can run from a USB
flash drive without installing it? 
scite, from the scintilla fame. TemplateTamer would also work fine if you
just copy the whole directory
Scite is perfect. You rock. A single 364KB file with PHP source code 
highlighting, brace matching, (regex) search and replace and more. It's 
so perfect I won't even make fun of you for mentioning TemplateTamer 
again! ;) Thanks, though, seriously.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Unexpected T_ENCAPSED...

2004-07-24 Thread John W. Holmes
Philip Olson wrote:
And quoting integers is not a problem, I even prefer it.  IMHO we should
tell people to quote all values so if someone forgets to do any sort of
input validation (i.e. make sure it's actually an integer) there won't be
a major problem otherwise problems (including SQL injection) may arise.
I wouldn't recommend that you recommend that to everyone. Not all 
databases will allow you to enter a STRING into an numeric field. MySQL 
may be lenient on it, but that doesn't mean you should get in the habit 
of using it that way. Properly validate your data and none of this is an 
issue. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Fwd: IMPORTANT: Please Verify Your Message

2004-07-24 Thread John W. Holmes
Jason Wong wrote:
 On Sunday 25 July 2004 09:42, Mark wrote:
[EMAIL PROTECTED], [EMAIL PROTECTED] is currently

 You've got the culprit here. Either lambast him publically (since he 
doesn't
 want to receive your private mail). Or do what this says:

The thing is, though, none of these people have actually signed up for 
this service as far as I can tell. It's like there's a spamcease bot 
signed up to the list and is sending out these notices to people that 
post to the list saying that some random address has signed up for it. 
It's saying the list is signed up and people are receiving messages 
saying themselves are signed up when they know they haven't.

I really wish we could get an active admin on the list that would react 
to these sorts of things. I'd volunteer, but I don't think anyone cares 
besides the people actually on the list.

All that being said, I just trash these, anyhow. :)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] log.

2004-07-23 Thread John W. Holmes
Ulitin S.S. wrote:
I am learning php.
I need to log all actions on my page. (like ip, browser, time, pages etc).
question is: how can i identify a user and when he is on my page(s)  to log
all his actions.
Your web server already does all of this, why duplicate it? Just get a 
log analyzer.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Using Post like Get

2004-07-23 Thread John W. Holmes
Dennis Gearon wrote:
With get varaibles, it's possible to always have get variables on a 
page, even without a form, by simply appending the Get variables to the 
end of the URL.

Is there anyway to do the same with Post variables? For instance, a 
javascript that onUnload submit, or something?
You can't just include POST variables in a link, if that's what you're 
going for. Perhaps some clunky javascript submitting a hidden form on an 
onclick method would get you close, but why even bother?

Maybe you should just say what you're actually trying to achieve and 
why, then we could offer better alternatives.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Using Post like Get

2004-07-23 Thread John W. Holmes
Dennis Gearon wrote:
What I'm trying to achieve is to have the same cookie IDENTIFY a user on 
different (or same) applications (on the same server), but require them 
to log in for each application, and get a different session.. Basically, 
to keep separate 'user trails and in process variables' for different 
tabs or windows in a browser.
Can't you just set $_SESSION['application_name']['loggedin'] = TRUE for 
the various applications? If they are accessing application widget, 
then checking for isset($_SESSION['widget']['loggedin']) will tell you 
whether they are logged in or not. Or am I missing something?

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] HTML Escaping

2004-07-23 Thread John W. Holmes
Robb Kerr wrote:
I've got a conditional button that needs to appear/hide on my page
depending upon the contents of a field in my database. The button is an
image and has a long URL and JavaScript for image rotation attached to it.
Needless to say, the href is quite long and includes several '
characters. My conditional works great but I want to know if there is an
easy way to escape the whole href so that the ' characters will not be
seen as PHP quote marks. See below...
?php
if ($recordset['field'] != 1) {
echo 'a href=# onMouseOut=MM_swapImgRestore()
onMouseOver=MM_swapImage('PreviousPage','','/URL/ButtonName.gif',1)img
src=/URL/ButtonName.gif alt=Previous Page name=Previous Page
width=150 height=20 border=0/a;
?
It looks like you're trying to echo a string that's delimited by single 
quote marks, but I don't see a single quote at the end of the string. 
Assuming this is what you want, though, to escape single quotes within 
the string you're trying to echo, put a backslash \ character before them.

?php
if ($recordset['field'] != 1) {
echo 'a href=# onMouseOut=MM_swapImgRestore()
onMouseOver=MM_swapImage(\'PreviousPage\',\'\',\'/URL/ButtonName.gif\',1)img
src=/URL/ButtonName.gif alt=Previous Page name=Previous Page
width=150 height=20 border=0/a';
?
Alternatively, you can just use double quotes in your JavaScript 
MM_swapImage() function...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Include path

2004-07-23 Thread John W. Holmes
PHP Gen wrote:
Hello,
I am a bit confused :-(, this is my server path:
/home/sites/site80/web/articles/myfile.php
from myfile.php I want to include header.php which
is located in:
/home/sites/site80/web/templates/
include('/home/sites/site80/web/templates/header.php');
Are you looking for a relative path or wondering why 
include('header.php') doesn't work, or what?

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Converting regional decimal numbers

2004-07-23 Thread John W. Holmes
C.F. Scheidecker Antunes wrote:
I have a few users that use a different number format, other than the US 
one, which is 1.526,23 . That is, the comma is used as a separator for 
the fractional part of the number (.23) and the dot is used to separate
thousands. Therefore, I need to convert 1.526,23 to 1,526.23, invert the 
comma and the dot. Some numbers are formated correctly so nothing needs 
to be done, while other need that.

I have writen a function to perform that but it reads char by char and 
has test cases. I first check the position of the dot and the comma. It 
one is higher than the other than I need to convert, if not than I do
nothing. I would like to make it simpler and more efficent and for that 
I need some help from some of the PHP regex experts.
Store the raw number, 1234.56 and then use number_format() to add the 
appropriate commas and periods. You can tailor the number_format() call 
to the user so they get the numbers in the format they like.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PHP editor that doesn't require installation

2004-07-23 Thread John W. Holmes
Does anyone know of a good windows PHP editor that I can run from a USB 
flash drive without installing it? A good stand-alone editor. I know how 
to use Vi, so I'll even take a copy of that (so long as it's got syntax 
hightlighting) so long as installation isn't required.

For everyone else, yes, I know what editor you use, so you don't have to 
tell me. I agree that what you use is the best editor ever. No, really. 
Honest. ;)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] run perl script with php

2004-07-22 Thread John W. Holmes
Tassos T wrote:
i faced a small problem i have a perl script but i want to execute that 
in a php script. unfortunately i cannot convert to php.
virtual()
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] smpt server requiring authentication

2004-07-22 Thread John W. Holmes
Chris Hunt wrote:
anyone know how to configure php's outgoing mail to use a smtp server that
requires authentication?
Can't. Use an SMTP class from phpclasses.org (Manuel will be on here 
soon, I'm sure ;) or PEAR.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] textarea/display question...

2004-07-21 Thread John W. Holmes
Dennis Gearon wrote:
Make sure to remove tags via:
$var_that_will_be_displayed = strip_tags( 
$var_from_user_input_via_POST_or_GET_or_COOKIE );

if you are going to display or mail it as part of a link(email or URL), 
you might do this instead:

$var_that_will_be_part_of_a_link = strip_tags( rawurldecode( 
$var_from_user_input_via_POST_or_GET_or_COOKIE ) );

See this page:
http://www.cgisecurity.com/articles/xss-faq.shtml
Yeah, use strip_tags so you can get rid of evil, malicious content such 
as grin... gasp! Just use htmlentities() like others have already 
suggested, so you don't change the users input. There's nothing more 
annoying than programs that strip out content from what users write 
because they think it's bad. Using allowed_tags with strip_tags() just 
introduces the possibility for vulnerabilities since attributes aren't 
checked. Javascript in a b tag, you say? Yep...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] URL

2004-07-21 Thread John W. Holmes
Bruno Santos wrote:
Im developing a couple of pages and i need to do some redirecting to 
another page depending
on the choice of a user.
The problem is, to go to another page, i need to send some parameters in 
the URL that are alredy present, but i need to make the redirecting 
independent of the page. if i use $_SERVER['PHP_SELF'], i have only 
http://some_domain/the_page
and what i want is 
http://some_domain/the_page?some_parameters=valueanother_parameter=value
the ?some_parameters=value are alredy present and i need to redirect 
them again...

I know that are some fuctions to manage this, or not...
any solucion ??
How about $_SERVER['QUERY_STRING']?
That _should_ contain the current query string with the values still 
encoded, but I'm not sure on that. If they aren't still encoded, then 
just rebuild the query string by looping through $_GET.

$url = $_SERVER['PHP_SELF'] . '?';
foreach($_GET as $key = $value)
{ $url .= '' . $key . '=' . urlencode($value); }
If you have arrays within $_GET, then you'll need a recursive function, 
but hopefully one of the above will work for your needs.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] echo and html_decode

2004-07-21 Thread John W. Holmes
Karl-Heinz Schulz wrote:
I'm  trying to use html_decode with the echo function but failed so far.
? echo mysql_result($product, 0,1) ?
What would be the correct syntax?
Huh? I don't see html_decode anywhere and the function is 
html_entity_decode(), anyhow.

If you want to run the above through the function, then:
?php echo html_entity_decode(mysql_result($product,0,1)); ?
Otherwise we'll need some more information. My crystal ball is currently 
loaned out.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] trim() white space from record set

2004-07-21 Thread John W. Holmes
msa wrote:
I created a search form with multiple search parameters.  It returns nothing
if there is a space after their text entry or if they hit return in the text
area.
$coltitle_rsResults = 0;
if (isset($_GET['Title'])) {
$_GET['title'] = trim($_GET['title']);
  $coltitle_rsResults = (get_magic_quotes_gpc()) ? $_GET['Title'] :
addslashes($_GET['Title']);
where do i put the trim?
See above. You have to assign the result of trim() to a variable. My 
crystal ball (it's back off of loan now) says that was the issue. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Error when using HTTP Location header

2004-07-21 Thread John W. Holmes
Chris Shiflett wrote:
There is a difference between works and right 
Man... where have I heard that before?!? ;)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] change value of session variable?

2004-07-21 Thread John W. Holmes
Five wrote:
Is it possible to assign a value to a session variable on say, page1.php:
$_SESSION['favcolor'] = 'blue';
and then on another page, say page2.php reassign the value:
$_SESSION['favcolor'] = 'green'; ?
So far experimentation says no.
PHP says Yes. Crystal ball says to put session_start() on page2.php
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Line breaks again....

2004-07-21 Thread John W. Holmes
PHP User wrote:
I have managed to get the line breaks to show up on my site no problem, but
I still get one long line when it is sent to my email. I have looked and
looked and have read all the stuff I could find on \r\n, so I'm not sure
where to go from here since it's not working...
Are you viewing HTML email or plain text? Using \r\n or \n will work 
fine in most email viewers. Are you sure you're not stripping the \n 
from the text to show it with br in HTML and then screwing up the 
presentation in email? Hard to tell what you're doing without any 
code... hint hint...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Firefox - IE differences

2004-07-21 Thread John W. Holmes
Karl-Heinz Schulz wrote:
The following codes open the links perfect.
print($press[1]. a target=_blank href=..\PDF/$press[3]
class=\press_links\.strip_tags(html_decode($press[2]))./abr);
1. Use quotes around your attributes.
target=_blank href=.
2. Why are you mixing / and \ in your path? Why not send an absolute 
path to the file so there's no confusion?

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: change value of session variable?

2004-07-21 Thread John W. Holmes
Chris Shiflett wrote:
--- Five [EMAIL PROTECTED] wrote:
That did it! I wonder if there is a way, then, to have it work even if
the variable is initialized after it is echoed.
You see, that makes no sense, and that's why no one else was able to
answer your question. Code is executed in order. Consider this:
Maybe some custom output buffer will make it work!? :)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP] Re: change value of session variable?

2004-07-21 Thread John W. Holmes
Five wrote:

page1.php
?php
session_start();
echo 'page #1br';
echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'green';
echo 'bra href=page2.phppage 2/a';
?

page2.php
?php
session_start();
echo 'page #2br';
echo $_SESSION['favcolor'];
$_SESSION['favcolor'] = 'blue';
echo 'bra href=page1.phppage 1/a';
?

This code works exactly the way it's supposed to!! No value first time, 
then rotating value!!

If it does not work for you, are you sure you're accepting the session 
cookie? How are you sure? Do you have a valid session.save_path? How do 
you know? Are you displaying errors? How do you know? If you see an SID 
in the URL when navigating the pages, does it stay the same between 
pages or change?

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: change value of session variable?

2004-07-21 Thread John W. Holmes
Five wrote:
John W. Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]

If it does not work for you, are you sure you're accepting the session
cookie? How are you sure? Do you have a valid session.save_path? How do
you know? Are you displaying errors? How do you know? If you see an SID
in the URL when navigating the pages, does it stay the same between
pages or change?

If you had read my replies you would know how I know.
And, oh yeah, if you're not a troll, how would I know?
Answer the questions if you want help.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Money format

2004-07-20 Thread John W. Holmes
Luk Moravec - PTV Servis wrote:
is there any function wich can format a double or string into money
format.for example: 1526789,99 to 1.526.789,99 or something like that.?
number_format()
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] textarea/display question...

2004-07-20 Thread John W. Holmes
bruce wrote:
textarea value='$foo'/textarea
Please review your HTML textbook. There is no value attribute for a 
textarea.

textarea$foo/textarea
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Problem of a beginner with Array

2004-07-20 Thread John W. Holmes
Henri Marc wrote:
I want to make a lottery site (just as an exercise), so I made a page with 6 grids of 50 numbers each (check boxes).
 
Now, I want to know which numbers have been checked by the player.
I have a :
input name=Grid1 type=checkbox
for the first grid. Grid2 for the grid #2...
 
I was thinking to get the numbers chosen by the player with $_POST['Grid1[]']
Grid1 being a table but it doesn't work. I thought I wouldn't have to declare an array. I have 50 numbers for each grid, I don't want to have to type array followed by the 50 numbers. There is not a way to do something like array(1...50).
 
What is the solution?
Name them like this:
input type=checkbox name=Grid[1]
input type=checkbox name=Grid[2]
etc...
Then, you can use array_keys($_POST['Grid']) to get the numbers checked.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] textarea/display question...

2004-07-20 Thread John W. Holmes
bruce wrote:
ps.. to you guys who said that the textarea doesn't have a value=''.. it
does...
No, it doesn't. Pleae upgrade your textbooks.
http://www.w3.org/TR/html4/interact/forms.html#h-17.7
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] file_exists() to search for *.xml file with a wild card???

2004-07-20 Thread John W. Holmes
Scott Fletcher wrote:
I would like to use the file_exists() or something similar to check for the
existance of any of the xml files regardless of what filename it use.   Like
file_exist(*.xml) for example.  Anyone know??
Try glob()
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] string filtering

2004-07-20 Thread John W. Holmes
C.F. Scheidecker Antunes wrote:
I need to filter some strings. They can only contain characters like 
a...z or A..Z and 0..9. Some strings have blank spaces, -,./?, 
characters that must be discarded. I wrote a function to check each and 
every character but I guess there must be something else more efficient.

Any suggestions?
To get rid of them:
$newstring = preg_replace('/[^0-9a-zA-Z]/','',$oldstring);
To detect them:
if(preg_match('/[^0-9a-zA-Z]/',$string))
{ echo 'bad characters present'; }
else
{ echo 'string okay'; }
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] get all except 1

2004-07-20 Thread John W. Holmes
Dan McCullough wrote:
Haven't done this in a while, but here is my question.
I have 4 stories, and you land on the story page where one story is shown
and on the side there is a listing of the other 3 stories that are active in
that edition.
So what I would like to do in one query is get the three that are not shown
on that page.
So can I do something like
$story_sql=SELECT * FROM story WHERE approved = 1 AND editionId = $eid
EXCEPT nid = $nid;
$nid is the id of the story whos detail page we are on
SELECT * FROM story WHERE approved = 1 AND editionID = $eid AND nid  $nid
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] get all except 1

2004-07-20 Thread John W. Holmes
Dan McCullough wrote:
Anything wrong with
SELECT * FROM story WHERE approved = 1 AND newsId != $newsId AND editionId =
$eid ORDER BY newsSortOrder ASC
Should be fine if I understand your question correctly. You can use != 
or ; same result.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Print page without images

2004-07-19 Thread John W. Holmes
francesco[AT]automationsoft[DOT]biz wrote:
I know that it is a simple and maybe elementary 
question, but there is in PHP a function, like print 
or echo, that print only the text of an HTML page on printer?
No. Use CSS.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] old guy newbie needs some help

2004-07-18 Thread John W. Holmes
Bob Imperial wrote:
Warning: session_start(): open(/tmp\sess_ff8651f382492ae56f436690d81ff124,
O_RDWR) failed: No such file or directory (2) in
c:\inetpub\wwwroot\phptest\listing10.1.php on line 15
You just need to set session.save_path in you php.ini file or use 
session_save_path() before you call session_start(). Either way, the 
path needs to be set to a valid path on your machine that the web server 
has access to read and write from. It looks like you're using IIS, so 
either set up the directory so Everyone can read/write from it or the 
IUSR_computername user, which is what IIS runs as.

You are getting the error because PHP is looking for a /tmp folder (by 
default) which doesn't exist on your machine.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] [Q] Regex Woes

2004-07-18 Thread John W. Holmes
Michael T. Peterson wrote:
I need to find all lines that begin with the string 'WAZ' after reading from
a url (http://www.atmos.washington.edu/data/zone_report.KSEW.html). While
I've tried every combination of expressions under the sun (using the
functions preg_match(), ereg()), I can not figure out a correct regexp for
this task.
This works. Read the entire file into a string (file_get_contents() 
works great here) and pass to this regex. $matches[0] will have your 
lines that start with WAZ. Example:

?php
$file = asdf asdf asdf
WAZ this is line 1
asdf asdf asdf asdf
WAZ this is another line that should be matches
fWAZ this is a line that shouldn't be matches
WAZ one more for good measure
and a bad one WAZ (whoa, who put that there!)
asdf
 asdf asd fas df asdf;
preg_match_all('/^WAZ.*/m',$file,$matches);
print_r($matches[0]);
?
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Form Field Validation

2004-07-18 Thread John W. Holmes
Harlequin wrote:
Just wondering if there's a quick and easy way to validate form fields using
PHP.
Not really that concerned with actual content by using REGEX but want to
ensure users have at-least bothered to put something in and if not display
an error with the form field's name maybe.
empty()
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Error: unexpected T_ELSE on line 14...?

2004-07-18 Thread John W. Holmes
Harlequin wrote:
  if ($_SESSION[Authorised]=Yes);
You know this will _always_ be true, don't you?
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Is Function Constants the Correct Term?

2004-07-17 Thread John W. Holmes
Curt Zirzow wrote:
* Thus wrote gohaku:
Hi everyone,
I have been experimenting with defining functions as constants.
Below is what I am using to test Function Constants:
pre
?
define(LOGIN,user);
define(PASS,pass);
define(DB,mysql);
define(DBLOGIN,dblogin(LOGIN,PASS,DB));

This is simply not allowed.
see:
  http://php.net/define
damn... I had just rewritten my entire application to use this!!
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Need help with line breaks in a textarea form

2004-07-16 Thread John W. Holmes
PHP User wrote:
Hi,
I have been trying to format the textarea output and have come across some
code that almost does what I need, but I still have one small problem.
Look at the text below that was input into my textarea:
Now is the time for all young men to come to the aid of the party. Now is
the time for all young men to come to the aid of the party.
Testing
Now is the time for all young men to come to the aid of the party. Now is
the time for all young men to come to the aid of the party.
Testing.
When I print this out to my webpage it has a line break before and after the
word Testing. I want it to be a wysiwyg - so in the case above there should
be no extra line breaks. It should look exactly as typed.
The code I tried to change the \n to BR are:
$text2= nl2br ($text); 
or
$text2 str_replace(\n,br,$text);

This is what I have in my form.
textarea rows=10 cols=51 name=texttextarea
textarea rows=10 cols=51 
name=text?=htmlentities($text2)?/textarea

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Getting the primary key from a MySQL insert

2004-07-16 Thread John W. Holmes
Andrew Wood wrote:
Thanks.  When it says 'the last insert' is that just the last insert my 
PHP script did, or the last insert on the DB as a whole?
Read the links Daniel just sent out.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Need help with line breaks in a textarea form

2004-07-16 Thread John W. Holmes
PHP User wrote:
Something came to mind as soon as I sent my last email, and it seems to
work. Not sure it will work in every circumstance but the few tests I tried
seemed ok. This is what I did. I added the two following lines to my script.
$text=str_replace(\n,br,$text);
$text=str_replace(br /,,$text);
Okay... let's say you have $text that is text that was entered into a 
textarea. To put it _back into_ a textare, you simply need to do this:

textarea rows=5 cols=50?=htmlentities($text)?/textarea
That's it. If you want to display $text to the user outside of a 
textarea, then you do this:

echo nl2br(htmlentities($text));
If you want to insert $text into a database and magic_quotes_gpc is 
enabled, you do this:

$query = INSERT INTO yourtable (textcolumn) VALUES ('$text');
If magic_quotes_gpc is not enabled (you can check with 
get_magic_quotes_gpc(), btw), then you'd use this:

$text = addslashes($text);
$query = INSERT INTO yourtable (textcolumn) VALUES ('$text');
If you'd like to extract the winning lottery numbers from $text, you 
simply...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Echoing Results in a Table

2004-07-16 Thread John W. Holmes
Harlequin wrote:
I've managed to develop a query which pulls a finite number of records from
a table based on a query.
What commends do I now use to present these results in a table...?
How would you show a table now with a single record? Start there. Now, 
what areas would need repeating with a finite number of records? Those 
elements should be in a loop, either FOR, FOREACH or WHILE, more than 
likely.

If you don't know how to run your query and extract the results, then 
you've got some reading to do. Check the PHP manual; there are user 
comments that walk you through everything.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] quotes in text.

2004-07-16 Thread John W. Holmes
Ed Curtis wrote:
I'm having some difficulty with quotation marks, both single and double,
input via a textarea in a form.
Here's and example of text.
Trying out the Special Character thing.
Page 1 is the form.
Page 2 is the data shown back to the user.
original POST data is not touched. NO stripslashes
original typed text is show to the user by stripslashes($thistext)
original POST data is transferred to next page via hidden input field
without stripping slashes.
Page 3 posts the data to a MySQL database.
original POST data is not touched. No stipslashes.
Text gets cut off in database (Trying out the)
What exactly do I need to do to the text so that any quotation marks
(single or double) get input into the database.
Let's say you have $_POST['text'] from the user.
To display the value back to the user with magic_quotes_enabled, you'd 
do this:

echo htmlentities(stripslashes($_POST['text']));
To put the value into a hidden form element, you'd do this:
input type=hidden name=text 
value=?=htmlentities(stripslashes($_POST['text']))?

Now, $_POST['text'] will come out correctly on Page 3. Since you seem to 
have magic_quotes_gpc enabled, you can put the value directly into your 
query.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Security vulerability, any more detail info than this???

2004-07-16 Thread John W. Holmes
Scott Fletcher wrote:
Saw a website about security vulerability and there's no info on php.net
that can describe more about it.  So, anyone know?
http://pcworld.co.nz/news.nsf/0/4D6AE0157B37ACDCCC256ED200693BB3?OpenDocument
One more reason to not use strip_tags... like I really needed another, 
though.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] quotes in text.

2004-07-16 Thread John W. Holmes
Ed Curtis wrote:
On Fri, 16 Jul 2004, Justin Patrin wrote:
This is why he said: Since you seem to have magic_quotes_gpc enabled,
you can put the value directly into your query.
You shouldn't use htmlentities when putting it into the DB. Use it
when displaying the text.
 I tried it both ways and it only works correctly when I do use
htmlentities($_POST['text']) in my insert query. I'm not showing the text
to the user on page 3 at all.
Well, if you're happy with it just working and not knowing why or how 
it's going to break in the future... have fun.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Problem with calculate

2004-07-16 Thread John W. Holmes
Rosen wrote:
I use some numbers from mysql table and other local vars to calculate one
number.
But on one calc I receive thath $value=4.5474735088646E-013;
This must be zero (0) - I see all vars and calc then with calculator. I use
function number_format($value, 2, .,  ) and it return me -0.00
When you use floating point numbers, you can get small errors like this. 
To the computer, 4.54E-13 is about the same as zero. number_format() 
returns the correct result... well, the negative sign may throw you off. 
You can use abs() and round() to get what you want, more than likely.

The thing to remember and react accordingly to is that for floating 
point numbers, 2.0 - 1.5 can equal 0.4999 and be correct 
because of the precision.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Uploading a directory of files

2004-07-16 Thread John W. Holmes
Ryan Schefke wrote:
Does anyone have a script to upload a directory full of files?
.something like a recursive upload.
Not going to happen with PHP and an HTML interface. If you have PHP 
running on two machines and want to do this, then say so.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] finding a substring

2004-07-16 Thread John W. Holmes
C.F. Scheidecker Antunes wrote:
Hello all,
I need to read lines within a text file that might have a  
value='somevalue'  string the position of value= varies from line to 
line but there's only one value= in each line.

So what I need to do is to parse the file and find the value= and put 
their values in an array.

Suposse I have the following text file with 3 lines :
snLADEFEFfdgvalue=1234rwgjngrgj
value=23456gkerlgwg
132fngdhbvalue=5678bfl928
I would like to get an array like this:
array[0] = 1234;
array[1] = 23456;
array[2] =  5678;
The value is delimited always by double quotes but its position on the 
line varies. I need to extract these values and put them on a string.
$file = file_get_contents('yourfile.txt');
preg_match_all('/value=([^]*)/',$file,$matches);
Now $matches[1] will have what you're after.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Help on copying part of a text file

2004-07-16 Thread John W. Holmes
C.F. Scheidecker Antunes wrote:
Hello all,
I need some help on the following:
I need to extract a paragraph from a text file that is delimited with a 
--start-paragraph-- and --end-paragraph-- However, after 
--start-paragraph-- there's a blank line that I need to remove.

The delimiter --start-paragraph-- might be one the first line or it 
might be on any middle line of the line. That is, --start-paragraph line 
starts at some point on the file.

Here's na example:
--start-paragraph--
This is a paragraph that I need to extract with a php function and 
return just
the string of it.
--end-paragraph--

After I run the function extract_paragraph($content) I should get the 
string:
function extract_paragraph($content)
{
  $start = '--start-paragraph--';
  $end = '--end-paragraph--';
  preg_match(/$start(.*)$end/s,$content,$matches);
  return trim($matches[1]);
}
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] upload an image and store it in mysql

2004-07-16 Thread John W. Holmes
Five wrote:
I've been playing with this for two days and am wondering if there's a way to retrieve 
and display the images in a browser using
only php or is it necessary to use a graphics library like GD?
You don't need GD unless you want to modify the image (and even then 
there are other options).

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP upgrade... issues???

2004-07-15 Thread John W. Holmes
[EMAIL PROTECTED] wrote:
I've just got this mail from my host...
=
Dear customer,
This email is sent to inform you that we'll upgrade the PHP version on 
your
server to the latest stable version 4.3.8 within the next hour.
=

Are there any issues that I need to panic about...?
I'm off to google now, but am just having a panic attack, and hope that I 
can sit back knowing that my PHP pages will still work...
I wouldn't be too worried.
PHP 4.3.8 Changelog: http://us2.php.net/ChangeLog-4.php
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Storing text with carriage returns in MySQL

2004-07-15 Thread John W. Holmes
Vail, Warren wrote:
The function addslashes() will resolve many user input problems where the
user;
Inputs a quoted value in the middle of his string.
Uses  and  and  in text.
Inputs other ASCII control characters like tab and bell (remember that one).
addslashes() does not escapecharacters nor control characters 
(other than NUL). It only affects single quotes, double quotes, 
backslashes, and NUL bytes.

Just to name a few.
Usually MySQL will strip slashes when the column is retrieved, 
Already mentioned, but there are no slashes to remove when reading data. 
The slashes simply escape the string to get it into the database.

however care
should be taken when displaying the value on a form (inside another text
area should be no problem).  
It can be a problem if the text contains the string /textarea 
followed by whatever the user wants to inject onto your page.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] problem with super global '$_REQUEST'

2004-07-15 Thread John W. Holmes
Dennis Gearon wrote:
Why unset the globals?
I plan on implementing filters on all User input to ALL scripts in the 
prepend file. And if someone wants to get a variable that was supplied
by a user, they have to specifiy if it's going to be INT, STR(with 
options to remove run on spaces, validate email addr, remove carriage 
returns to prevent embedded email directives) 'NUM' type with formatting 
like in databases, and also, anti SQL injection escaping is possible. 
The programmer will HAVE to choose which filtering, but strip tags is 
automatic. I'm not going to have XSS holes or SQL injection on my site.
Why is strip_tags automatic? So you can filter out such evil code as 
grin and crap, which strip_tags removes? Thinking about using 
allowed_tags with strip_tags? Allow me only the use of the b tag and 
I'll put XSS vulnerabilities all over your site.

How is this going to stop XSS? I tell you I need a string safe to input 
into a database and you send me an escaped string that I insert into a 
database and then display to the user. That can prevent a XSS hole 
unless your users run htmlentities/htmlspecialchars() on the string.

I undestand your idea and what you're trying to do, but educating your 
users is going to have a greater effect than trying to create this 
catch-all-be-all script to protect yourself... that's not going to work.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Offset error

2004-07-15 Thread John W. Holmes
C.F. Scheidecker Antunes wrote:
Can anyone tell me how to test the offset 1 or more in the array 
$att[$k]-parameters[1] so that I can avoid this error?
if(isset($att[$k]-parameters[1]))
{ dosomething(); }
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] selecting a database to create a table with MySQL

2004-07-15 Thread John W. Holmes
Rocky Singh wrote:
how do i select a database under which to create a table...
magic 8-ball says: mysql_select_db()
Four second look at the manual probably would have told you the same. :)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] upload an image and store it in mysql

2004-07-14 Thread John W. Holmes
Five wrote:
I have php code that takes text input from a webpage and and stores it in a mysql data 
base.
I tried uploading small images (jpg) using basically the same syntax but they don't 
make it into the data base.
Does anyone know of a simple tutorial that shows how to do this?
although I'm against storing files in databases...
$file = 
mysql_real_escape_string(file_get_contents($_FILES['yourfile']['tmp_name']));
$query = INSERT INTO yourtable (imgdata) VALUES ('$file');

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Templates Are Driving me Nuts

2004-07-13 Thread John W. Holmes
EE wrote:
Please help. This template thing is driving my nuts. I though maybe when
I read more articles things will clear up; however, things got even
worse. Every article writer has a different idea. Can anyone explain to
me what are Templates for? What are the advantages of using them? If I
use a third party template, will my site have a different look or is it
only a parser that will take my designed template and data and combine
them. I really don't know.
The whole idea behind templates is to separate your business logic 
from your presentation logic. This means you have a script that does 
all of your processing and data retrieval, etc. This script is generally 
all PHP that performs your business logic. Then you have your template 
that only has code meant to control your presentation. This file is 
mostly HTML, generally, with some special template code or limited PHP 
thrown in to control presentation _only_. The idea is that changes to 
the presentation layer will not require changes to your business layer 
and vice-versa.

Everyone has their own ideas on whether this is needed and what kind of 
templates to use. There are a ton of engines out there that you can use. 
Some are simple and some turn into programming languages of their own 
and just present another layer of failure/difficulty. Some people 
recommend just using PHP both in your business and presentation layer as 
this is what PHP was originally designed for.

Personal preference. :)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] $_Request from 4.3 to v5.x

2004-07-13 Thread John W. Holmes
Michael Purdy wrote:
I have a script which accepts three POSTed variables from a basic form.  Under 4.3.7 
the script
runs fine and the variables are successfully passed to the script.
I am testing 5.0 C3 and receive the following error 

PHP Notice: Undefined index: searchtype in c:\http\cgi\list7.php on line 13
script language='php' 
  $searchtype = $_REQUEST['searchtype'];  -- this is line 13
This is simply a notice saying that there was no variable named 
'searchtype' passed from your form data. More than likely searchtype is 
a checkbox. When checkboxes are not checked, they are not sent with the 
form data, so there simply IS NO $_REQUEST['searchtype'] variable. It is 
not set.

You should be checking for this using isset().
$searchtype = isset($_REQUEST['searchtype']) ? $_REQUEST['searchtype'] : 
'default value';

You will want to check the other values, too. Just because your form has 
three elements in it, that doesn't mean every request coming to your 
processing script will have the same three elements...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] using htmlentities with data in textarea

2004-07-13 Thread John W. Holmes
Hull, Douglas D wrote:
But if one enters: w' my word ends up w\'
Run stripslashes() on the entire string before you begin processing it.
If you eventually insert the data into the database, you'll need to run 
addslashes() on it though, to prevent errors/sql injection from the 
unescaped quotes.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] RE:$_Request from 4.3 to v5.x

2004-07-13 Thread John W. Holmes
Dennis Gearon wrote:
Isn't $_REQUEST the same as the old GPC variables in global namespace? A 
way to get requested variables without paying attention to whether they 
came in via cookies, post, or get?

That's been my understanding so I've been using $_GET, $_POST, $_COOKIE 
instead, because that way I  don't have to worry about GPC order AND I 
can use GET and POST together at the same time.
Yes, you're correct. Personal preference as to what to use, though. I 
like using $_REQUEST since it doesn't matter what method my forms use 
and in the end, I really don't care how the user sends me the 
information since it's all validated anyhow. If you send me the form 
data through a cookie, who cares, as long as it's correct...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Anyone knows when PHP5 is released?

2004-07-13 Thread John W. Holmes
Ben Ramsey wrote:
Aidan Lister wrote:
When it's ready
Hopefully we'll see the stable release in the next 24 hours.

There was a post to the internals@ list yesterday.  Andi announced a 
test roll of 5.0.0 saying that he would release PHP 5 within the next 24 
hours if all goes well.  Keep your fingers crossed.

Refer to: http://www.phpdeveloper.org/index/2279
www.php.net says PHP 5.0.0 is released now. I'm sure there'll be an 
annoucement soon...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] HTTP Session Recorder?

2004-07-13 Thread John W. Holmes
Does anyone know of a program that'll record the clicks and requests 
as I go through a site? Something that'll watch as I click on links, 
fill in forms, etc and then be able to perform the same requests 
(duplicating the forms, cookies, etc)?? Maybe a PHP script that can be 
dropped into an existing program and be turned on or off?

Any ideas? Anyone think this is possible to implement in PHP and then 
use Curl or a PEAR class to reproduce the sequence?

Thanks.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] placing values in html teaxtarea

2004-07-12 Thread John W. Holmes
Keith Greene wrote:
 Here is what I tried:

 textarea name=zoutput rows=20 cols=70 wrap value=? echo
 $test; ? / /textarea

textareas do not use the value attribute. instead, the value is placed 
between the textarea/textarea tags:

textarea name=zoutput rows=20 cols=70 wrap /? echo $test; 
?/textarea
Ensure you run $test through htmlentities() or htmlspecialchars() before 
placing it in your textarea like this to prevent code injection.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Trouble with arrays from within MySQL results where clause

2004-07-12 Thread John W. Holmes
Eric Boerner wrote:
Hello all,
I am having trouble setting array data from within a MySQL results
query. I have modified data from the result and wish to enter it into
it's own array ($data). That then is used to generate a graph. The
following code basically gives me an empty array...
I doubt the array is empty. It may not contain what you think it should, 
though. Try using print_r() on $data as you run through the code so you 
can see what it contains.

	if ($sig1  -150) { $aval = $sig1; }
Don't put quotes around -150. As you have it right now, you're comparing 
 strings. If $sig1 is a number, PHP plays nice and assumes you mean 
-150 instead of -150, though. Also, you don't need quotes around $sig1 
at the end of the line.

if ($sig2  -150) { $bval = $sig2; } if ($bval  $aval)
{$aval = bval;}
Missing a dollar sign for bval on this line, unless bval is really a 
constant. Same deal with the quotes, too.

if ($sig3  -150) { $bval = $sig3; } if ($bval  $aval)
{$aval = $bval;}
Same deal here with the quotes, also.
	$data[] = array('$time' = '$time','$aval' = 'aval');
Variables in single quotes are not evaluated. '$val' is not the same as 
$val. Either way, you don't need any quotes here (assuming you mean 
$aval for the last entry.

$data[] = array($time=$time, $aval=$aval);
	$aval = -999;
$aval = -999;
Again, $data has something in it so long as your query is running. It is 
probably just not what you think it is.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] File Upload Question

2004-07-12 Thread John W. Holmes
Vail, Warren wrote:
Perhaps this is more about HTML than PHP, but the PHP $_FILES var seems to
be set up to allow a list of files to be uploaded.  How does one get the
pop-up window to allow a user to select (ctrl-click or whatever) multiple
files in the same pop-up window?  Everything I have tried has left the user
restricted to selecting one file only.
You can only select one file at a time. There's no way to change that.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] stripslashes() when reading from the DB

2004-07-12 Thread John W. Holmes
Jordi Canals wrote:
I usually stripslashes() when I read the info from the database (MySQL). 
 Because the information was inserted after adding slashes, or the 
system has magic_quotes_gpc set to ON.
I remember being taught this lesson long ago. :)
You do not need to strip slashes from the data being read from the 
database. If you find yourself having to do that, then you're escaping 
the data twice before it's inserted. You more than likely have 
magic_quotes_gpc enabled which escapes all incoming GET, POST and COOKIE 
data and then you are running addslashes() yourself.

You should check the magic_quotes setting with get_magic_quotes_gpc() 
and then determine if you need to use addslashes or 
mysql_real_escape_string().

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] OO woes

2004-07-12 Thread John W. Holmes
Matthew Sims wrote:
Your problem has nothing to do with the Objects (or really even PHP for
that matter). You're not supposed to run mysql_escape_string on an
entire query.
So I ran my $_POST array into array_map before the injection:
$_POST = array_map(mysql_escape_string,$_POST);
And it all worked on nicely.
That's a waste of resources when you're only using one value out
of $_POST in your query. Why not just turn on magic_quotes_gpc
and have the same effect?
I'd recommend some actual validation methods in your class. Something to 
ensure $_POST'd values are really integers within a range, strings of a 
certain length, etc and prepare them for insertion into a query.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] php reserved characters...

2004-07-12 Thread John W. Holmes
bruce wrote:
i have the following:
html
body
?
$test = p;
echo $test;
print $test;
?
/body
/html
it doesn't seem to print... which leads me to 
 believe that  is a reserved char/word...
i tried to do a \p with no luck...
any idea as to what's going on, and can someone 
 point me to a list of the actual php reserved
 chars/words couldn't seem to track them down
 on the php site/google...
 is not reserved. The problem is your HTML.
Your result ends up like this:
html
body
p p /body
/html
which is just badly formed HTML, not PHP.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] search string / query format

2004-07-09 Thread John W. Holmes
Ed Lazor wrote:
I'm going to create a search page that accepts input similar to places like
Yahoo and Google.  
[snip]
 Also, I've heard that MySQL's indexing can
support some of this, but I'm not sure how much.
Using a FULLTEXT index and searching in BOOLEAN mode supports the type 
of search strings that you wrote.

Consult thine manual!! (The MySQL one) ;)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


  1   2   3   4   5   6   7   8   9   10   >