Re: [PHP] Appending into associative arrays

2007-04-16 Thread Otto Wyss

Alister Bulman wrote:



$dirs[$d] = filemtime($d);

Has he even retrieved the directories in sorted order by modification
time? If not he still needs to sort.


Then he'll need an asort($dirs);  They would not have come in any
particular order, so you have to sort them for whatever you need
anyway.

Fine. But how do I now implement recursive looking for directories? My 
code doesn't work.


  function recurseDir ($base, $accending = true, $dirs = array()) {
$handle = opendir ($base);
while ($dir = readdir($handle)) {
  if (($dir != '..') and ($dir != '.')) {
$d = $base.'/'.$dir;
if (is_dir ($d)) {
  $dirs[$d] = filemtime($d);
  recurseDir ($d, true, $dirs);
}
  }
}
closedir ($handle);
asort ($dirs);
return array_keys ($accending? $dirs: array_reverse ($dirs));
  }

O. Wyss

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



Re: [PHP] Appending into associative arrays

2007-04-16 Thread Satyam

$fmtime = filemtime($d);
if (!array_key_exists($fm,$dir)) $dir[$fm] = array();
$dir[$fm][] = $d;

This would give you an array indexed by filetime containing arrays of 
filenames.  You may try and see if the last line is enough on its own, but I 
believe it once happened to me that it failed to create a two levels deep 
array of arrays in just one shot, that's why the second line.  Alternatively 
you could use the filename as key of the second array and store in it any 
information as data, for whatever you might need:


$dir[$fm][$d] = some data related to $d.

Satyam


- Original Message - 
From: Otto Wyss [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Sunday, April 15, 2007 9:20 PM
Subject: [PHP] Appending into associative arrays


I want to sort directories according there modification time and thought 
accociative arrays would be perfect. But when I add an element like


$dirs = array (filemtime($d) = $d)

the previous ones are lost. I tried array_push but that doesn't seems to 
work, at least I always get syntax errors. Next try was array_merge(array 
(...)). So what next?


O. Wyss

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



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 269.4.0/761 - Release Date: 14/04/2007 
21:36





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



Re: [PHP] Appending into associative arrays

2007-04-16 Thread Zoltán Németh
2007. 04. 16, hétfő keltezéssel 09.27-kor Otto Wyss ezt írta:
 Alister Bulman wrote:
  
  $dirs[$d] = filemtime($d);
  Has he even retrieved the directories in sorted order by modification
  time? If not he still needs to sort.
  
  Then he'll need an asort($dirs);  They would not have come in any
  particular order, so you have to sort them for whatever you need
  anyway.
  
 Fine. But how do I now implement recursive looking for directories? My 
 code doesn't work.

what do you mean by doesn't work? what error is thrown if any? what
result do you get instead of the expected?
at first glance I cannot see anything wrong with your function...

greets
Zoltán Németh

 
function recurseDir ($base, $accending = true, $dirs = array()) {
  $handle = opendir ($base);
  while ($dir = readdir($handle)) {
if (($dir != '..') and ($dir != '.')) {
  $d = $base.'/'.$dir;
  if (is_dir ($d)) {
$dirs[$d] = filemtime($d);
recurseDir ($d, true, $dirs);
  }
}
  }
  closedir ($handle);
  asort ($dirs);
  return array_keys ($accending? $dirs: array_reverse ($dirs));
}
 
 O. Wyss
 

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



Re: [PHP] Appending into associative arrays

2007-04-16 Thread Otto Wyss

Zoltán Németh wrote:

what do you mean by doesn't work? what error is thrown if any? what
result do you get instead of the expected?
at first glance I cannot see anything wrong with your function...

It simply doesn't add any sub folder to $dirs. Could it be that the 
function doesn't return the $dirs parameter?


O. Wyss

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



Re: [PHP] Appending into associative arrays

2007-04-16 Thread Zoltán Németh
2007. 04. 16, hétfő keltezéssel 10.40-kor Otto Wyss ezt írta:
 Zoltán Németh wrote:
  what do you mean by doesn't work? what error is thrown if any? what
  result do you get instead of the expected?
  at first glance I cannot see anything wrong with your function...
  
 It simply doesn't add any sub folder to $dirs. Could it be that the 
 function doesn't return the $dirs parameter?

yes at second look I see the problem. you should do it this way:

function recurseDir ($base, $accending = true, $dirs = array()) {
 $handle = opendir ($base);
 while ($dir = readdir($handle)) {
   if (($dir != '..') and ($dir != '.')) {
 $d = $base.'/'.$dir;
 if (is_dir ($d)) {
   $dirs[$d] = filemtime($d);
   $dirs = recurseDir ($d, true, $dirs);
 }
   }
 }
 closedir ($handle);
 asort ($dirs);
 return $accending? $dirs: array_reverse ($dirs);
   }

and then you can call array_keys on the result of the whole recursion
like:
$dirnames = array_keys($base, $accending);

greets
Zoltán Németh

 
 O. Wyss
 

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



Re: [PHP] Json.php

2007-04-16 Thread Jochem Maas
Otto Wyss wrote:
 Tijnema ! wrote:

 *ROFLMFAO*...Did you actually try google for json.php?
 Second result:
 http://mike.teczno.com/JSON/JSON.phps

 This doesn't have a json_encode but needs a $json object which then
 could be used as $json-encode(...). Thanks anyway.

that's going to make it completely impossible to use then isn't it.
no way you could possibly wrap the class/objects functionality in a wrapper
function.

if (!function_exists('json_encode')) {
function json_encode($data) {
$json = new JSON; // or whatever the class is called.
return $json-encode($data);
}
}

omg that was hard.

 
 O. Wyss
 

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



Re: [PHP] Importing data in to mysql with some control

2007-04-16 Thread Jochem Maas
Richard Kurth wrote:
 I am trying to write a import script for loading data into an existing mysql
 table. I want to show the import data on the screen and let the user select
 the column number to go with which mysql field. Now some of the fields are
 mandatory like firstname lastname email address and so on... But
 some of the fields might be custom fields these would be stored in a
 different table and the mysql fields would be custom1 custom2 .   So
 the user would select what column go's with which field. No I know that some
 of this would have to be done server side. So I was thinking of using Ajax
 or just JavaScript. Does anybody know of any examples that show something
 like this being done. The only examples I have seen just shows data being
 imported into the database form csv file with out choosing where the data
 should go. It has to be in order when you run the script. Any ideas on where
 to look and how to get this started.

1. user uploads CSV file
2. you cache the file
3. you parse the file for available headers/columns
4. you display an interface for mapping available columns to required/optional 
fields
(the hard part is probably making this part user-friendly and fool-proof.)
5. the user submits their mapping selection
6. you loop through the 'rows' in the cached CSV file - using the mapping 
selection data
that was submitted in order to generate suitable sql INSERT statements ... say 
the user
mapped column X to field Y and column X is the third column of data in the CSV 
file then
for every row you would take the third piece of data and make a snippet of SQL 
that ends up
looking like:

X='mydata'

'X' would be retrieved from the mapping info that your given, and 'mydata' 
would be the
data from the 3rd column of a given row in the CSV file.

hth

 

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



RE: [PHP] how to get var name and value from function?

2007-04-16 Thread Ford, Mike
On 14 April 2007 13:16, Afan Pasalic wrote:

 Tijnema ! wrote:
  On 4/14/07, Afan Pasalic [EMAIL PROTECTED] wrote:
   function value2var($array, $print=0)
   {
  foreach ($_POST as $key = $value)
  
  I think you should change above line to :
  
 foreach ($array as $key = $value)
 yup! it's print error. I meant $array.
  {
  ${$key} = $value;
  echo ($print ==1) ? $key.': '.$value.'br'; // to test
   results and seeing array variables and values
  }
   }
   
   value2var($_POST, 1);
   
   but, I don't know how to get info from function back to
   script?!?!? :-(
  
  Uhm, it's not even possible when you don't know the keys i believe.
 after 2 hours of testing and research I realized this too, but want
 to be sure. :-(

If you really *must* do this yourself (but others have pointed out the folly of 
it), this would do it:

function value2var($array)
{
foreach ($array as $key = $value)
{
$GLOBALS['$key'] = $value;
}
}

... or, alternatively, rather than defining you own function, use extract() 
(http://php.net/extract) with one of the overwrite safety options to avoid 
blobbing existing variables.

Personally, I'd never do this in any form -- if I do it at all, I extract 
specific indices of the array with code like:

  foreach (array('name', 'address', 'email', 'setting1', 'setting2') as $key):
$GLOBALS[$key] = $array[$key];
  endforeach;

... making certain, of course, that those values get properly validated 
elsewhere.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Appending into associative arrays

2007-04-16 Thread Zoltán Németh
2007. 04. 16, hétfő keltezéssel 10.50-kor Zoltán Németh ezt írta:
 2007. 04. 16, hétfő keltezéssel 10.40-kor Otto Wyss ezt írta:
  Zoltán Németh wrote:
   what do you mean by doesn't work? what error is thrown if any? what
   result do you get instead of the expected?
   at first glance I cannot see anything wrong with your function...
   
  It simply doesn't add any sub folder to $dirs. Could it be that the 
  function doesn't return the $dirs parameter?
 
 yes at second look I see the problem. you should do it this way:
 
 function recurseDir ($base, $accending = true, $dirs = array()) {
  $handle = opendir ($base);
  while ($dir = readdir($handle)) {
if (($dir != '..') and ($dir != '.')) {
  $d = $base.'/'.$dir;
  if (is_dir ($d)) {
$dirs[$d] = filemtime($d);
$dirs = recurseDir ($d, true, $dirs);
  }
}
  }
  closedir ($handle);
  asort ($dirs);
  return $accending? $dirs: array_reverse ($dirs);
}
 
 and then you can call array_keys on the result of the whole recursion
 like:
 $dirnames = array_keys($base, $accending);

ehh typo in the above line, sorry

$dirnames = array_keys(recurseDir($base, $accending));

greets
Zoltán Németh

 
 greets
 Zoltán Németh
 
  
  O. Wyss
  
 

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



Re: [PHP] Appending into associative arrays

2007-04-16 Thread Jochem Maas
Zoltán Németh wrote:
 2007. 04. 16, hétfő keltezéssel 10.50-kor Zoltán Németh ezt írta:
 2007. 04. 16, hétfő keltezéssel 10.40-kor Otto Wyss ezt írta:
 Zoltán Németh wrote:
 what do you mean by doesn't work? what error is thrown if any? what
 result do you get instead of the expected?
 at first glance I cannot see anything wrong with your function...

 It simply doesn't add any sub folder to $dirs. Could it be that the 
 function doesn't return the $dirs parameter?
 yes at second look I see the problem. you should do it this way:

 function recurseDir ($base, $accending = true, $dirs = array()) {
  $handle = opendir ($base);
  while ($dir = readdir($handle)) {
if (($dir != '..') and ($dir != '.')) {
  $d = $base.'/'.$dir;
  if (is_dir ($d)) {
$dirs[$d] = filemtime($d);
$dirs = recurseDir ($d, true, $dirs);
  }
}
  }
  closedir ($handle);
  asort ($dirs);
  return $accending? $dirs: array_reverse ($dirs);
}

 and then you can call array_keys on the result of the whole recursion
 like:
 $dirnames = array_keys($base, $accending);
 
 ehh typo in the above line, sorry
 
 $dirnames = array_keys(recurseDir($base, $accending));

It would be much cleaner to not pass $dirs into the function and
use array_merge() on the returned array instead, additionally
having to call array_keys() on the call to recurseDir() seems rather
lame (too much of wtf factor imho).

function recurseDir ($base, $ascending = true, $self_called = false) {
 $handle = opendir($base);
 $dirs   = array();
 while ($dir = readdir($handle)) {
   if (($dir != ..) and ($dir != .)) {
 $d = $base./.$dir;
 if (is_dir ($d)) {
   $dirs[$d] = filemtime($d);
   $dirs = array_merge($dirs, recurseDir($d, $ascending, true));
 }
   }
 }

 closedir ($handle);

 if ($self_called) {
return $dirs;
 } else {
asort ($dirs);
return array_keys($ascending ? $dirs : array_reverse($dirs));
 }
}


not exactly pretty, what with the use of $self_called - but at least it keeps
all the crap inside the function.

 
 greets
 Zoltán Németh
 
 greets
 Zoltán Németh

 O. Wyss

 

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



Re: [PHP] Json.php

2007-04-16 Thread Otto Wyss

Jochem Maas wrote:


that's going to make it completely impossible to use then isn't it.
no way you could possibly wrap the class/objects functionality in a wrapper
function.

At the moment it's sufficient, since I've now time to figure out how the 
Json package can be installed. Then I can switch to use the usual 
json_encode function. Thanks.


O. Wyss

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



Re: [PHP] Json.php

2007-04-16 Thread Philip Thompson

On Apr 16, 2007, at 4:40 AM, Jochem Maas wrote:


Otto Wyss wrote:

Tijnema ! wrote:


*ROFLMFAO*...Did you actually try google for json.php?
Second result:
http://mike.teczno.com/JSON/JSON.phps


This doesn't have a json_encode but needs a $json object which then
could be used as $json-encode(...). Thanks anyway.


that's going to make it completely impossible to use then isn't it.
no way you could possibly wrap the class/objects functionality in a  
wrapper

function.

if (!function_exists('json_encode')) {
function json_encode($data) {
$json = new JSON; // or whatever the class is called.
return $json-encode($data);
}
}

omg that was hard.


Can't you just feel the love in the room? That's the kind of support  
I like to see! =P


~PT

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



Re: [PHP] auto page generation

2007-04-16 Thread tedd

At 1:31 AM -0400 4/16/07, Jeremy Adams wrote:

I'm building a website right now that will be a database of attractions in
the Carolina and Virginia area.
The idea is that attraction owners can submit data to the database and the
database will automatically generate a page containing that information.
What I'm trying to figure out is how to generate the pages automatically and
have links to them added to the site.  If someone could help me or point me
in the direction of a book or web page that covers this I would really
appreciate it.


Jeremy:

Welcome to php and mysql, because if you're going to do it yourself, 
then you're going to have to learn it.


Here's some online tutorials to introduce you.

http://www.htmlgoodies.com/beyond/php/article.php/3472391
http://www.w3schools.com/php/default.asp
http://www.weberdev.com/ViewArticle/433
http://www.weberdev.com/Manuals/PHP/
http://www.unf.edu/~rita0001/eresources/php_tutorials/index.htm

As you develop, post specific problems on this list and we'll help.

Plus, it would be a good idea to buy a few of books on the subject 
like the PHP Cookbook, MSQL Cookbook, PHP Developer's Cookbook and 
PHP Security (not a cookbook). As you see, I'm big into Cookbooks.


However, that's a minor fraction of the php, mysql, javascript, and 
other books I've purchased to do what you're wanting to do. It might 
be cheaper and quicker to hire one of us.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] NEWBIE guide

2007-04-16 Thread tedd

Hi gang:

What ever happened to the NEWBIE guide we were talking about 
providing last year? Did anyone do anything about it?


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] NEWBIE guide

2007-04-16 Thread Jay Blanchard
[snip]
What ever happened to the NEWBIE guide we were talking about 
providing last year? Did anyone do anything about it?
[/snip]

We had periodically published a newbie guide to the list, for a while it
was automated by one of the group, then I would send out manually from
time-to-time. These are in the archives. It had kind of morphed, new
information was added. 

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



[PHP] PHP Dynamic Form Generator

2007-04-16 Thread Tom Chubb

Dear list,
I'm currently reviewing a load of scripts to dynamically generate a form for
a membership system.
I have designed a registration form, and once registered and logged in there
are a load of different options relevant to people's profile (which will all
be radio check boxes) in a 2nd form.
As the number of these check-boxes may change, I'd like to be able to read
the structure of the relevant table and generate the form from that.
I just wanted to ask everyone for any advice on this and which scripts you
use? I'm not being lazy, but currently I'm looking at 8 of them from
phpclasses.org and sourceforge and I'm sure someone out there knows exactly
what I'm looking for.
Thanks in advance,

Tom

--
Tom Chubb
[EMAIL PROTECTED]


[PHP] post via text message?

2007-04-16 Thread blackwater dev

I'm working on a site where I need to allow someone to send me a text
message and let the code take their message and respond or post it in the
db.  Can someone point me in the right direction on how this is done?

Thanks!


Re: [PHP] Array remove function?

2007-04-16 Thread Jochem Maas
Richard Lynch wrote:
 On Wed, April 11, 2007 9:00 pm, Jochem Maas wrote:
 [PS - I've the pleasure of listening to a colleague do a manual
 install
 of Vista over an existing copy of XP and then get the really tricky
 stuff
 like the soundcard to work ... for the last week :-/]
 
 Give them an Ubuntu (or similar) CD and see if they want to just leave
 the Dark Side... :-)

yeah, but the vista story keeps getting worse.
how about:

1. '50% of applications can't use network because the router is in compatible 
with vista'

a total WTF, apparently due to vista network 'auto-tuning' - can only 
be turned off
via the cmdline.

2. undo/redo function in a whole stack of programs doesn't work unless you
run the program in 'administrator mode'

omg.

3. openvpn doesn't work ... unless you run it in 'administrator mode'

4. when you finally give trying to run anything as anything other than an 
adminstrator
user your still confronted with that freakin' 'administrator mode' popup (which 
also
greys out the rest of the desktop) *everytime* you breath too loudly.

5. don't delete a folder if you want to get anything done today ... well at the 
least you'll
probably get a chance to grab a another cup of coffee.

6. er ... I'll keep you posted.

 

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



[PHP] Problems when trying to use ibm_db2 extension

2007-04-16 Thread Leo Jokinen

Hi all,

I've been banging my head into the wall cause I can't get ibm_db2 
extension working with Apache 2.0.59 and PHP 5.2.1 (as apache module).

(Operating system is winxp pro SP2)

For some reason, this code is working on command line but not when 
placed to htdocs folder:



?php
if(function_exists('db2_connect')) {
  echo 'Function db2_connect() exists';
} else {
  echo 'Unknown function db2_connect()';
  exit;
}

echo \nTrying to connect DB2 database..\n;

$database = 'services';
$user = 'db2admin';
$password = 'xxx';
$hostname = '127.0.0.1';
$port = 5;
$conn_string = DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database; .
  HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;;
$conn = db2_connect($conn_string, '', '');

if ($conn) {
  echo OK: Connection established\n;
  db2_close($conn);
} else {
  echo ERROR: Connection failed\n;
}
?


Command line output:

C:\php c:\db2_test.php
Function db2_connect() exists
Trying to connect DB2 database..
OK: Connection established


Web output:

Unknown function db2_connect()


Some extra output:

Fatal error: Call to undefined function db2_connect() in 
F:\www\services.itella.net\app\webroot\index.php on line 57


Also, phpinfo() won't say nothing that module ibm_db2 is in use

More info:

php_ibm_db2.dll file is in folder C:/php-5.2.1/ext

php.ini:
extension_dir = C:/php-5.2.1/ext
extension=php_ibm_db2.dll

httpd.conf:
AddType application/x-httpd-php .php
LoadModule php5_module C:/php-5.2.1/php5apache2.dll
PHPIniDir C:/php-5.2.1/


Can someone point out the right direction for me?

Regards

Leo Jokinen

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



Re: [PHP] Json.php

2007-04-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-04-16 14:03:55 +0200:
 Jochem Maas wrote:
 
 that's going to make it completely impossible to use then isn't it.
 no way you could possibly wrap the class/objects functionality in a wrapper
 function.
 
 At the moment it's sufficient, since I've now time to figure out how the 
 Json package can be installed. Then I can switch to use the usual 
 json_encode function. Thanks.

What I don't understand is why you're going from a general interface

  $someObject-decode($string); # if it quacks like a JSON decoder...

to a narrow one:

  json_decode($string); # you either have the function or you're screwed.

Tight coupling - inflexible code.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] isset

2007-04-16 Thread tedd

At 12:16 PM -0500 4/15/07, Larry Garfield wrote:

If you want your syntax to be a bit simpler, I frequently use helper functions
along these lines:

function http_get_int($var, $default=0) {
  return isset($_GET[$var]) ? (int) $_GET[$var] : $default;
}

if (http_get_int('var') ==5) {
  // Do stuff
}

Clean to read, easy defaults, (reasonably) type-safe, and E_NOTICE friendly.


Larry:

Slick.

Thanks,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Json.php

2007-04-16 Thread tedd

At 8:41 AM -0500 4/16/07, Philip Thompson wrote:

On Apr 16, 2007, at 4:40 AM, Jochem Maas wrote:


Otto Wyss wrote:

Tijnema ! wrote:


*ROFLMFAO*...Did you actually try google for json.php?
Second result:
http://mike.teczno.com/JSON/JSON.phps


This doesn't have a json_encode but needs a $json object which then
could be used as $json-encode(...). Thanks anyway.


that's going to make it completely impossible to use then isn't it.
no way you could possibly wrap the class/objects functionality in a wrapper
function.

if (!function_exists('json_encode')) {
function json_encode($data) {
$json = new JSON; // or whatever the class is called.
return $json-encode($data);
}
}

omg that was hard.


Can't you just feel the love in the room? That's the kind of support 
I like to see! =P


~PT



Yep, it must be spring.

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] isset

2007-04-16 Thread Jim Lucas

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like 
if (isset($_REQUEST['var'])) {

}
Put var has no data it still says it is set. Because $_REQUEST['var'] = 
and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}

--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times 
for you and me when all such things agree.


- Rush



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



Re: [PHP] Json.php

2007-04-16 Thread Robert Cummings
On Mon, 2007-04-16 at 10:49 -0400, tedd wrote:
 At 8:41 AM -0500 4/16/07, Philip Thompson wrote:
 On Apr 16, 2007, at 4:40 AM, Jochem Maas wrote:
 
 Otto Wyss wrote:
 Tijnema ! wrote:
 
 *ROFLMFAO*...Did you actually try google for json.php?
 Second result:
 http://mike.teczno.com/JSON/JSON.phps
 
 This doesn't have a json_encode but needs a $json object which then
 could be used as $json-encode(...). Thanks anyway.
 
 that's going to make it completely impossible to use then isn't it.
 no way you could possibly wrap the class/objects functionality in a wrapper
 function.
 
 if (!function_exists('json_encode')) {
 function json_encode($data) {
 $json = new JSON; // or whatever the class is called.
 return $json-encode($data);
 }
 }
 
 omg that was hard.
 
 Can't you just feel the love in the room? That's the kind of support 
 I like to see! =P
 
 ~PT
 
 
 Yep, it must be spring.

It's the difference between free support and paid support. In paid
support the love is all fake... in free support, what you feel is the
real deal :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] auto page generation

2007-04-16 Thread Tijnema !

On 4/16/07, tedd [EMAIL PROTECTED] wrote:

At 1:31 AM -0400 4/16/07, Jeremy Adams wrote:
I'm building a website right now that will be a database of attractions in
the Carolina and Virginia area.
The idea is that attraction owners can submit data to the database and the
database will automatically generate a page containing that information.
What I'm trying to figure out is how to generate the pages automatically and
have links to them added to the site.  If someone could help me or point me
in the direction of a book or web page that covers this I would really
appreciate it.

Jeremy:

Welcome to php and mysql, because if you're going to do it yourself,
then you're going to have to learn it.

Here's some online tutorials to introduce you.

http://www.htmlgoodies.com/beyond/php/article.php/3472391
http://www.w3schools.com/php/default.asp
http://www.weberdev.com/ViewArticle/433
http://www.weberdev.com/Manuals/PHP/
http://www.unf.edu/~rita0001/eresources/php_tutorials/index.htm

As you develop, post specific problems on this list and we'll help.

Plus, it would be a good idea to buy a few of books on the subject
like the PHP Cookbook, MSQL Cookbook, PHP Developer's Cookbook and
PHP Security (not a cookbook). As you see, I'm big into Cookbooks.

However, that's a minor fraction of the php, mysql, javascript, and
other books I've purchased to do what you're wanting to do. It might
be cheaper and quicker to hire one of us.


Or just google for some tutorials like : www.tizag.com
It has a great tutorial for n00bs... ;)

After that you probably will be able to make such site you want to :)

Tijnema


Cheers,

tedd


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



Re: [PHP] isset

2007-04-16 Thread Stut

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because $_REQUEST['var'] 
= 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}


The isset is a pointless waste of cycles.

-Stut

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



Re: [PHP] Json.php

2007-04-16 Thread Jochem Maas
Robert Cummings wrote:
 On Mon, 2007-04-16 at 10:49 -0400, tedd wrote:
 At 8:41 AM -0500 4/16/07, Philip Thompson wrote:
 On Apr 16, 2007, at 4:40 AM, Jochem Maas wrote:

 Otto Wyss wrote:
 Tijnema ! wrote:
 *ROFLMFAO*...Did you actually try google for json.php?
 Second result:
 http://mike.teczno.com/JSON/JSON.phps

 This doesn't have a json_encode but needs a $json object which then
 could be used as $json-encode(...). Thanks anyway.
 that's going to make it completely impossible to use then isn't it.
 no way you could possibly wrap the class/objects functionality in a wrapper
 function.

 if (!function_exists('json_encode')) {
function json_encode($data) {
$json = new JSON; // or whatever the class is called.
return $json-encode($data);
}
 }

 omg that was hard.
 Can't you just feel the love in the room? That's the kind of support 
 I like to see! =P

 ~PT

 Yep, it must be spring.
 
 It's the difference between free support and paid support. In paid
 support the love is all fake... in free support, what you feel is the
 real deal :)

yeah! tough love.
if the man complains the fishing lesson is not a fish he's liable to
be gently beaten with the fishing rod.

 
 Cheers,
 Rob.

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



Re: [PHP] how to get var name and value from function?

2007-04-16 Thread Tijnema !

On 4/16/07, Ford, Mike [EMAIL PROTECTED] wrote:

On 14 April 2007 13:16, Afan Pasalic wrote:

 Tijnema ! wrote:
  On 4/14/07, Afan Pasalic [EMAIL PROTECTED] wrote:
   function value2var($array, $print=0)
   {
  foreach ($_POST as $key = $value)
 
  I think you should change above line to :
 
 foreach ($array as $key = $value)
 yup! it's print error. I meant $array.
  {
  ${$key} = $value;
  echo ($print ==1) ? $key.': '.$value.'br'; // to test
   results and seeing array variables and values
  }
   }
  
   value2var($_POST, 1);
  
   but, I don't know how to get info from function back to
   script?!?!? :-(
 
  Uhm, it's not even possible when you don't know the keys i believe.
 after 2 hours of testing and research I realized this too, but want
 to be sure. :-(

If you really *must* do this yourself (but others have pointed out the folly of 
it), this would do it:

function value2var($array)
{
   foreach ($array as $key = $value)
   {
   $GLOBALS['$key'] = $value;
   }
}


What's the sense in above function? you're putting the variables from
1 array in another...
you could use array_merge for this.
But even then it's quite useless...



... or, alternatively, rather than defining you own function, use extract() 
(http://php.net/extract) with one of the overwrite safety options to avoid 
blobbing existing variables.


That's a better idea. :)


Personally, I'd never do this in any form -- if I do it at all, I extract 
specific indices of the array with code like:

 foreach (array('name', 'address', 'email', 'setting1', 'setting2') as $key):
   $GLOBALS[$key] = $array[$key];
 endforeach;


endforeach? never heard of that statement before, does it really exist in PHP?



... making certain, of course, that those values get properly validated 
elsewhere.

Cheers!

Mike


Sure, you should always validate your variables, but i would recommend
to only get the variables from $_GET/$_POST that you actually gonna
need, and not just everything.

Tijnema




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



Re: [PHP] Json.php

2007-04-16 Thread Tijnema !

On 4/16/07, Jochem Maas [EMAIL PROTECTED] wrote:

Otto Wyss wrote:
 Tijnema ! wrote:

 *ROFLMFAO*...Did you actually try google for json.php?
 Second result:
 http://mike.teczno.com/JSON/JSON.phps

 This doesn't have a json_encode but needs a $json object which then
 could be used as $json-encode(...). Thanks anyway.

that's going to make it completely impossible to use then isn't it.
no way you could possibly wrap the class/objects functionality in a wrapper
function.

if (!function_exists('json_encode')) {
   function json_encode($data) {
   $json = new JSON; // or whatever the class is called.
   return $json-encode($data);
   }
}


The class is called Services_JSON, not JSON.
And btw, I think it's better not to create a new link to the class
each time the function is called, but just use ::
if (!function_exists('json_encode')) {
  function json_encode($data) {
  return Services_JSON::encode($data);
  }
}

and probably also one for decoding.

if (!function_exists('json_decode')) {
  function json_decode($data) {
  return Services_JSON::decode($data);
  }
}



omg that was hard.


Definitely not :)

Tijnema

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



Re: [PHP] isset

2007-04-16 Thread Jim Lucas

Robert Cummings wrote:

On Mon, 2007-04-16 at 09:27 -0700, Jim Lucas wrote:

Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because $_REQUEST['var'] 
= 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}

The isset is a pointless waste of cycles.

-Stut


well, as the OP said, he wants to know when the variable has a value other the 
.

So, to check for that you have to do something like this right?

if ( $var != '' ) {}
if ( strlen($var)  0 ) {}
if ( !empty($var) ) {}
... a number of other ideas come to mind, but

none of them will work, because they will always product a E_NOTICE warning.

You COULD always use empty() prefixed with an @ to quiet the E_NOTICE,


Stut wouldn't do that... especially not after calling isset() a waste of
cycles. using the @ to suppress warnings/errors still invokes the error
system, and that includes any error handler you've custom hooked.

Maybe Stut just writes bad code ;) ;)

Cheers,
Rob.

I wouldn't say bad code, but I might say exceptionally noisy code  :P

--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times 
for you and me when all such things agree.


- Rush

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



Re: [PHP] isset

2007-04-16 Thread tedd

At 4:08 PM +0100 4/16/07, Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because $_REQUEST['var'] = 
and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}


The isset is a pointless waste of cycles.

-Stut



I've been accuse of that too, but what's your solution?

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] isset

2007-04-16 Thread Stut

tedd wrote:

At 4:08 PM +0100 4/16/07, Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because 
$_REQUEST['var'] = 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}


The isset is a pointless waste of cycles.

-Stut


I've been accuse of that too, but what's your solution?


In the above example,

  if (isset($_GET['something'])  !empty($_GET['something'])) {

is the same as...

  if (!empty($_GET['something'])) {

So, in that particular line of code the isset is a pointless waste of 
cycles.


-Stut

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



[PHP] header('Location:') works locally but not remotely

2007-04-16 Thread Ross
any reason why this should be?

R. 

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



Re: [PHP] isset

2007-04-16 Thread Jim Lucas

Stut wrote:

tedd wrote:

At 4:08 PM +0100 4/16/07, Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because 
$_REQUEST['var'] = 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}


The isset is a pointless waste of cycles.

-Stut


I've been accuse of that too, but what's your solution?


In the above example,

  if (isset($_GET['something'])  !empty($_GET['something'])) {

is the same as...

  if (!empty($_GET['something'])) {

So, in that particular line of code the isset is a pointless waste of 
cycles.


-Stut

these two lines are not the same infact, with the first, you will not get a E_NOTICE warning, but 
with the second you will.


--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times 
for you and me when all such things agree.


- Rush

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



Re: [PHP] isset

2007-04-16 Thread Afan Pasalic

that was actually my point.
:)

-afan


Stut wrote:

tedd wrote:

At 4:08 PM +0100 4/16/07, Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because 
$_REQUEST['var'] = 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}


The isset is a pointless waste of cycles.

-Stut


I've been accuse of that too, but what's your solution?


In the above example,

  if (isset($_GET['something'])  !empty($_GET['something'])) {

is the same as...

  if (!empty($_GET['something'])) {

So, in that particular line of code the isset is a pointless waste of 
cycles.


-Stut



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



Re: [PHP] header('Location:') works locally but not remotely

2007-04-16 Thread Dave Goodchild

Provide some code...?


[PHP] Shiny Floor (web 2.0) effect with GD Library

2007-04-16 Thread Graham Anderson
Has anyone created that web 2.0 shiny floor  effect with the GD  
Library?
I have seen it dynamically created by passing variables into a Flash  
movie.  Has this been done with GD?


many thanks

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



Re: [PHP] isset

2007-04-16 Thread Jim Lucas

Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because $_REQUEST['var'] 
= 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}


The isset is a pointless waste of cycles.

-Stut


well, as the OP said, he wants to know when the variable has a value other the 
.

So, to check for that you have to do something like this right?

if ( $var != '' ) {}
if ( strlen($var)  0 ) {}
if ( !empty($var) ) {}
... a number of other ideas come to mind, but

none of them will work, because they will always product a E_NOTICE warning.

You COULD always use empty() prefixed with an @ to quiet the E_NOTICE,

but, me, I could/would possibly miss that when scanning the code.

I would however see the isset()  !empty() bit of code.

And the amount of time that you save by not using isset(), well, lets just say that if it affected 
the time of your apps performance, I think you have other things to worry about first.



Just for example.  The current project that just took over has about 60,000 lines of code.  Doing a 
quick grep -ri 'isset' * on the dir returns about 475 instances of that function call.  Many of 
which I have added to the system to get rid of E_NOTICE warnings, for the simple fact that I wanted 
to set error reporting to E_ALL.  Bad mistake, over half the scripts fire off warnings left and 
right, because all he was doing for checking was !empty() if ( $var ) {} or if ( $var != '' ) {} 
calls all over the place.


There are two ways that I have found to get rid of the notices.


Example #1

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}

Example #2

if ( @!empty($_GET['something']) ) {
// do something here with $_GET['something']
}

Other suggestions would be gladly accepted.


--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times 
for you and me when all such things agree.


- Rush

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



Re: [PHP] isset

2007-04-16 Thread Edward Vermillion


On Apr 16, 2007, at 11:27 AM, Jim Lucas wrote:


Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because $_REQUEST 
['var'] = 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}

The isset is a pointless waste of cycles.
-Stut
well, as the OP said, he wants to know when the variable has a  
value other the .


So, to check for that you have to do something like this right?

if ( $var != '' ) {}
if ( strlen($var)  0 ) {}
if ( !empty($var) ) {}
... a number of other ideas come to mind, but

none of them will work, because they will always product a E_NOTICE  
warning.




empty() does NOT produce an E_NOTICE if the variable is not set.  
That's one of the things it considers as empty.


And why I always do !empty($foo) then check for a value such as (! 
empty($foo)  $foo == $bar)


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



RE: [PHP] Shiny Floor (web 2.0) effect with GD Library

2007-04-16 Thread Jay Blanchard
[snip]
web 2.0
[/snip]

There is a new web? Do you have an example of the shiny floor? Does it
look like the one in my kitchen or one of those old Java water effects?

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



Re: [PHP] isset

2007-04-16 Thread Robert Cummings
On Mon, 2007-04-16 at 09:27 -0700, Jim Lucas wrote:
 Stut wrote:
  Jim Lucas wrote:
  Richard Kurth wrote:
  What do you do when isset does not work? If I send data in a
  $_REQUEST['var'] like if (isset($_REQUEST['var'])) {
  }
  Put var has no data it still says it is set. Because $_REQUEST['var'] 
  = 
  and isset thinks  is set
 
  I use this combination a lot:
 
  if ( isset($_GET['something'])  !empty($_GET['something']) ) {
  // do something here with $_GET['something']
  }
  
  The isset is a pointless waste of cycles.
  
  -Stut
  
 well, as the OP said, he wants to know when the variable has a value other 
 the .
 
 So, to check for that you have to do something like this right?
 
   if ( $var != '' ) {}
   if ( strlen($var)  0 ) {}
   if ( !empty($var) ) {}
   ... a number of other ideas come to mind, but
 
 none of them will work, because they will always product a E_NOTICE warning.
 
 You COULD always use empty() prefixed with an @ to quiet the E_NOTICE,

Stut wouldn't do that... especially not after calling isset() a waste of
cycles. using the @ to suppress warnings/errors still invokes the error
system, and that includes any error handler you've custom hooked.

Maybe Stut just writes bad code ;) ;)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



RE: [PHP] how to get var name and value from function?

2007-04-16 Thread Ford, Mike
On 16 April 2007 16:18, Tijnema ! wrote:

 On 4/16/07, Ford, Mike [EMAIL PROTECTED] wrote:
  On 14 April 2007 13:16, Afan Pasalic wrote:
  
   Tijnema ! wrote:
On 4/14/07, Afan Pasalic [EMAIL PROTECTED] wrote:
 function value2var($array, $print=0)
 {
foreach ($_POST as $key = $value)

I think you should change above line to :

   foreach ($array as $key = $value)
   yup! it's print error. I meant $array.
{
${$key} = $value;
echo ($print ==1) ? $key.': '.$value.'br';
   // to test
 results and seeing array variables and values
}
 }
 
 value2var($_POST, 1);
 
 but, I don't know how to get info from function back to
 script?!?!? :-(

Uhm, it's not even possible when you don't know the
 keys i believe.
   after 2 hours of testing and research I realized this too, but
   want to be sure. :-(
  
  If you really *must* do this yourself (but others have
 pointed out the folly of it), this would do it:
  
  function value2var($array)
  {
 foreach ($array as $key = $value)
 {
 $GLOBALS['$key'] = $value;
 }
  }
 
 What's the sense in above function? you're putting the variables from
 1 array in another... you could use array_merge for this.
 But even then it's quite useless...

No, not just another array (although I agree about the function being pretty 
useless!) -- $GLOBALS is a superglobal array that contains a reference to every 
variable defined in the global scope, so that accessing $GLOBALS['var'] from 
anywhere is the same as accessing $var in the global scope.  It's a way of 
referencing global variables without having to use a global $var statement.

I was simply pointing out how you can to get info from function back to 
script when you don't know the keys, which you'd just said you believed was 
impossible! ;) ;)

Having done which, I proceeded to point out that:

  ... or, alternatively, rather than defining you own
 function, use extract() (http://php.net/extract) with one of
 the overwrite safety options to avoid blobbing existing variables.
 
 That's a better idea. :)

... Precisely ;)

   foreach (array('name', 'address', 'email', 'setting1', 'setting2')
 as $key): $GLOBALS[$key] = $array[$key];
   endforeach;
 
 endforeach? never heard of that statement before, does it
 really exist in PHP?

Of course -- would I give you non-working code? (Well, on purpose, anyway! ;) 
See http://php.net/manual/en/control-structures.alternative-syntax.php

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] isset

2007-04-16 Thread Stut

Jim Lucas wrote:

Stut wrote:

tedd wrote:

At 4:08 PM +0100 4/16/07, Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because 
$_REQUEST['var'] = 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}


The isset is a pointless waste of cycles.

-Stut


I've been accuse of that too, but what's your solution?


In the above example,

  if (isset($_GET['something'])  !empty($_GET['something'])) {

is the same as...

  if (!empty($_GET['something'])) {

So, in that particular line of code the isset is a pointless waste of 
cycles.


-Stut

these two lines are not the same infact, with the first, you will not 
get a E_NOTICE warning, but with the second you will.


No you won't. The empty function does not raise a notice if its argument 
does not exist.


From http://php.net/empty...

empty() is the opposite of (boolean) var, except that no warning is 
generated when the variable is not set.


-Stut

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



Re: [PHP] Shiny Floor (web 2.0) effect with GD Library

2007-04-16 Thread Graham Anderson
Here is an example of a 'Shiny Floor' effect (dynamically generated  
with flash).

http://alistapart.com/d/semanticflash/shiny/


look like the one in my kitchen or one of those old Java water  
effects?

Personally, I prefer the Quicktime 'Fire' effect.

As to the effect itself, I wanted to see if the wheel had already  
been invented with gd.



many thanks



On Apr 16, 2007, at 10:14 AM, Jay Blanchard wrote:


[snip]
web 2.0
[/snip]

There is a new web? Do you have an example of the shiny floor? Does it
look like the one in my kitchen or one of those old Java water  
effects?


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



RE: [PHP] auto page generation

2007-04-16 Thread Tim
 

 -Message d'origine-
 De : tedd [mailto:[EMAIL PROTECTED] 
 Envoyé : lundi 16 avril 2007 15:59
 À : Jeremy Adams
 Cc : php-general@lists.php.net
 Objet : Re: [PHP] auto page generation
 
 At 1:31 AM -0400 4/16/07, Jeremy Adams wrote:
 I'm building a website right now that will be a database of 
 attractions 
 in the Carolina and Virginia area.
 The idea is that attraction owners can submit data to the 
 database and 
 the database will automatically generate a page containing 
 that information.
 What I'm trying to figure out is how to generate the pages 
 automatically and have links to them added to the site.  If someone 
 could help me or point me in the direction of a book or web 
 page that 
 covers this I would really appreciate it.
 
 Jeremy:
 
 Welcome to php and mysql, because if you're going to do it 
 yourself, then you're going to have to learn it.
 
 Here's some online tutorials to introduce you.
 
 http://www.htmlgoodies.com/beyond/php/article.php/3472391
 http://www.w3schools.com/php/default.asp
 http://www.weberdev.com/ViewArticle/433
 http://www.weberdev.com/Manuals/PHP/
 http://www.unf.edu/~rita0001/eresources/php_tutorials/index.htm
 
 As you develop, post specific problems on this list and we'll help.
 
 Plus, it would be a good idea to buy a few of books on the 
 subject like the PHP Cookbook, MSQL Cookbook, PHP Developer's 
 Cookbook and PHP Security (not a cookbook). As you see, I'm 
 big into Cookbooks.

Also can i reccomend:

Web Database Applications with PHP and MySQL

 
 However, that's a minor fraction of the php, mysql, 
 javascript, and other books I've purchased to do what you're 
 wanting to do. It might be cheaper and quicker to hire one of us.
 

Tim

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



RE: [PHP] Shiny Floor (web 2.0) effect with GD Library

2007-04-16 Thread Jay Blanchard
[snip]
Here is an example of a 'Shiny Floor' effect (dynamically generated  
with flash).
http://alistapart.com/d/semanticflash/shiny/
[/snip]

Ah, so it really isn't Web 2.0, it is just a neat graphics effect.

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



Re: [PHP] Shiny Floor (web 2.0) effect with GD Library

2007-04-16 Thread Richard Davey

Graham Anderson wrote:


Has anyone created that web 2.0 shiny floor  effect with the GD Library?
I have seen it dynamically created by passing variables into a Flash 
movie.  Has this been done with GD?


http://reflection.corephp.co.uk

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] how to get var name and value from function?

2007-04-16 Thread Tijnema !

On 4/16/07, Ford, Mike [EMAIL PROTECTED] wrote:

On 16 April 2007 16:18, Tijnema ! wrote:

 On 4/16/07, Ford, Mike [EMAIL PROTECTED] wrote:
  On 14 April 2007 13:16, Afan Pasalic wrote:
 
   Tijnema ! wrote:
On 4/14/07, Afan Pasalic [EMAIL PROTECTED] wrote:
 function value2var($array, $print=0)
 {
foreach ($_POST as $key = $value)
   
I think you should change above line to :
   
   foreach ($array as $key = $value)
   yup! it's print error. I meant $array.
{
${$key} = $value;
echo ($print ==1) ? $key.': '.$value.'br';
   // to test
 results and seeing array variables and values
}
 }

 value2var($_POST, 1);

 but, I don't know how to get info from function back to
 script?!?!? :-(
   
Uhm, it's not even possible when you don't know the
 keys i believe.
   after 2 hours of testing and research I realized this too, but
   want to be sure. :-(
 
  If you really *must* do this yourself (but others have
 pointed out the folly of it), this would do it:
 
  function value2var($array)
  {
 foreach ($array as $key = $value)
 {
 $GLOBALS['$key'] = $value;
 }
  }

 What's the sense in above function? you're putting the variables from
 1 array in another... you could use array_merge for this.
 But even then it's quite useless...

No, not just another array (although I agree about the function being pretty useless!) 
-- $GLOBALS is a superglobal array that contains a reference to every variable defined in the 
global scope, so that accessing $GLOBALS['var'] from anywhere is the same as accessing $var in the 
global scope.  It's a way of referencing global variables without having to use a global 
$var statement.


but $_GET and $_POST are also global variables, so you transfer
variables from one global variable to another :)



I was simply pointing out how you can to get info from function back to script 
when you don't know the keys, which you'd just said you believed was impossible! ;) ;)


You can also return an array ;)
I mean to say returning multiple variables (not arrays)



Having done which, I proceeded to point out that:

  ... or, alternatively, rather than defining you own
 function, use extract() (http://php.net/extract) with one of
 the overwrite safety options to avoid blobbing existing variables.

 That's a better idea. :)

... Precisely ;)

   foreach (array('name', 'address', 'email', 'setting1', 'setting2')
 as $key): $GLOBALS[$key] = $array[$key];
   endforeach;

 endforeach? never heard of that statement before, does it
 really exist in PHP?

Of course -- would I give you non-working code? (Well, on purpose, anyway! ;) 
See http://php.net/manual/en/control-structures.alternative-syntax.php

Cheers!

Mike


Never knew there was an alternative syntax... (in all these years...)

Of course you would (try to) give working code, but you could've be
confused by other programming languages :)

Tijnema

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



Re: [PHP] isset

2007-04-16 Thread Jim Lucas

Stut wrote:

Jim Lucas wrote:

Stut wrote:

tedd wrote:

At 4:08 PM +0100 4/16/07, Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because 
$_REQUEST['var'] = 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}


The isset is a pointless waste of cycles.

-Stut


I've been accuse of that too, but what's your solution?


In the above example,

  if (isset($_GET['something'])  !empty($_GET['something'])) {

is the same as...

  if (!empty($_GET['something'])) {

So, in that particular line of code the isset is a pointless waste of 
cycles.


-Stut

these two lines are not the same infact, with the first, you will not 
get a E_NOTICE warning, but with the second you will.


No you won't. The empty function does not raise a notice if its argument 
does not exist.


 From http://php.net/empty...

empty() is the opposite of (boolean) var, except that no warning is 
generated when the variable is not set.


-Stut


Interesting, have not looked at the empty() man page in a long time.

It use to through E_NOTICE warnings, as far back as I can remember back in 
1999, and 2000

I wonder if they changed it, or the person that told me to do it that way was 
mistaken.

my mistake.

But, as you can tell, others were under the same impression as I.

--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times 
for you and me when all such things agree.


- Rush

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



Re: [PHP] isset

2007-04-16 Thread Robert Cummings
On Mon, 2007-04-16 at 18:16 +0100, Stut wrote:
 Jim Lucas wrote:
  Stut wrote:
  tedd wrote:
  At 4:08 PM +0100 4/16/07, Stut wrote:
  Jim Lucas wrote:
  Richard Kurth wrote:
  What do you do when isset does not work? If I send data in a
  $_REQUEST['var'] like if (isset($_REQUEST['var'])) {
  }
  Put var has no data it still says it is set. Because 
  $_REQUEST['var'] = 
  and isset thinks  is set
 
  I use this combination a lot:
 
  if ( isset($_GET['something'])  !empty($_GET['something']) ) {
  // do something here with $_GET['something']
  }
 
  The isset is a pointless waste of cycles.
 
  -Stut
 
  I've been accuse of that too, but what's your solution?
 
  In the above example,
 
if (isset($_GET['something'])  !empty($_GET['something'])) {
 
  is the same as...
 
if (!empty($_GET['something'])) {
 
  So, in that particular line of code the isset is a pointless waste of 
  cycles.
 
  -Stut
 
  these two lines are not the same infact, with the first, you will not 
  get a E_NOTICE warning, but with the second you will.
 
 No you won't. The empty function does not raise a notice if its argument 
 does not exist.
 
  From http://php.net/empty...
 
 empty() is the opposite of (boolean) var, except that no warning is 
 generated when the variable is not set.

Bleh, my mistake... I'm so adverse to empty() I forgot it doesn't
generate notices.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Shiny Floor (web 2.0) effect with GD Library

2007-04-16 Thread Graham Anderson

Many Thanks :)

That would be it.



On Apr 16, 2007, at 10:25 AM, Richard Davey wrote:


Graham Anderson wrote:

Has anyone created that web 2.0 shiny floor  effect with the GD  
Library?
I have seen it dynamically created by passing variables into a  
Flash movie.  Has this been done with GD?


http://reflection.corephp.co.uk

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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


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



RE: [PHP] Saving css state in javascript and passing to php via form submit

2007-04-16 Thread Tim
...
 
 You could use AJAX to get things from/to PHP, but why should 
 you? You can use session within javascript too i believe.
 
   Tijnema
  
   ps. Maybe you could also use AJAX instead of submitting forms the 
   whole time.

...

 Really, it's not that hard to use AJAX. You might want to 
 look at www.tizag.com, there it is really easy explained. 
 It's nothing more then making new request to scripts inside 
 javascript.
 


Was a great idea and also works great until the moment i needed to upload
images :P
You have a suggestion for that by any chance Tijnema?

Regards,

Tim

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



TR: [PHP] auto page generation

2007-04-16 Thread Tim
tim says: 
forwarding to list as was sent to me directly:



 
Thanks everyone, I'll look into all of this.  I'm trying to learn all of
this since I'm starting school next semester for Computer programming and am
trying to get some understanding of the concepts by building web pages. 

If anyone wants to take a look at what I'm working on you can go here
http://www.nchaunts.com/new/index.html . Any suggestions are appreciated.
We're really trying to have the new site live by the end of the month. 

Another problem I'm having is in the submit to database function the region
option is always blank.  


On 4/16/07, Tim  [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  wrote: 



 -Message d'origine-
 De : tedd [mailto: [EMAIL PROTECTED]
 Envoyé : lundi 16 avril 2007 15:59
 À : Jeremy Adams
 Cc : php-general@lists.php.net
 Objet : Re: [PHP] auto page generation 

 At 1:31 AM -0400 4/16/07, Jeremy Adams wrote:
 I'm building a website right now that will be a database of
 attractions
 in the Carolina and Virginia area.
 The idea is that attraction owners can submit data to the 
 database and
 the database will automatically generate a page containing
 that information.
 What I'm trying to figure out is how to generate the pages
 automatically and have links to them added to the site.  If someone 
 could help me or point me in the direction of a book or web
 page that
 covers this I would really appreciate it.

 Jeremy:

 Welcome to php and mysql, because if you're going to do it 
 yourself, then you're going to have to learn it.

 Here's some online tutorials to introduce you.

 http://www.htmlgoodies.com/beyond/php/article.php/3472391
http://www.htmlgoodies.com/beyond/php/article.php/3472391 
 http://www.w3schools.com/php/default.asp
 http://www.weberdev.com/ViewArticle/433
 http://www.weberdev.com/Manuals/PHP/
 http://www.unf.edu/~rita0001/eresources/php_tutorials/index.htm

 As you develop, post specific problems on this list and we'll help. 

 Plus, it would be a good idea to buy a few of books on the
 subject like the PHP Cookbook, MSQL Cookbook, PHP Developer's
 Cookbook and PHP Security (not a cookbook). As you see, I'm 
 big into Cookbooks.

Also can i reccomend:

Web Database Applications with PHP and MySQL


 However, that's a minor fraction of the php, mysql,
 javascript, and other books I've purchased to do what you're 
 wanting to do. It might be cheaper and quicker to hire one of us.


Tim






RE: [PHP] Problems when trying to use ibm_db2 extension

2007-04-16 Thread Buesching, Logan J
My first guess would be to make sure that the version of PHP that you
are running from CLI is the same as the one running as an apache module,
and that they are configured the same.  When running the CLI, do an 

?php phpinfo(); ?

And compare the output with what you get from doing the same thing from
the web.

-Logan

-Original Message-
From: Leo Jokinen [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 16, 2007 10:22 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED];
php-general@lists.php.net
Subject: [PHP] Problems when trying to use ibm_db2 extension

Hi all,

I've been banging my head into the wall cause I can't get ibm_db2 
extension working with Apache 2.0.59 and PHP 5.2.1 (as apache module).
(Operating system is winxp pro SP2)

For some reason, this code is working on command line but not when 
placed to htdocs folder:

 ?php
 if(function_exists('db2_connect')) {
   echo 'Function db2_connect() exists';
 } else {
   echo 'Unknown function db2_connect()';
   exit;
 }
 
 echo \nTrying to connect DB2 database..\n;
 
 $database = 'services';
 $user = 'db2admin';
 $password = 'xxx';
 $hostname = '127.0.0.1';
 $port = 5;
 $conn_string = DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database; .

HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;;
 $conn = db2_connect($conn_string, '', '');
 
 if ($conn) {
   echo OK: Connection established\n;
   db2_close($conn);
 } else {
   echo ERROR: Connection failed\n;
 }
 ?

Command line output:
 C:\php c:\db2_test.php
 Function db2_connect() exists
 Trying to connect DB2 database..
 OK: Connection established

Web output:
 Unknown function db2_connect()

Some extra output:
 Fatal error: Call to undefined function db2_connect() in
F:\www\services.itella.net\app\webroot\index.php on line 57

Also, phpinfo() won't say nothing that module ibm_db2 is in use

More info:

php_ibm_db2.dll file is in folder C:/php-5.2.1/ext

php.ini:
extension_dir = C:/php-5.2.1/ext
extension=php_ibm_db2.dll

httpd.conf:
AddType application/x-httpd-php .php
LoadModule php5_module C:/php-5.2.1/php5apache2.dll
PHPIniDir C:/php-5.2.1/


Can someone point out the right direction for me?

Regards

Leo Jokinen

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

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



[PHP] Re: header('Location:') works locally but not remotely

2007-04-16 Thread Ross
ok I have a page that calls my my functions, basically a 6 step signup. All 
the steps look like this

function step_one() {

$_SESSION['property_id'] =$_POST['property_id'];
$property_id = $_POST['property_id'];
$postcode= $_POST['postcode'];
$query = INSERT INTO properties (property_id, postcode) VALUES 
('$property_id', '$postcode');
$result= mysql_query($query);
header( 'Location: ?step=two' );
}

This SHOULD redirect to

add_new.php?step=two

As add_new is the container page.

Thanks.

R. 

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



RE: [PHP] Re: header('Location:') works locally but not remotely

2007-04-16 Thread Tim
 

 -Message d'origine-
 De : Ross [mailto:[EMAIL PROTECTED] 
 Envoyé : lundi 16 avril 2007 19:45
 À : php-general@lists.php.net
 Objet : [PHP] Re: header('Location:') works locally but not remotely
 
 ok I have a page that calls my my functions, basically a 6 
 step signup. All the steps look like this
 
 function step_one() {
 
 $_SESSION['property_id'] =$_POST['property_id']; $property_id 
 = $_POST['property_id']; $postcode= $_POST['postcode']; 
 $query = INSERT INTO properties (property_id, postcode) 
 VALUES ('$property_id', '$postcode'); $result= 
 mysql_query($query); header( 'Location: ?step=two' ); }

php.net
http://fr.php.net/header:

Note:  HTTP/1.1 requires an absolute URI as argument to » Location:
including the scheme, hostname and absolute path, but some clients accept
relative URIs. You can usually use $_SERVER['HTTP_HOST'],
$_SERVER['PHP_SELF']  and dirname() to make an absolute URI from a relative
one yourself
/php.net

Could this be your issue? I always use full URI for header('location:

Regards,

Tim

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



Re: [PHP] how to get var name and value from function?

2007-04-16 Thread Jim Lucas

Afan Pasalic wrote:

hi,
this one I can't figure out:

I have to assign value of an array to variable named after key of the
array several times in my project to , e.g. after I submit a form with
personal info I have
$_POST['name'] = 'john doe';
$_POST['address'] = '123 main st.';
$_POST['city'] = 'urbandale';
$_POST['zip'] = '12345';
$_POST['phone'] = '123-456-7980';
etc.

Then I assign value to the var name:
foreach ($_POST as $key = $value)
{
${$key} = $value;
}
and then validate submitted.

Though, to avoid writing all over again the same lines (even it's only 3
lines) I was thinking to create a function something like:

function value2var($array, $print=0)
{
foreach ($_POST as $key = $value)
{
${$key} = $value;
echo ($print ==1) ? $key.': '.$value.'br'; // to test
results and seeing array variables and values
}
}

value2var($_POST, 1);

but, I don't know how to get info from function back to script?!?!?
:-(

any help appreciated.

-afan


well, I would do something like this.

function value2var($in, $wanted=array(), $print=false) {
if ( ! is_array($wanted) ) {
$tmp = array($wanted);
} else {
if ( count($wanted)  0 ) {
$tmp = $wanted;
} else {
$tmp = array_keys($in);
}
}
$myArr = array();
foreach ($tmp as $key) {
if ( isset($in[$key])  !empty($in[$key]) ) {
$value = validate_data($in[$key], $key);
}
$value = '';
}
$myArr[$key] = $value;
// to test results and seeing array variables and values
if ( $print )
echo $key.': '.$value.'br';
}
}
return $myArr;
}


// Say $_POST looked like this
$_POST['first_name'] = 'John';
$_POST['last_name'] = 'Doe';
$_POST['address1'] = '123 Someplace Dr.';
$_POST['something_else'] = 'Some Value';

$wanted = array('first_name', 'last_name', 'address1');

extract(value2var($_POST, $wanted, TRUE), EXTR_SKIP, 'CLEAN');

//  The EXTR_SKIP option will force extract not to create the variable if it 
already exists.
//  Check out http://us2.php.net/extract for other options that could replace 
EXTR_SKIP

//  After running the above line, you should end of with the variables that 
follow

echo $CLEAN_first_name;  // This should echo John
echo $CLEAN_last_name;  // This should echo Doe
echo $CLEAN_address1;  // This should echo 123 Someplace Dr.

// and the something_else variable will not have been created as $CLEAN_something_else, because it 
did not exist in the $wanted array


--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times 
for you and me when all such things agree.


- Rush

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



RE: [PHP] Re: header('Location:') works locally but not remotely

2007-04-16 Thread Tim
 

 -Message d'origine-
 De : Tim [mailto:[EMAIL PROTECTED] 
 Envoyé : lundi 16 avril 2007 19:54
 À : 'Ross'; php-general@lists.php.net
 Objet : RE: [PHP] Re: header('Location:') works locally but 
 not remotely
 
  
 
  -Message d'origine-
  De : Ross [mailto:[EMAIL PROTECTED] 
  Envoyé : lundi 16 avril 2007 19:45
  À : php-general@lists.php.net
  Objet : [PHP] Re: header('Location:') works locally but not remotely
  
  ok I have a page that calls my my functions, basically a 6 
  step signup. All the steps look like this
  
  function step_one() {
  
  $_SESSION['property_id'] =$_POST['property_id']; $property_id 
  = $_POST['property_id']; $postcode= $_POST['postcode']; 
  $query = INSERT INTO properties (property_id, postcode) 
  VALUES ('$property_id', '$postcode'); $result= 
  mysql_query($query); header( 'Location: ?step=two' ); }
 
 php.net
 http://fr.php.net/header:
 
 Note:  HTTP/1.1 requires an absolute URI as argument to » Location:
 including the scheme, hostname and absolute path, but some 
 clients accept
 relative URIs. You can usually use $_SERVER['HTTP_HOST'],
 $_SERVER['PHP_SELF']  and dirname() to make an absolute URI 
 from a relative
 one yourself
 /php.net
 
 Could this be your issue? I always use full URI for 
 header('location:

Sorry i meant i always use full host/uri/extra schema

Tim

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



Re: [PHP] isset

2007-04-16 Thread Edward Vermillion


On Apr 16, 2007, at 12:30 PM, Robert Cummings wrote:

[snip]




Bleh, my mistake... I'm so adverse to empty() I forgot it doesn't
generate notices.



Lemme guess... You don't like empty() because it thinks null/0/'' is  
empty? Or is there some other reason?


Agreed, it can be tricky if you just use it everywhere, but for most  
things, especially replacing a


if (isset($foo)  $foo != 0/null/''/array()) {}

with

if (!empty($foo))

makes my life a little easier. Especially checking for empty arrays  
since foreach on an empty array will throw a notice or warning, I  
forget which atm.


Of course if null/0/'' are considered valid values in your code then  
you're pretty much stuck with isset() and checking for the value.


And doesn't it also consider 'null' (the string) as empty? Seems like  
I've read folks complaining that returns from a database that are set  
to null get missed also... but since I don't have any code that  
considers null a useful value it's never been a problem for me.


Ed

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



Re: [PHP] Re: header('Location:') works locally but not remotely

2007-04-16 Thread Philip Thompson

On Apr 16, 2007, at 12:44 PM, Ross wrote:

ok I have a page that calls my my functions, basically a 6 step  
signup. All

the steps look like this

function step_one() {

$_SESSION['property_id'] =$_POST['property_id'];
$property_id = $_POST['property_id'];
$postcode= $_POST['postcode'];


Escape your data:
$property_id = mysql_real_escape_string($_POST['property_id']);
$postcode = mysql_real_escape_string($_POST['postcode']);



$query = INSERT INTO properties (property_id, postcode) VALUES
('$property_id', '$postcode');
$result= mysql_query($query);
header( 'Location: ?step=two' );


As others have mentioned, you must include at least the relative path.

header (Location: add_new.php?step=two);
exit;

Always include 'exit;' after a redirect. Happy coding...

~Philip



}

This SHOULD redirect to

add_new.php?step=two

As add_new is the container page.

Thanks.

R.


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



Re: [PHP] isset

2007-04-16 Thread Robert Cummings
On Mon, 2007-04-16 at 13:16 -0500, Edward Vermillion wrote:
 On Apr 16, 2007, at 12:30 PM, Robert Cummings wrote:
 
 [snip]
 
 
 
  Bleh, my mistake... I'm so adverse to empty() I forgot it doesn't
  generate notices.
 

Strings only containing only spaces are not empty. Strings containing a
0 are empty. It's crap for almost any kind of validation routine. It's
one of those useless, magical, shoot newbies in the toes functions. But
then I guess to each their own :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Re: post via text message?

2007-04-16 Thread Manuel Lemos
Hello,

on 04/16/2007 11:14 AM blackwater dev said the following:
 I'm working on a site where I need to allow someone to send me a text
 message and let the code take their message and respond or post it in the
 db.  Can someone point me in the right direction on how this is done?

You need several classes for what you want. Take a look at these classes:

POP3class
Read messages from a mailbox
http://www.phpclasses.org/pop3class

MIME Parser
Parse messages and retrieve their parts
http://www.phpclasses.org/mimeparser

Metabase
Database independent abstraction package that supports many types of
databases. Supports BLOB fields, in case you want to store attachments
http://www.phpclasses.org/metabase

MIME message composing and sending
Compose and send standards compliant e-mail messages. Supports text
wrapping and quoting, which is useful to generate automatic replies
quoting the original message
http://www.phpclasses.org/mimemessage

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



[PHP] Re: PHP Dynamic Form Generator

2007-04-16 Thread Manuel Lemos
Hello,

on 04/16/2007 11:14 AM Tom Chubb said the following:
 Dear list,
 I'm currently reviewing a load of scripts to dynamically generate a form
 for
 a membership system.
 I have designed a registration form, and once registered and logged in
 there
 are a load of different options relevant to people's profile (which will
 all
 be radio check boxes) in a 2nd form.
 As the number of these check-boxes may change, I'd like to be able to read
 the structure of the relevant table and generate the form from that.
 I just wanted to ask everyone for any advice on this and which scripts you
 use? I'm not being lazy, but currently I'm looking at 8 of them from
 phpclasses.org and sourceforge and I'm sure someone out there knows exactly
 what I'm looking for.
 Thanks in advance,

I suppose you have evaluated already the PHP Forms Generation and
Validation class. Among many other things, it can validate groups of
checkbox or radio buttons to assure that at least on is checked.

http://www.phpclasses.org/formsgeneration

Take a look here at a live example that demonstrates that:

http://www.meta-language.net/forms-examples.html?example=test_form

or look at this tutorial video that explains the features employed in
the example above:

http://www.phpclasses.org/browse/video/1/package/1/section/example-form.html


-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



Re: [PHP] isset

2007-04-16 Thread Edward Vermillion


On Apr 16, 2007, at 1:28 PM, Robert Cummings wrote:


On Mon, 2007-04-16 at 13:16 -0500, Edward Vermillion wrote:

On Apr 16, 2007, at 12:30 PM, Robert Cummings wrote:

[snip]




Bleh, my mistake... I'm so adverse to empty() I forgot it doesn't
generate notices.



Strings only containing only spaces are not empty. Strings  
containing a

0 are empty. It's crap for almost any kind of validation routine. It's
one of those useless, magical, shoot newbies in the toes functions.  
But

then I guess to each their own :)



Strings containing spaces and 0's (and null), while technically not  
empty, may or may not have any meaning in your code outside of being  
empty or at least not interesting. That's why I qualified it with  
whether they have meaning in the code.


I'll agree that it can cause problems if you're not paying attention,  
I've been bitten myself in the past by it. And those things can be  
hard to track down too. :P


Ed

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



Re: [PHP] Saving css state in javascript and passing to php via form submit

2007-04-16 Thread Tijnema !

On 4/16/07, Tim [EMAIL PROTECTED] wrote:

...

 You could use AJAX to get things from/to PHP, but why should
 you? You can use session within javascript too i believe.
 
   Tijnema
  
   ps. Maybe you could also use AJAX instead of submitting forms the
   whole time.

...

 Really, it's not that hard to use AJAX. You might want to
 look at www.tizag.com, there it is really easy explained.
 It's nothing more then making new request to scripts inside
 javascript.



Was a great idea and also works great until the moment i needed to upload
images :P
You have a suggestion for that by any chance Tijnema?

Regards,

Tim


I would use an iframe for this.Didn't test following code, but shoudl
work though.
iframe name=imgupload/iframe
form action=upload.php method=post target=imgupload
enctype=multipart/form-data
input type=fileinput type=submit value=upload/form
and now just make sure that your upload.php script doesn't return
anything, or it will be displayed inside the iframe :)
If you want to know when upload is done, you should check that through
AJAX. you could give the upload an unique number, and store the
results of the upload in a database for example, then request that id
once in 10 seconds lets say, and when it's done it will return
something useful :)

Tijnema






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



[PHP] I make a patch, how I report?

2007-04-16 Thread Fernando chucre

Hello all,

I buid a patch for wrapper php fopen. In this patch I create a way for
the script access the filedescriptos opened by process. Ex:

php file.php 3file_in.txt 7file_out.txt

In this case the script can't read the filedescriptor 3 and 7. Not
have way for read or write in filedescriptor opends by precess.

I make a way for read or write it. A modify de wrapper 'php' for fopen
function. (http://br.php.net/manual/en/wrappers.php.php) A create the
'php:/fd/N' which N is the filedescriptor number.

how to access fd 7 to write?

ex:

?
$fd = fopen(php://fd/7,'w');
fwrite($fd,test of write\n);
fclose($fd);
?

I want know who I send the patch for to be avaliable. Thanks.

--
Fernando Chure
PSL/CE - Brasil

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



Re: [PHP] I make a patch, how I report?

2007-04-16 Thread Tijnema !

On 4/16/07, Fernando chucre [EMAIL PROTECTED] wrote:

Hello all,

I buid a patch for wrapper php fopen. In this patch I create a way for
the script access the filedescriptos opened by process. Ex:

php file.php 3file_in.txt 7file_out.txt

In this case the script can't read the filedescriptor 3 and 7. Not
have way for read or write in filedescriptor opends by precess.

I make a way for read or write it. A modify de wrapper 'php' for fopen
function. (http://br.php.net/manual/en/wrappers.php.php) A create the
'php:/fd/N' which N is the filedescriptor number.

how to access fd 7 to write?

ex:

?
$fd = fopen(php://fd/7,'w');
fwrite($fd,test of write\n);
fclose($fd);
?

I want know who I send the patch for to be avaliable. Thanks.

--
Fernando Chure
PSL/CE - Brasil


Post it to the PHP internals list: [EMAIL PROTECTED], or
subscribe to the list, send empty message to
[EMAIL PROTECTED] and then post it.

Tijnema

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



Re: [PHP] I make a patch, how I report?

2007-04-16 Thread Jochem Maas
Fernando chucre wrote:
 Hello all,
 
 I buid a patch for wrapper php fopen. In this patch I create a way for
 the script access the filedescriptos opened by process. Ex:
 
 php file.php 3file_in.txt 7file_out.txt
 
 In this case the script can't read the filedescriptor 3 and 7. Not
 have way for read or write in filedescriptor opends by precess.
 
 I make a way for read or write it. A modify de wrapper 'php' for fopen
 function. (http://br.php.net/manual/en/wrappers.php.php) A create the
 'php:/fd/N' which N is the filedescriptor number.
 
 how to access fd 7 to write?
 
 ex:
 
 ?
 $fd = fopen(php://fd/7,'w');
 fwrite($fd,test of write\n);
 fclose($fd);
 ?
 
 I want know who I send the patch for to be avaliable. Thanks.

try [EMAIL PROTECTED]

 

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



Re: [PHP] Array remove function?

2007-04-16 Thread Tijnema !

On 4/16/07, Jochem Maas [EMAIL PROTECTED] wrote:

Richard Lynch wrote:
 On Wed, April 11, 2007 9:00 pm, Jochem Maas wrote:
 [PS - I've the pleasure of listening to a colleague do a manual
 install
 of Vista over an existing copy of XP and then get the really tricky
 stuff
 like the soundcard to work ... for the last week :-/]

 Give them an Ubuntu (or similar) CD and see if they want to just leave
 the Dark Side... :-)

yeah, but the vista story keeps getting worse.
how about:

1. '50% of applications can't use network because the router is in compatible 
with vista'

   a total WTF, apparently due to vista network 'auto-tuning' - can only be 
turned off
   via the cmdline.

2. undo/redo function in a whole stack of programs doesn't work unless you
run the program in 'administrator mode'

   omg.

3. openvpn doesn't work ... unless you run it in 'administrator mode'

4. when you finally give trying to run anything as anything other than an 
adminstrator
user your still confronted with that freakin' 'administrator mode' popup (which 
also
greys out the rest of the desktop) *everytime* you breath too loudly.

5. don't delete a folder if you want to get anything done today ... well at the 
least you'll
probably get a chance to grab a another cup of coffee.

6. er ... I'll keep you posted.


How off-topic is this?
Remember, this is the PHP list, not the Vista list.

Tijnema

ps. The name Microsoft is not really the right name for the company,
it should have been called Megasoft, because vista is overkill in
size.

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



Re: [PHP] isset

2007-04-16 Thread Stut

Robert Cummings wrote:

On Mon, 2007-04-16 at 09:27 -0700, Jim Lucas wrote:

Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because $_REQUEST['var'] 
= 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}

The isset is a pointless waste of cycles.

-Stut


well, as the OP said, he wants to know when the variable has a value other the 
.

So, to check for that you have to do something like this right?

if ( $var != '' ) {}
if ( strlen($var)  0 ) {}
if ( !empty($var) ) {}
... a number of other ideas come to mind, but

none of them will work, because they will always product a E_NOTICE warning.

You COULD always use empty() prefixed with an @ to quiet the E_NOTICE,


Stut wouldn't do that... especially not after calling isset() a waste of
cycles. using the @ to suppress warnings/errors still invokes the error
system, and that includes any error handler you've custom hooked.

Maybe Stut just writes bad code ;) ;)


I'm thinking I just know some parts of the language better than you lot. 
You guys really should try reading the manual before responding instead 
of just assuming it's the way you think it is.


As far as my coding style goes, that's between me and my $DEITY, but let 
it be noted that even my production servers run with error_reporting as 
E_ALL (but logged to files and not displayed obviously). Knowing how 
isset and empty work is essential to enabling my style of coding PHP, 
which I've found works very well for me.


-Stut

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



Re: [PHP] header('Location:') works locally but not remotely

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 11:16 am, Ross wrote:
 any reason why this should be?

Things that could go wrong:

1. output_buffering can make header work when it shouldn't because
it will buffer HTML (or other) output and then it works

2. Location: URLs are supposed to be full-blown URLs.  Maybe it
works when they're not, and maybe it doesn't.  Depends more on the
browser than on anything, but who knows fomr what little you've given
us...

3. Remote server *could* have header() function disabled in php.ini --
unlikely, but possible.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Problems when trying to use ibm_db2 extension

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 9:21 am, Leo Jokinen wrote:
 Also, phpinfo() won't say nothing that module ibm_db2 is in use

Did you re-start Apache?

Actually, Windows being Windows, just re-boot the dang thing...
You should be used to that. :-)

Is the php.ini file named in phpinfo() the one you are editing?

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] Problems with Curl and POST

2007-04-16 Thread mbneto

Hi,

I am tring to use curl to access, via POST, a remote 'service'.I've
managed to test it fine but when I use real data to feed the curl it gives
me strange results.

When I check the logs of the remote web server one thing that alarms me is
that with test data I see

A.B.C.D - - [16/Apr/2007:17:41:53 -0400] POST /service.php HTTP/1.1 200 61

with real data (using the same script)

A.B.C.D - - [16/Apr/2007:17:48:55 -0400] HEAD /service.php HTTP/1.1 200 -

After reading the user contributed notes I found that it must be related
with encoding.  But even if I use the suggested code

$o=;foreach ($post_data as $k=$v)
   {$o.=
$k=.utf8_encode($v).;}
   $post_data=substr($o,0,-1);

   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);

I get the same results.

Any tips?

php 5.0.4


Re: [PHP] post via text message?

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 9:14 am, blackwater dev wrote:
 I'm working on a site where I need to allow someone to send me a text
 message and let the code take their message and respond or post it in
 the
 db.  Can someone point me in the right direction on how this is done?

You mean like a cellphone text message?

Just Google for PHP SMS

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Importing data in to mysql with some control

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 12:43 am, Richard Kurth wrote:
 I am trying to write a import script for loading data into an existing
 mysql
 table. I want to show the import data on the screen and let the user
 select
 the column number to go with which mysql field. Now some of the fields
 are
 mandatory like firstname lastname email address and so on...
 But
 some of the fields might be custom fields these would be stored in a
 different table and the mysql fields would be custom1 custom2
 .   So
 the user would select what column go's with which field. No I know
 that some
 of this would have to be done server side. So I was thinking of using
 Ajax
 or just JavaScript. Does anybody know of any examples that show
 something
 like this being done. The only examples I have seen just shows data
 being
 imported into the database form csv file with out choosing where the
 data
 should go. It has to be in order when you run the script. Any ideas on
 where
 to look and how to get this started.

I had to do something similar for a mailing list import thingie once...

Back in PHP 3.0.12 days, according to my comments in the source I've
just located and uploaded for ya:
http://www.l-i-e.com/listbaby/

Huge grain of salt here, as it was one of my earlier projects and it
never went into production.  Well, actually, the shmrsh php script to
be a mailing list admin went live, but not the GUI bit.

I basically added a second table that stored any extra fields the
user chose with their own fieldnames as just another column in the DB.

FileMaker has a nice import that does this if you import CSV files. 
You may want to take a look at that if you know anybody who has
filemaker.

You also may want to consider allowing the user to compbine two or
more of their fields (firstname + lastname) into one of your fields.

Maybe even let them split a field into two according to some basic
rule on where to split.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Problems with Curl and POST

2007-04-16 Thread Richard Lynch
HEAD is just like GET, only it gets just the headers (hence the name)
usually to see if the document has changed according to LastModified:
before doing a full-blown GET.

There shouldn't be a HEAD done before a POST...

Are you sure you are doing a CURLOPT_POST and not CURLOPT_GET...?

On Mon, April 16, 2007 4:43 pm, mbneto wrote:
 Hi,

 I am tring to use curl to access, via POST, a remote 'service'.
 I've
 managed to test it fine but when I use real data to feed the curl it
 gives
 me strange results.

 When I check the logs of the remote web server one thing that alarms
 me is
 that with test data I see

 A.B.C.D - - [16/Apr/2007:17:41:53 -0400] POST /service.php HTTP/1.1
 200 61

 with real data (using the same script)

 A.B.C.D - - [16/Apr/2007:17:48:55 -0400] HEAD /service.php HTTP/1.1
 200 -

 After reading the user contributed notes I found that it must be
 related
 with encoding.  But even if I use the suggested code

 $o=;foreach ($post_data as $k=$v)
 {$o.=
 $k=.utf8_encode($v).;}
 $post_data=substr($o,0,-1);

 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);

 I get the same results.

 Any tips?

 php 5.0.4



-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] auto page generation

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 12:31 am, Jeremy Adams wrote:
 I'm building a website right now that will be a database of
 attractions in
 the Carolina and Virginia area.
 The idea is that attraction owners can submit data to the database and
 the
 database will automatically generate a page containing that
 information.
 What I'm trying to figure out is how to generate the pages
 automatically and
 have links to them added to the site.  If someone could help me or
 point me
 in the direction of a book or web page that covers this I would really
 appreciate it.

What you describe is just about the basis for every PHP MySQL Tutorial
#1 out there on the Internet...  Just pick one and run with it. :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Appending into associative arrays

2007-04-16 Thread Richard Lynch
On Sun, April 15, 2007 2:20 pm, Otto Wyss wrote:
 I want to sort directories according there modification time and
 thought
 accociative arrays would be perfect. But when I add an element like

 $dirs = array (filemtime($d) = $d)

 the previous ones are lost. I tried array_push but that doesn't seems
 to
 work, at least I always get syntax errors. Next try was
 array_merge(array (...)). So what next?

Two files may have the same modification time.

You are storing only ONE file for any given timestamp.

You could do something like this:

foreach($files as $file){
  $dirs[filemtime($file)][] = $file;
}

You will then have an ARRAY for each timestamp with all the files that
were modified at that time.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] simple form web site up date

2007-04-16 Thread Richard Lynch

See PHP manual section titled Handling File Uploads


On Sun, April 15, 2007 1:56 pm, Joker7 wrote:
 I have said I would host a couple of friends CV's as a web page,here's
 the
 situation I'd like to set it up so that it can updated it via a simple
 form.I've googled the subject a fair bit and all I can come up with is
 big
 full solutions when I only need a simple form and say a flat file
 system.Any
 one have an idea or better still know of a pre-made form ect.

 Cheers
 Chris

 --
 Cheap As Chips Broadband http://yeah.kick-butt.co.uk
 Superb hosting  domain name deals http://host.kick-butt.co.uk

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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] secure login

2007-04-16 Thread Richard Lynch
On Sun, April 15, 2007 4:15 am, Ross wrote:

 I am creating a single user secure login based on this:

 http://www.phpnoise.com/tutorials/26/1

For just one user, I'd just tossing in an .htaccess and .htpasswd
file, personally, and not bother with page after page of PHP.

 Can anyone see any potential security issues with this method? Where
 should
 I store the password/username can I just have it located in the
 pagehead?

If there is only one valid login, then I see no problem with just
storing it in source code.

I'd put it in an include file outside the web tree, personally, so
that the PHP source is less likely to get exposed by .htaccess files
getting lost or whatever can't happen.

Actually, you should probably store only the MD5 of the correct
password in your PHP source, and then not worry about anybody seeing
the source.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] preg_replace and regular expressions.

2007-04-16 Thread Richard Lynch
http://php.net/preg_replace_all

And be sure to use Ungreedy flag to your pattern:
/pattern/U

On Sat, April 14, 2007 11:22 pm, Travis Moore wrote:
 Okay, so what I have is a BB code type of thing for a CMS, which I for
 obvious reasons can't allow HTML.

 Here's the snippet of my function:

 
 function bbCode($str)
   {
$db = new _Mysql;
$strOld = $str;
$strNew = $str;
$getRegexs = $db-query(SELECT `regex`,`replace`,`search` FROM
 `_bb_codes`);
while ($getRegex = mysql_fetch_assoc($getRegexs))
 {
  $search = base64_decode($getRegex['search']);
  $regex = base64_decode($getRegex['regex']);
  $replace = base64_decode($getRegex['replace']);
  if (preg_match($search,$strNew) == 1)
   {
for ($i = 1; $i  20; $i++)
 {
  $strNew = $strOld;
   $strNew = preg_replace($regex,$replace,$strNew);
  if ($strNew == $strOld)
   {
break;
   }
  else
   {
$strOld = $strNew;
   }
 }
   }
 }
$return = $strNew;
return $return;
   }
 **

 But, for something like this:

 [quote][quote]Quote #2[/quote]Quote #1[/quote]No quote.

 I'll get:

 div class=quoteContainer
 [quote]Quote #2[/quote]Quote #1/div
 No quote.

 Despite being in the loop.

 Regex is: /\[quote\]((.*|\n)*)\[\/quote\]/
 Replace is: div class=messageQuote$1/div

 Both are stored base64 encoded in a database.

 Any help / suggestions much appreciated.

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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] isset

2007-04-16 Thread Richard Lynch
On Sat, April 14, 2007 8:36 pm, Richard Kurth wrote:
 What do you do when isset does not work? If I send data in a
 $_REQUEST['var'] like
 if (isset($_REQUEST['var'])) {
 }
 Put var has no data it still says it is set. Because $_REQUEST['var']
 = 
 and isset thinks  is set

It *is* set.

It just happens to be the empty string.

That is VERY different from not being set at all.

If you do not want to allow the empty string as a valid input, that
should, imho, be handled by your data validation routines, which
happen after your business logic of doing whatever based on isset()

http://php.net/strlen is a good one for that.

In other words, use isset() to decide what the user is trying to do
first.

Then use data validation to decide if they have provided
valid/suitable input.  If the input is egregious enough (i.e., no
normal human would ever generate that state) you can respond
differently with, say, die(hacker);

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] isset

2007-04-16 Thread Richard Lynch
On Sun, April 15, 2007 12:07 pm, [EMAIL PROTECTED] wrote:
 I have E_NOTICE turned off. :)

Your first mistake.

:-)

E_NOTICE on is a royal pain at first, but will catch bugs for you, and
save you development time in the long run.

Turn it on for your next new project and try it.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] isset

2007-04-16 Thread Tim Earl
 

 -Message d'origine-
 De : Robert Cummings [mailto:[EMAIL PROTECTED] 
 Envoyé : lundi 16 avril 2007 20:28
 À : Edward Vermillion
 Cc : php Lists
 Objet : Re: [PHP] isset
 
 On Mon, 2007-04-16 at 13:16 -0500, Edward Vermillion wrote:
  On Apr 16, 2007, at 12:30 PM, Robert Cummings wrote:
  
  [snip]
  
  
  
   Bleh, my mistake... I'm so adverse to empty() I forgot it doesn't 
   generate notices.
  
 
 Strings only containing only spaces are not empty. Strings 
 containing a 0 are empty. It's crap for almost any kind of 
 validation routine. It's one of those useless, magical, shoot 
 newbies in the toes functions. But then I guess to each their own :)

What about in the following context?

$arr = array();
If (!empty($arr)) { }

This is where i have found it to be the most usefull...


tim

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



Re: [PHP] isset

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 11:12 am, tedd wrote:
 I've been accuse of that too, but what's your solution?

*MY* solution:

Don't use empty because its behaviour changed wrt 0 in various
versions, so it's just gonna bite you in the butt like it did me. :-)

I generally do this basic algorithm:

#1
Use isset() to see what came in as inputs, to decide basic business
logic for large-scale chunks of code
Also use specific values with == for simple if/else or switch setup here

#2
Within an isset() (and possible == 'foo' block)
Check the validity of the data *WAY* more than just empty
  preg_match with a white-list pattern is good
  ctype for specific data is good
  checking with strlen() (possibly with trim() first) is good
  typecasting any data that should be of a certain type is good
  checking inputs against a static list of valid inputs is good

#3
Still within the block,
Prep input data for output formats as needed for this section:
  $foo_sql = mysql_real_escape_string($foo, $connection);
  $foo_html = htmlentities($foo);
  $foo_json = json_encode(foo);

Only after all that is done do I start actually doing fine-tuned
business logic of the body of my code.

I may end up repeating the same large structure I had above, to decide
what code to run, or maybe it will be a different structure, depending
on what the script does.

But all my data is clean and prepped at this point, so I can just use it.

Within that code, if I'm writing an SQL query, I can just do:

$query = whatever SQL blah blah '$foo_sql' blah ;

If I'm going to echo out $foo, I can just do:
echo whatever blah blah $foo_html blah ;

I just tossed in JSON even though I've never used it in my life so
far, but I presume it would be like:

?script type=text/javascript
!--
  var foo = ?php echo $foo_json?;
--
/script
?php



I'm not claiming this is the best way ever, or will work for the next
big thing with 50 developers, but it works well for my needs of simple
maintainable scripts in a one-man shop.

YMMV

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] isset

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 5:35 pm, Tim Earl wrote:
 What about in the following context?

 $arr = array();
 If (!empty($arr)) { }

 This is where i have found it to be the most usefull...

If I'm already certain that it's an array, I just use 'count' personally.

'empty' takes a mixed data type, and could return TRUE for, say, 'foo'
even though you are expecting an array there.

I think it's a better practice to use the right weapon and use
count() on an array to see if it's empty or not.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] isset

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 11:18 am, Jim Lucas wrote:
 these two lines are not the same infact, with the first, you will not
 get a E_NOTICE warning, but
 with the second you will.

I dunno what you are thinking of, but the manual says:

empty() is the opposite of (boolean) var, except that no warning is
generated when the variable is not set.

I am reasonably certain that empty, like isset is not, in fact, a
function, but is a language construct (like if and foreach) and it
does not attempt to use the variable per se, so does not generate an
E_NOTICE.

I am also reasonably certain that this has been true since empty
debuted in the language, but won't swear to that in court.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Shiny Floor (web 2.0) effect with GD Library

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 12:06 pm, Graham Anderson wrote:
 Has anyone created that web 2.0 shiny floor  effect with the GD
 Library?
 I have seen it dynamically created by passing variables into a Flash
 movie.  Has this been done with GD?

I think you're going to have to provide some sample images if you
expect a bunch of programmers to have ANY IDEA what you mean by shiny
floor effect...

And my momma created the shiny floor effect long before Web 2.0, so
I'm really lost on that connection... :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] Shiny Floor (web 2.0) effect with GD Library

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 12:14 pm, Jay Blanchard wrote:
 [snip]
 web 2.0
 [/snip]

 There is a new web? Do you have an example of the shiny floor? Does it
 look like the one in my kitchen or one of those old Java water
 effects?

Actually, I just saw a comment on some blog that Web 2.0 is already
passe, and Web 3.0 is the next big thing.

I, Richard Lynch, do hereby delcare Web X.0 (as in Roman numeral
system a la Mac OS) as the next big thing. :-)

Sheesh.

I can't take anybody seriously who talks about Web 2.0

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] isset

2007-04-16 Thread Jochem Maas
Richard Lynch wrote:
 On Mon, April 16, 2007 5:35 pm, Tim Earl wrote:
 What about in the following context?

 $arr = array();
 If (!empty($arr)) { }

 This is where i have found it to be the most usefull...
 
 If I'm already certain that it's an array, I just use 'count' personally.
 
 'empty' takes a mixed data type, and could return TRUE for, say, 'foo'
 even though you are expecting an array there.
 
 I think it's a better practice to use the right weapon and use
 count() on an array to see if it's empty or not.

php -r 'var_dump(count(foo));'

outputs:
int(1)

so my strategy is usually

if (!empty($r)  is_array($r)) {
// good to go.
}

if I know it's an array I'll definitely use empty() over count() 
count() needs to actually count the items where as empty() can return false
as soon as it finds a singel element ... maybe I'm mistaken - if so please
put me right.

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



Re: [PHP] Protecting individual files/dirs from access

2007-04-16 Thread Richard Lynch
On Sat, April 14, 2007 10:47 am, tedd wrote:
 At 4:56 PM -0500 4/13/07, Richard Lynch wrote:
Put the files outside the webtree, and have a PHP script that
 controls
access and is your gate-keeper.

 Richard:

 How secure is this:

I can't answer that question definitely just looking from the outside
in...

A deadbolt may look secure from the outside, but if it's balsa-wood
behind the locked door, that deadbolt ain't worth squat. :-)

 http://sperling.com/a/pw

 There are seven files there, namely:

 http://sperling.com/a/pw/.htaccess
 http://sperling.com/a/pw/a.php
 http://sperling.com/a/pw/b.php
 http://sperling.com/a/pw/auth.php
 http://sperling.com/a/pw/index.php
 http://sperling.com/a/pw/girl.gif-- not protected.
 http://sperling.com/a/pw/girl.jpg   -- protected, but well worth the
 effort.

 Are any of these files accessible, even when you know the path? And
 by accessible I mean can you obtain any information that the files
 contain?

index.php is also accessible, if I can guess the login, which I did on
my first try...

a.php is also then accessible.

I can then visit b.php and auth.php, which do not seem to generate
output.

girl.jpg remains in accessible, however, afaict.

 For example, if I were to tell people to store their user id and
 password in a configuration php file with a known path, would it be
 safe? I realize that if the server is breached then nothing is safe,
 but barring that -- how safe would that be?

Consider the following scenarios:


SCENARIO #1
Your webhost is about to go out of business, and you tar up your site
in a super big hurry, and slam it into a new server.

Whew!

You check it out, and it works, and you toddle off to bed exhausted.

Turns out, though, that the .htaccess files didn't get into your
tarball, because you forgot that you needed to add them explicitly.

So a bunch of stuff in your webtree on your shiny new server is wide
open.

Yes, this has really happened.

To me.

Fortunately, I had other stuff in .htaccess that made it obvious that
something was wrong, and the window of opportunity was short, but
there it is.  And it wasn't like the world was gonna end or anybody's
money was at risk or even anything personal info, really.  But
still...


SCENARIO #2
The server admin (possibly you, possibly not) upgrades Apache, and
somehow manages to not install PHP.

Or, perhaps, doesn't use the same extensions (.php3 anybody?) for PHP.

Or, perhaps, messes up that line and forgets to add the .html you've
grown accustomed to being passed through PHP.

Any one of these can suddenly expose your password to the whole Internet.

These are things that should not happen, but have happened, and will
happen again, to somebody somewhere.

If you put the stuff you want to keep private OUTSIDE the web-tree,
and provide a PHP gate-keeper to get to it, you reduce your risk.

It's a lot harder to screw up bad enough to configure Apache to start
serving up files directly from a private directory.

I won't say nobody has ever managed to do that.

In fact, I'm sure somebody somewhere has managed it with a
+FollowSymLinks and then putting a symlink in the web tree out to the
private dir, because they didn't know how to work PHP's
include_path...

But it takes a lot more work to mess that up than a simple common typo.


So it's not about whether I can get to the stuff NOW.

It's about whether things could EASILY go wrong enough that I could
get to the stuff tomorrow.


Let's also consider the case of my visiting b.php and auth.php

In this small tiny sample application, it's unlikely that either of
those do anything interesting enough when I visit them out of
sequence.

However, in a LARGE application, if the user visits a .php file
completely out of sequence from any QA process you have ever run,
because they are surfing to random .php files to try and break your
application, what happens?

A: PHP code is executed completely out of context, in a manner you
have never ever tested at all, much less subjected to any kind of
formal QA process.  In essence, the visitor is running code that
you've never even tried, at least not in that particular environment. 
As code grows and accretes more and more cruft, and a large complex
web application emerges, can you really guarantee that the user
running some arbitrary chunk of PHP code out of sequence like that is
never ever going to be a problem?  Use PHP's include_path and get the
include files OUT of your webtree.


PS I'm assuming that you intended it to be easy to guess the login for
the HTTP Basic Authentication... :-)

PPS Nice photo! :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] warning message to hide

2007-04-16 Thread Richard Lynch
Short-term, you can toss an @ in front of pg_eonnect.

Long-term:
http://php.net/set_error_handler
Also check out ini_set for error_log and friends.

After you've done it the Right Way, get rid of the @

On Sat, April 14, 2007 8:44 am, Alain Roger wrote:
 Hi,

 Today i discovered that when my host webserver has some issue with
 PostgreSQL database, my code displays the following error message :
 *Warning*: pg_connect()
 [function.pg-connecthttp://www.immense.sk/function.pg-connect]:
 Unable to connect to PostgreSQL server: could not connect to server:
 Connection refused Is the server running on host pgsql.exohosting.sk
 and
 accepting TCP/IP connections on port 5432? in */www/.php* on line
 yyy.

 I would like instead of that, to display my own error message... in
 fact, i
 would like to display something like : We are sorry but temporary we
 have
 some technical issues. Please try again later.
 how can i do that ?

 i tried to do :
 $conn = pg_connect($conn_string);

 if ($conn) // check if database is online
 {
 // close database connection
 pg_close($conn);
 }
 else
 {
 // impossible to connect to DB
 die('Maintenance in progress... Try later.');
 }

 but it still display the previous warning message.
 thanks for your help.


 --
 Alain
 
 Windows XP SP2
 PostgreSQL 8.1.4
 Apache 2.0.58
 PHP 5



-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] warning message to hide

2007-04-16 Thread Richard Lynch
On Sat, April 14, 2007 12:12 pm, Tijnema ! wrote:
 try putting an @ sign before this line. something like this:
 @$conn = pg_connect($conn_string);

 According to the manual:
 http://www.php.net/manual/en/language.operators.errorcontrol.php
 the @ should be placed before the function, so like this:
 $conn = @pg_connect($conn_string);

Actually, the manual explicitly documents the @ operator as being
valid in front of any EXPRESSION.

It goes on to say that if you can get the value of something, you can
use @ on it.

The assignment operator returns a value.

It is an expression.

@$conn = pg_connect($conn_string);

is therefore a documented feature.

Using @ as a long-term solution is stll morally wrong, of course. :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Problems installing php with pdflib

2007-04-16 Thread Richard Lynch
On Sat, April 14, 2007 3:55 am, Merlin wrote:
 I am moving to a new box and want to install php with pdflib again.
 After configure I get an error saying:
 pdflib.h not found! Check the path passed to --with-pdflib

 The path is just fine:
 '--with-pdflib=/usr/local/lib'

configure needs to find TWO things:
  #1 the lib file which is libpdf.so in /usr/local/lib
  #2 the header file which is libpdf.h in /usr/local/include

If you tell configure to look inside of /usr/local/lib, it can't
*find* the libpdf.h file, because it's not inside that directory, it's
inside a directory parallel to that.

If you tell configure to look in /usr/local, it knows to check in
/usr/local/lib for the .so file, and in /usr/local/include for the .h
file, and it finds everything it needs.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Json.php

2007-04-16 Thread Richard Lynch
On Sat, April 14, 2007 3:11 am, Otto Wyss wrote:
 I've seen a json.php file somewhere in a project for cases where the
 json module isn't installed (e.g. PHP4), yet I can't find that project
 again. Is there an official or unofficial download site for json.php?

 Why isn't this available in the PHP manual
 (http://ch2.php.net/manual/de/ref.json.php)?

I think JSON is new enough to have only ever lived in PECL.

http://pecl.php.net

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Json.php

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 9:33 am, Roman Neuhauser wrote:
 # [EMAIL PROTECTED] / 2007-04-16 14:03:55 +0200:
 Jochem Maas wrote:
 
 that's going to make it completely impossible to use then isn't it.
 no way you could possibly wrap the class/objects functionality in a
 wrapper
 function.
 
 At the moment it's sufficient, since I've now time to figure out how
 the
 Json package can be installed. Then I can switch to use the usual
 json_encode function. Thanks.

 What I don't understand is why you're going from a general interface

   $someObject-decode($string); # if it quacks like a JSON decoder...

 to a narrow one:

   json_decode($string); # you either have the function or you're
 screwed.

 Tight coupling - inflexible code.

This seems pretty ridiculous argument to me.

You either have JSON isntalled, or you don't.

If you have it, having it as an OOP thingie or as a function doesn't
make any real difference if you know how to write decent code in the
first place.

It's not like it's any easier to swap out the current JSON package for
a mythical new one. Global search and replace or writing a wrapper
function or whatever is going to be equally easy.

Any real pain will be in whether the substitute JSON actually outputs
the same thing as the one you used before, not in the syntatic
sugar/bloat of having:

$json = new json();
$foo_json = $json-encode($foo);

versus
$foo_json = json_encode($foo);

Getting all bent out of shape about OOP versus procedural just makes
no sense to me, if one has competent programmers...

If one doesn't have competent programmers, then does it really matter
which one you use, in the long run?

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] isset

2007-04-16 Thread Al

I've been using empty() for about 5 years, obeying the rules for empty() in the 
php manual
Appendix P. PHP type comparison tables and have never seen it generate any 
type of error message.

If you guys know of at least one exception, please clue us in on it.


Jim Lucas wrote:

Stut wrote:

tedd wrote:

At 4:08 PM +0100 4/16/07, Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because 
$_REQUEST['var'] = 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}


The isset is a pointless waste of cycles.

-Stut


I've been accuse of that too, but what's your solution?


In the above example,

  if (isset($_GET['something'])  !empty($_GET['something'])) {

is the same as...

  if (!empty($_GET['something'])) {

So, in that particular line of code the isset is a pointless waste of 
cycles.


-Stut

these two lines are not the same infact, with the first, you will not 
get a E_NOTICE warning, but with the second you will.




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



Re: [PHP] Json.php

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 10:20 am, Tijnema ! wrote:
 And btw, I think it's better not to create a new link to the class
 each time the function is called, but just use ::
 if (!function_exists('json_encode')) {
function json_encode($data) {
return Services_JSON::encode($data);
}
 }

 and probably also one for decoding.

 if (!function_exists('json_decode')) {
function json_decode($data) {
return Services_JSON::decode($data);
}
 }

Actually, if I understand the flame wars of Internals correctly,
whichever one of those is correct, the other one ain't gonna work in
PHP 6...

Or so I gather from the OOP purists fighting the OOP zealots on
PHP-Internals.

I may be 100% wrong, of course, regarding not only the outcome of this
flame-fest, but even if it applies to this JSON thingie.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Images again

2007-04-16 Thread Richard Lynch
On Fri, April 13, 2007 8:02 pm, Børge Holen wrote:
 Before mr lynch starts beating up those already dead and probably long
 since
 burried horses...

 Images in a database!

Feh.

Read the archives.

 See I was just wondering, and that at times leads to late nights
 I used to read the images from two different files; one watermarked
 the image
 and one let it throught without any hazzle.
 Of course this kind of script was easy enought to get around the
 watermarking,
 witch I fixed with the http referer witch as follows IE don't send. I
 don't
 particulary like ppl who use IE (ups did I upset someone?) ;D.

Using referer for anything other than logging it for analysis later
is probably your first mistake...

 However I  started compressing my scripts and putting them inside one
 file.
 And the status is so far:

 * Query for the image object.
 * Query for copyright check in case of watermarking. If no
 watermarking skip
 to echo
 * Read the object.
 * put object in a file outside webroot like /tmp.
 * read both the watermark and object
 * merge
 * echo

 Is it possible to skip one query and still be able to read ownership
 from a
 table and at the same time stream the object, witch lead me to the
 next
 question, I can't seem to be able to make imageCreateFromJPEG handle
 the
 direct stream, nor that I fetch it in an array, is any of this
 possible?

imageCreateFromString should work on your un-watermarked image from
the DB.

When you need the watermark, you can load the watermark from whatever
source you like (file with imagecreatefromjpeg or DB with
imagecreatefromstring)

You can then merge the two images (original and watermark overlay) in
RAM with imagecopymerge calls, or perhaps playing with an alpha blend
with imagealphablending first.

Creating that tmp file and writing/reading to it is probably a pretty
serious performance bottleneck that should be addressed for any kind
of heavy traffic or large images.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] isset

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 6:10 pm, Jochem Maas wrote:
 if I know it's an array I'll definitely use empty() over count() 
 count() needs to actually count the items where as empty() can return
 false
 as soon as it finds a singel element ... maybe I'm mistaken - if so
 please
 put me right.

You're wrong.

The count is maintained internally as items are added/removed, and it
is an O(1) operation for PHP to count the array, as it already knows
the answer and just returns it.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



  1   2   >