Re: [PHP] php5 oop question

2007-04-11 Thread Jim Lucas

Paul Scott wrote:

On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:


Has anybody else seen this style of syntax?


http://5ive.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=init_8059_1163957717&userid=5729061010

I don't think that its really useful for anything, except maybe creating
overly complex SQL queries.

--Paul





All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 



well, I guess the better question is, is why when I talk others about oop, they say that this style 
of syntax is OOP, and anything else is not.


be it dot notation or the pointers (->) in php.

I heard it called messaging at one point in the past.

the passing up of information in the tree.

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



Re: [PHP] php5 oop question

2007-04-11 Thread Jim Lucas

Paul Scott wrote:

On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:


Has anybody else seen this style of syntax?


http://5ive.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=init_8059_1163957717&userid=5729061010

I don't think that its really useful for anything, except maybe creating
overly complex SQL queries.

--Paul





All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 




What about using it for math?

Here is the other example that I worked up.

value = $num;
return $this;
}
function out() {
echo $this->value;
}
function get() {
return $this->value;
}
function add($n) {
$this->value += $n;
return $this;
}
function subtract($n) {
$this->value -= $n;
return $this;
}
function multiply($n) {
$this->value *= $n;
return $this;
}
function divide($n) {
$this->value /= $n;
return $this;
}
}

$mObj = new Math();
$mObj->in(10)->add(90)->divide(5.3)->multiply(10)->out();

?>

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



Re: [PHP] location of the PHP executable

2007-04-11 Thread Chris

Børge Holen wrote:

On Wednesday 11 April 2007 23:50, Jarrel Cobb wrote:

Don't you have to run locate -u first to generate the database before using
locate?  You can't just assume a database exists already can you?


not an updated one at least, updatedb can also be used to update.


Probably can't because the database has to be created as root.. unless 
you get into using the switches which seems like a lot more hassle than 
it's worth but *shrug*.


If this is for a cron command, try

env php

which should pick whichever is in the $PATH for the cron environment.

Not 100% guaranteed but 90% should work.

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] php5 oop question

2007-04-11 Thread Paul Scott

On Wed, 2007-04-11 at 23:22 -0700, Jim Lucas wrote:

> Has anybody else seen this style of syntax?
> 
http://5ive.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=init_8059_1163957717&userid=5729061010

I don't think that its really useful for anything, except maybe creating
overly complex SQL queries.

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

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

Re: [PHP] location of the PHP executable

2007-04-11 Thread Børge Holen
On Wednesday 11 April 2007 23:50, Jarrel Cobb wrote:
> Don't you have to run locate -u first to generate the database before using
> locate?  You can't just assume a database exists already can you?

not an updated one at least, updatedb can also be used to update.
and if you're in a little bit of hurry you can also use find -name "some part 
of filename here"

>
> On 4/11/07, Jim Lucas <[EMAIL PROTECTED]> wrote:
> > Mattias Thorslund wrote:
> > > Hi,
> > >
> > > I have looked in the documentation but can't find it:
> > >
> > > My PHP script (which is run from the command prompt - CLI) needs to
> > > know the file system location of the PHP executable. This is because it
> > > needs to run a second PHP script. I know about the "which" command but
> > > it's not available in all OSes, and that might not be the currently
> > > running executable anyway.
> > >
> > > I could prompt the user for this, but that seems kind of silly. Surely,
> > > there must be some way of looking it up automatically?
> > >
> > > Thanks,
> > >
> > > Mattias
> >
> > What OS are you working with
> >
> > Assuming you are on a *nix box this should work
> >
> > #locate "/php" | grep "/php$"
> >
> > this should give you locations that have /php as the end of the line
> >
> >
> > on windows you could do this
> >
> > cd \
> > dir /s php*.exe
> >
> >
> >
> > --
> > 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

-- 
---
Børge
http://www.arivene.net
---

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



[PHP] php5 oop question

2007-04-11 Thread Jim Lucas

Ok, I have seen many different examples of OOP, but nothing quite like this.

Someone was showing me syntax for Ruby the other day, and it got me thinking, wouldn't it be neat to 
imitate ruby, or be it a little more generic, dot notation for OOP ways of calling methods like 
Java, javascript, ruby and others.  So I came up with this.


Seems to work in PHP5, but chokes in PHP4.

I would like input on this setup for calling methods.

value = $str;
$this->setProperties();
return $this;
}
function out() {
echo $this->value;
}
function get() {
return $this->value;
}
function append($a) {
$this->value = $this->value.$a;
$this->setProperties();
return $this;
}
function prepend($a) {
$this->value = $a.$this->value;
$this->setProperties();
return $this;
}
function regex_replace($from, $to) {
$this->value = preg_replace("!{$from}!", $to, $this->value);
$this->setProperties();
return $this;
}
function setProperties() {
$this->str_length = strlen($this->value);
return $this;
}
function length() {
return $this->str_length;
}
}

$str = new myString;

echo $str->in("Starting String!")->prepend("Second String!")->regex_replace(' ', 
'_')->get();
echo $str->length();
$str->in("A new string")->out();

?>

Has anybody else seen this style of syntax?

Have they used this style of syntax?

If so, what is your opinion of this style?

TIA
Jim

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



Re: [PHP] 'lang' file editor ...

2007-04-11 Thread Jim Lucas

Richard Lynch wrote:

Seems to me you'd be better off just running the PHP code and dumping
the arrays out with var_dump or print_r "like" function to generate
your new language files...

Otherwise, you're writing a fairly big chunk of the PHP parser, which
is already in PHP, so you re-invent the wheel...

On Wed, April 11, 2007 9:07 pm, Jochem Maas wrote:

anyone know of a decent script (or something I can rip out of an
existing OS tool)
that is capable of comparing, editing and saving 'old skool' lang
files - you know
the ones which define tons of array elements e.g.:

$Lang['foo'] = 'bar';

I'm looking for something that can handle quotes properly and 'weird'
array keys
(that include constants, for instance) as well as sprintf markers in
the 'translation'
text (e.g. "my %s hurts") and if at all possible the abiltiy to
recognise and not f'up
stuff like:

$Lang['foo'] = 'my '.$Lang['bar'].' really hurts';

and I'd prefer it to be able to keep file formatting, item ordering
and comments
as they were when saving back into the file.

I can't find anything really useful - the firefox 'php lang file'
editor plugin, is,
for instance, not up to the job.

tar,
Jochem

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






From what he said, I read that he want to rip the contents out of the file, not 
actually parse it.

for example, if he parsed this out:
$Lang['foo'] = 'my '.$Lang['bar'].' really hurts';

You would get the completed string, not a line that has the variable call in it.

Maybe I took it wrong, but that is what I thought he wanted.

a reader, not a parser.

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



Re: [PHP] Constructors with multiple methods

2007-04-11 Thread Chris

Damien wrote:

Hi all,

Say you may want to create an instance in multiple ways, such as creating
from scratch or loading from a database. Is something like this normal for
creating an instance?


I do this:

class Foo {
  function Foo($id=0)
  {
if (is_int($id) && (int)$id > 0) {
  return $this->Load($id);
}
// set default variables.
  }
}

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] Constructors with multiple methods

2007-04-11 Thread Jarrel Cobb

"creating from scratch or loading from a database" sounds like you want a
registry or service locator.  Otherwise, you should encapsulate object
instantiation in factory methods/classes

On 4/11/07, Damien <[EMAIL PROTECTED]> wrote:


Hi all,

Say you may want to create an instance in multiple ways, such as creating
from scratch or loading from a database. Is something like this normal for
creating an instance?

class Foo
{
  function Foo($method)
  {
switch ($method) {
  default:
$method = 'create';
  case 'create':
  case 'load':
$args = func_get_args();
array_shift($args);
if (!call_user_func_array(array(&$this, $method), $args)) {
  $this = false;
}
}
  }

  function create()
... // Returns false on failure; true otherwise.

  function load($id)
... // Returns false on failure; true otherwise.

  function save()
... // Saves to database.

}

What are other people doing to instantiate their objects?

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




[PHP] Constructors with multiple methods

2007-04-11 Thread Damien
Hi all,

Say you may want to create an instance in multiple ways, such as creating
from scratch or loading from a database. Is something like this normal for
creating an instance?

class Foo
{
  function Foo($method)
  {
switch ($method) {
  default:
$method = 'create';
  case 'create':
  case 'load':
$args = func_get_args();
array_shift($args);
if (!call_user_func_array(array(&$this, $method), $args)) {
  $this = false;
}
}
  }

  function create()
... // Returns false on failure; true otherwise.

  function load($id)
... // Returns false on failure; true otherwise.

  function save()
... // Saves to database.

}

What are other people doing to instantiate their objects?

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



Re: [PHP] PHP textbook suggestions?

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 2:09 pm, Chris Lott wrote:
> On 4/10/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> > print 'The cost is ' . $cost;
>> > NOT
>> > print "The cost is $cost";
>> > AND CERTAINLY NOT
>> > print ("The cost is $cost");
>>
>> echo "The cost is ", $cost;
>>
>> If you're going to be this picky, you'd better write your own
>> textbook...
>>
>> :-)
>>
>> Perhaps instead of a textbook, just use http://php.net/manual
>
> The manual is not nearly enough reference for a beginning students.
> You illustrate the problem with quotes in your example above-- why
> double quotes with no variable being interpolated?

Surely the lecture is going to cover *something* :-)

That said, I suppose a good textbook *and* assigned readings in
parallel of specific sectionns of the online PHP Manual would be your
best bet.

> The . is the documented string operator for concatenation... that's
> one of the reasons I dislike the unneeded parentheses with the print
> function-- then I have to explain-- before I want to-- arguments to
> functions, which is necessary to explain the comma.

Yes.

One needs to cover each of the following in the first couple classes:
' versus "
function versus language construct
basic operators and syntax (. versus , included here)

One *might* delay all that until the second class, just to get a
sample web page "up" as a first exercise, more or less blindly typing
whatever they are told to type.

But if that materiel isn't covered by lesson 2 or 3 at the latest,
they'll never understand the billion PHP scripts they should be using
as a learning resource...

-- 
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] Re: PHP textbook suggestions?

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 5:12 pm, LuKreme wrote:
> On 11-Apr-2007, at 13:06, Chris Lott wrote:
>> I completely recognize that the practical effects of the differences
>> are small, but the learning effects of the inconsistencies is much
>> larger, particularly with a group of students that are not techies,
>> not geeks, not computer science or IT students...
>
> Well, non-techie non-geeks are going to get very little out of
> learning to code php and are likely going to end up writing crap code
> with loverly security holes that bring ebservers to their knees and
> propagate millions of spam emails.  Walk before you run, and all
> that.  PHP is not a good choice as a 'learning' language precisely
> because it is so flexible.
>
> Much better to teach a much more rigid and concise language like obj-
> c or c++ if you want to teach programming to tyros.  Heck, even perl.

I would disagree with this statement...

First of all, if you're not teaching good coding practices, and
pointing out security issues as you go, then you might as well not
teach at all.

Secondly, PHP is ideally-suited as a first language because something
reasonably useful, with reasonalbe security for the problem-space, can
be coded and understood by just about anybody.

Nothing loses more potential good programmers faster than the tedium
of compling C or the vagaries of Perl "syntax"

jmho.

Someday I'll retire and teach 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] PHP textbook suggestions?

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 22:47 -0500, Richard Lynch wrote:
> On Tue, April 10, 2007 9:40 pm, Robert Cummings wrote:
> >> echo "The cost is ", $cost;
> >
> > -1 Improper use of double quotes when nothing interpolated.
> 
> Yeah, I used to believe in that Urban Legend, and even promulgated it,
> once upon a time.
> 
> Then Rasmus set me straight that it's not really any faster/slower,
> and the only difference is whatever is more convenient, if you don't
> need anything interpolated.
> 
> Remember that '' examine each character in turn to detect \' and \\
> 
> It is the same order of magnitude search, with a slightly smaller
> constant number of patterns to find.
> 
> I actually do often use '' if there is nothing to interpolate, for
> longer strings especially, so that the reader (me) knows that there is
> nothing being interpolated.
> 
> But on a short enough string, it just doesn't matter which is used.

I meant the -1 in jest ;) While I do promulgate proper use of quotes, I
do so mostly because it provides better clarity of intent... as you have
stated above.

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] Re: PHP textbook suggestions?

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 2:06 pm, Chris Lott wrote:
> You're missing the point-- it's not that there is a practical
> difference in the examples, it's that there IS a difference, the
> students see it, and it is an extra point of confusion that isn't
> needed if one is being consistent.
>
> I completely recognize that the practical effects of the differences
> are small, but the learning effects of the inconsistencies is much
> larger, particularly with a group of students that are not techies,
> not geeks, not computer science or IT students...

So they need to learn what matters when and why.

Is this so different from any other subject matter?

If they don't get this, they certainly won't prepared for the plethora
of sample code they should be reviewing online!

-- 
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] PHP textbook suggestions?

2007-04-11 Thread Richard Lynch
On Tue, April 10, 2007 9:40 pm, Robert Cummings wrote:
>> echo "The cost is ", $cost;
>
> -1 Improper use of double quotes when nothing interpolated.

Yeah, I used to believe in that Urban Legend, and even promulgated it,
once upon a time.

Then Rasmus set me straight that it's not really any faster/slower,
and the only difference is whatever is more convenient, if you don't
need anything interpolated.

Remember that '' examine each character in turn to detect \' and \\

It is the same order of magnitude search, with a slightly smaller
constant number of patterns to find.

I actually do often use '' if there is nothing to interpolate, for
longer strings especially, so that the reader (me) knows that there is
nothing being interpolated.

But on a short enough string, it just doesn't matter which is used.

-- 
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] Re: SQL Source Control

2007-04-11 Thread Manuel Lemos
Hello,

on 04/11/2007 12:13 PM Richard Davey said the following:
> Hi all,
> 
> I know a lot of you use various means for PHP source control (CVS, SVN,
> etc), which is all well and fine, but how do you manage source control
> on your databases?
> 
> Say you've got an upgrade to a site, all of the new PHP files are
> controlled by SVN, so you can rollback at any time, but say the upgrade
> includes several key modifications to a MySQL table and perhaps the
> changing of some core data.
> 
> How (if at all?!) do you handle the versioning of the database and data
> itself, so you can keep both PHP and SQL structure in sync?

In 1998 I started a project to address very similar needs to yours.

I wanted to develop database independent applications that would let me
not only access different databases with the same API, but also would
let me install and maintain database schemas, also in a database
independent fashion.

I created a XML format to declare the database tables, fields, indexes,
sequences, etc.. Then the package reads the schema definitions and
installs the schema in whatever database I use.

If I need to change my database schema, I just change the database
definition and tell my package to compare the present and the installed
schema versions in order to perform the necesssary changes to upgrade
the schema, all without disturbing data that was inserted since the
schema was installed for the first time or upgraded for the last time.

Since the schema definition is now just a XML file, I can keep track of
successive revisions in CVS. If I want to downgrade the schema, I just
checkout the respective versions and tell my package to update the
installed schema just like when it is upgraded.

This package that I developed is named Metabase. It became very popular
and many of its ideas were copied. There is also a PEAR style flavour
for PEAR fans, named MDB. PEAR MDB2 is MDB follow up version. Until
today there are several other PHP database abstraction layers that use
the same XML schema definition format.

Metabase is available here:

http://www.phpclasses.org/metabase

Here you may also find some documentation:

http://www.meta-language.net/documentation.html#metabase

-- 

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] Re: 0x9f54

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 6:47 am, Man-wai Chang wrote:
> how do you do string comparison in utf-8? say the user entered a
> chinese
> string the browser and you need to search for the string in the MySQL
> table using PHP.

*IF*
the page that got the initial data was UTF-8 in its HTTP Headers and
in the META tags, and
mysql server is starting up with UTF-8, and
php mysql client connnection is using UTF-8, and
the page getting the search key is also UTf-8, then

it should "just work" I think...

That said...

If you're still having problems with this one broken character in a
specific charset, you're on the wrong list...

It's possible that you need WHERE binary field = '$input'
MySQL has a "binary" keyword for binary comparison.
But it may have some OTHER keyword for UTf-8 comparison...
I dunno.  Ask a MySQL list.

There's no actual PHP in your question...

I'll stop typing now.

And stop taking cold medicine too.

-- 
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] MD5 & bot Question

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 8:09 am, tedd wrote:
> -- that's all. See the subject line.

I'm sorry that I thought the thread had spilled over beyond the scope
of the Subject.

Since we rarely do that here in PHP General, I should have known better.

:-)

I don't think your work is "lame"

I think it's "lame" to say it can't be broken without massive computer
resources.

And, actually, even with the MD5 technique...

An MD5 is 32 bytes.

2 million images, sauteed down to 32 bytes each, is 64 Meg, plus some
DB overhead.

Plus an index on the MD5 field, for speed, but that cannot exceed the
original 64Meg, almost-for-sure.

So, a machine with 128 Meg DB is "massive resources"?

I think not.

True, you would use a lot of bandwidth and time to compute the MD5
hashes.

But what do you think zombie bot Windows computers are for?

This is an IDEAL problem-space for massive parallel computation,
distributed across as many machines as a Bad Guy can control.

So the "massive computing resources" turns out to be "readily
available cracked Windows boxes", if you even need it, which I doubt.

-- 
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] Posting a variable

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 22:10 -0500, Richard Lynch wrote:
> On Wed, April 11, 2007 9:58 pm, Robert Cummings wrote:
>
> I see it as two different things being matched up in a clear
> unequivocal manner, to make self-documenting code.

I'm all for self-documenting code, that's why I don't in practice export
my vars, and I do in practice name my database fields the same way I
would name the variables. Also in practice, I've rarely seen use of my
row values displaced far from the query. If they are, then it's usually
in another function, and then they have their own function centric
names :) But alas, to each their own... now getting back to the original
poster, I'm wondering if he directly accesses the integer IDs within
$row or if he does as you do and pulls them out into vars :/

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] MD5 & bot Question

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 7:30 am, tedd wrote:
> At 7:50 PM -0500 4/10/07, Richard Lynch wrote:
>>On Sun, April 8, 2007 11:12 am, tedd wrote:
>>>  chose from. Unless, there is something here that I don't
>>> understand
>>>  (which very well could be), I can't see how anyone, without
>>> massive
>>>  computer resources, could break that.
>>>
>>>  Am I wrong?
>>
>>You are wrong.
>>
>>The Tijnema! solution of memorizing every single image would fail.
>
> Then I'm right, because that's what I was saying.

You're right that it can't be broken WITH THAT TECHNIQUE, which is not
what you actually typed...

Your wrong that it can be broken, without massive computer resources,
which is what you actually typed.

:-)

By all means, publish a bunch of differnt nifty CAPTCHAs and re-name
to Assira or whatever so you can claim to be doing something "new" and
"different", but do not for an instant delude yourself that a
dedicated attack won't succeed no matter what you do.

-- 
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] Array remove function?

2007-04-11 Thread Richard Lynch
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... :-)

-- 
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] 'lang' file editor ...

2007-04-11 Thread Richard Lynch
Seems to me you'd be better off just running the PHP code and dumping
the arrays out with var_dump or print_r "like" function to generate
your new language files...

Otherwise, you're writing a fairly big chunk of the PHP parser, which
is already in PHP, so you re-invent the wheel...

On Wed, April 11, 2007 9:07 pm, Jochem Maas wrote:
> anyone know of a decent script (or something I can rip out of an
> existing OS tool)
> that is capable of comparing, editing and saving 'old skool' lang
> files - you know
> the ones which define tons of array elements e.g.:
>
> $Lang['foo'] = 'bar';
>
> I'm looking for something that can handle quotes properly and 'weird'
> array keys
> (that include constants, for instance) as well as sprintf markers in
> the 'translation'
> text (e.g. "my %s hurts") and if at all possible the abiltiy to
> recognise and not f'up
> stuff like:
>
> $Lang['foo'] = 'my '.$Lang['bar'].' really hurts';
>
> and I'd prefer it to be able to keep file formatting, item ordering
> and comments
> as they were when saving back into the file.
>
> I can't find anything really useful - the firefox 'php lang file'
> editor plugin, is,
> for instance, not up to the job.
>
> tar,
> Jochem
>
> --
> 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] Posting a variable

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 9:58 pm, Robert Cummings wrote:
> The table fields should have been named well enough in the first
> place.

Some are not fields at all, but calculations, and, yes, I'll have an "
AS foo" in my SQL (only not really foo, of course) simply for
documentation purposes, even though I'm not using _assoc, because I
want to know what the heck that calculation is a month later.

> If you don't want the baggage or you're using the variable so much
> that
> it warrants an elimination of array access overhead then why not use
> the
> more concise extract()?
>
> 
> extract( mysql_fetch_assoc() )
>
> ?>

[shudder]

I amy not *want* the exact same name as the table fields in every
case, if I have the same name in the SQL in two tables.

And, yes, I could use even more " AS foo " (only not foo) a whole lot
more...

But, really, something like:

select id, name from option_list_foo order by rank
select id, name from option_list_bar order by rank
select id, name from option_list_baz order by rank
.
.
.

for a bunch of User Profile popups, I don't really want to have to do
a bunch of AS and then an extract, and rely on remembering the AS from
section to section.

For some reason, I do much better at remembering PHP variable names
than SQL column AS names.

> Yes, yes, I know some idiot out there will clobber their vars *lol* --
> or not clobber their vars as necessary *grin*. Either way, list()'ing
> out all the fields you've already declared in the query (or that are
> implied) or directly pulling out to a var using assignment is just
> code
> in two places that could be in one.

You see it as the same thing in two places.

I see it as two different things being matched up in a clear
unequivocal manner, to make self-documenting code.

[shrug]

-- 
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] Posting a variable

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 21:30 -0500, Richard Lynch wrote:
> On Wed, April 11, 2007 8:17 pm, Robert Cummings wrote:
> > I'd rather lose track of $row['foozie'] than $row[1]. Either way, if
> > your code is structured well, the row data should be in close
> > proximity
> > to it's use. At the very least, if your field names are informative
> > instead of 'foozie', maybe 'email' then I think you'll have less
> > trouble
> > remembering. This isn't really a religious issue... it's a clarity
> > issue. I mean, why bother naming variables if you think you might get
> > confused later. Just call your vars $foo1 to $fooX-- at least that's
> > the
> > path you've laid out as an argument.
> 
> But I don't USE row[1]!
> 
> And certainly not $foozie!  I would have hoped that was obvious, but I
> guess not. :-(

*hehe* I saw where the rest of your post went, but the initial part
walked down this path ;)

> I use $email and I have it "close" enough to the source query, and
> with the name matching up (for simple columns) or very clear and
> descriptive names for calculated SQL values.
> 
> I might do an aggregate count(*) with a group by and it's going to be
> called $count, if it's simple enough a script to remember what is
> being counted, since there is only one thing being counted.
> 
> If I have both venues and cities being counted, it's $venue_count and
> $city_count.
> 
> I don't really like carrying around the "baggage" of
> $row['venue_count'] everywhere, especially if I'll use the variable a
> lot.
> 
> If I'm going to assign it to a well-named variable in 3 lines anyway,
> wny do I need it to be in an assoc array?  I don't.

The table fields should have been named well enough in the first place.
If you don't want the baggage or you're using the variable so much that
it warrants an elimination of array access overhead then why not use the
more concise extract()?



Yes, yes, I know some idiot out there will clobber their vars *lol* --
or not clobber their vars as necessary *grin*. Either way, list()'ing
out all the fields you've already declared in the query (or that are
implied) or directly pulling out to a var using assignment is just code
in two places that could be in one.

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] Re: downloading an image

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 9:37 am, Ross wrote:
> yes it is image/jpeg

Some (ancient) versions of IE don't give a doodly-squat what your
Content-type header is.  They'll "guess" based on the URL.

Your URL is like this:
download.php?id=47

IE thinks that's a .php file, and has no idea how to handle a .php file.

Some (ancient) versions of IE won't accept a GET arg on images.  Or
maybe it was .pdf  Or maybe it was .fdf  Or maybe it was... I forget. 
All I know is, I gave up on the browser doing the right thing with
content-type header, and always make my URL indistinguishable from a
perfectly valid "static" URL to an image, even if the image is not, in
fact, static.

That's pretty much part of what I ranted about here, oh so long ago:
http://richardlynch.blogspot.com/


In other potential problems, just off the top of my head...

HOw many bytes can content field hold in DB?
How many bytes can query buffer accept?
What is actually *IN* content field?
Did you manage to insert it correctly?
How do you know?
.
.
.


There are a dozen ways for this to "go wrong" once you start cramming
images into your DB.

If you can anticipate all those, and plan/code/design around them, fine.

But that doesn't make it a Good Idea to cram images in DBs unless you
know what you are doing, and have a very good reason to do so.

The preceding statment will almost for sure cause yet another flame
war just like in the archives, but there it is.

> "Roberto Mansfield" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Verify that your $type is a correct mime type.
>>
>>
>> Ross wrote:
>>> tthe image does not display although it exists in the table
>>> 'images'
>>>
>>>
>>> This calls the download script
>>>
>>>
>>> >>  $property_id = $_SESSION['property_id'] ;
>>>  $query = "SELECT * FROM images WHERE property_id='$property_id'";
>>> $result = mysql_query($query);
>>> while($row = mysql_fetch_array($result, MYSQL_ASSOC))
>>> {
>>>
>>> echo $id= $row['id'];
>>> echo $title= $row['title'];
>>> $link = "download.php?id=$id";
>>> }
>>> ?>
>>> 
>>>
>>>
>>>
>>> this is the download script
>>>
>>> id = $_GET['id'];
>>> $query = "SELECT name, type, size, content FROM images WHERE id
>>> ='$id'";
>>>
>>>  $result = mysql_query($query) or die(mysql_error());
>>> list($name, $type, $size, $content) = mysql_fetch_array($result);
>>>
>>> header("Content-length: $size");
>>> header("Content-type: $type");
>>>
>>> echo $content;
>>>
>>> exit;
>
> --
> 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] downloading an image

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 8:10 am, Ross wrote:
> tthe image does not display although it exists in the table 'images'
>
>
> This calls the download script
>
>
>   $property_id = $_SESSION['property_id'] ;
>  $query = "SELECT * FROM images WHERE property_id='$property_id'";
> $result = mysql_query($query);
> while($row = mysql_fetch_array($result, MYSQL_ASSOC))
> {
>
> echo $id= $row['id'];
> echo $title= $row['title'];
> $link = "download.php?id=$id";
> }
> ?>
> 

Instead of just looking at a broken image in an image tag, surf
DIRECTLY to the $link URL of the image, and see what comes out.

Invariably, your PHP / SQL bug will be printed direct to your browser,
or wherever your errors go, if you've actually set things up
correctly.

> this is the download script
>
> id = $_GET['id'];
> $query = "SELECT name, type, size, content FROM images WHERE id
> ='$id'";

Do we need to scream SQL injection again?
http://phpsec.org/

>  $result = mysql_query($query) or die(mysql_error());
> list($name, $type, $size, $content) = mysql_fetch_array($result);
>
> header("Content-length: $size");
> header("Content-type: $type");
>
> echo $content;
>
> exit;

There are *so* many things that can go wrong with storing the iamge in
the database...  We've beat that horse to death here, both ways.

All I can say is that this script is *SO* simple, I suspect that
*content* is not what you think it is, for whichever of the doezen
reasons that crop up when you start cramming large-size binery data
into the DB.

What DB data type is the content field?
How much can it hold?
What did you actually cram in there?
Did you remember to mysql_real_escape_string() 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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 7:59 pm, Jarrel Cobb wrote:
> There is a code view in Dreamweaver.  The split view is useful for
> making
> handcoded changes to HTML in the top code view and seeing the
> immediate
> result in the bottom design view.   You dont have to use the WYSIWYG
> features.

If I'm only going to use code view, why in the world would I use
Dreamweaver?!

I can juse use vi and have a much less bulky editor.

Oh wait, I *do* just use vi!

:-)

-- 
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] Posting a variable

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 8:17 pm, Robert Cummings wrote:
> I'd rather lose track of $row['foozie'] than $row[1]. Either way, if
> your code is structured well, the row data should be in close
> proximity
> to it's use. At the very least, if your field names are informative
> instead of 'foozie', maybe 'email' then I think you'll have less
> trouble
> remembering. This isn't really a religious issue... it's a clarity
> issue. I mean, why bother naming variables if you think you might get
> confused later. Just call your vars $foo1 to $fooX-- at least that's
> the
> path you've laid out as an argument.

But I don't USE row[1]!

And certainly not $foozie!  I would have hoped that was obvious, but I
guess not. :-(

I use $email and I have it "close" enough to the source query, and
with the name matching up (for simple columns) or very clear and
descriptive names for calculated SQL values.

I might do an aggregate count(*) with a group by and it's going to be
called $count, if it's simple enough a script to remember what is
being counted, since there is only one thing being counted.

If I have both venues and cities being counted, it's $venue_count and
$city_count.

I don't really like carrying around the "baggage" of
$row['venue_count'] everywhere, especially if I'll use the variable a
lot.

If I'm going to assign it to a well-named variable in 3 lines anyway,
wny do I need it to be in an assoc array?  I don't.

-- 
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] Outlook task via email

2007-04-11 Thread Chris

Chris Boget wrote:
I've done some searching on Google but haven't been able to come up with 
anything helpful.  Has anyone on the list done any work on sending an 
Outlook Task as part of an email?  Or does anyone know of a good 
resource that shows how this can be done?  I'm going to be using PHP's 
mail() to actually send and I'm familiar with attaching files to such 
emails but I'm just not sure how a task can be attached.


If you are running php on the same computer as outlook (otherwise php 
can't get to outlook and so can't get to the tasks), you could try 
something using the com object(s).


http://php.net/com

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] Array remove function?

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 8:44 am, Tijnema ! wrote:
> On 4/10/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> http://php.net/array_flip followed up an unset, followed by another
>> array_flip, I guess...
>
> What if you have an array like this:
> Array
> (
> [0] => Array
> (
> [0] => 1
> [1] => 2
> [2] => 2
> [3] => 2
> [4] => 2
> [5] => 4
> )
> [1] => 4
> [2] => 2
> [3] => 4
> )
>
> And i want to remove the 4, but i don't know 1 and 3. using array_flip
> wouldn't work because of my multi-dimensional array. But what if i'm
> using array_search? will it return 1 only? will it return 5?
>>
>> Why in the world you'd architect the array with a value when you
>> need
>> to unset by value in the first place is beyond me, though...
>
> Sometimes you end up with such arrays, where you need to have
> non-unique values first, so you store them in the value, and then you
> need to remove some of the non-unique values. But it's a
> multi-dimensional array...

All I can say is that if I have to be able to delete by value, then I
etiher build an inverse mapping array, or, if they arrays are going to
get bigger then X, I just skip the arrays, and architect it in the
database.

You can always write an inverse array -- if you have multiple keys for
one value, you just have to add another layer of array-ness in your
reverse map.

Searcing through an array for a value to be deleted is just something
I never personally do.

'Course, we didn't *have* array_search back when I formed this
opinion, and I'm a fossil/Luddite...

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



[PHP] 'lang' file editor ...

2007-04-11 Thread Jochem Maas
anyone know of a decent script (or something I can rip out of an existing OS 
tool)
that is capable of comparing, editing and saving 'old skool' lang files - you 
know
the ones which define tons of array elements e.g.:

$Lang['foo'] = 'bar';

I'm looking for something that can handle quotes properly and 'weird' array keys
(that include constants, for instance) as well as sprintf markers in the 
'translation'
text (e.g. "my %s hurts") and if at all possible the abiltiy to recognise and 
not f'up
stuff like:

$Lang['foo'] = 'my '.$Lang['bar'].' really hurts';

and I'd prefer it to be able to keep file formatting, item ordering and comments
as they were when saving back into the file.

I can't find anything really useful - the firefox 'php lang file' editor 
plugin, is,
for instance, not up to the job.

tar,
Jochem

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



Re: [PHP] Array remove function?

2007-04-11 Thread Jochem Maas
Paul Novitski wrote:
> At 4/10/2007 03:09 PM, M.Sokolewicz wrote:
>> Such a function is inherently a Bad Idea (tm). array-values are not
>> unique. Array keys are. So unless you want to emulate the way
>> array_flip works (bad idea (tm)), I'd say: leave it be.
> 
> 
> Whoever owns that trademark has totally got to be the wealthiest person
> in this battered old world~

my guess: Bill Gates, stacks of money and nothing but bad ideas ;-)

[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 :-/]

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



Re: [PHP] SQL Source Control

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 10:13 am, Richard Davey wrote:
> I know a lot of you use various means for PHP source control (CVS,
> SVN,
> etc), which is all well and fine, but how do you manage source control
> on your databases?
>
> Say you've got an upgrade to a site, all of the new PHP files are
> controlled by SVN, so you can rollback at any time, but say the
> upgrade
> includes several key modifications to a MySQL table and perhaps the
> changing of some core data.
>
> How (if at all?!) do you handle the versioning of the database and
> data
> itself, so you can keep both PHP and SQL structure in sync?

Good thread!

Though perhaps a MySQL list would have more insight...

I wonder if perhaps some larger-scale sites might not just buy a whole
'nother DB server, and flip the connection line to the "new" one...

Granted, you lose all new data if you have to revert, but at least you
know you have a valid state to revert to...

Kinda pricey, but there it is.

I suppose the other thing I do that hasn't been mentioned is plan my
DB schema a bit farther out than my PHP code, so that I've got new
empty unused fields/tables sitting there, and not doing any harm, but
that I can add features without worrying that they won't work.

I've done this successfully a couple times for simple stuff, but it
usually won't work for anything remotely complex, as I don't
anticipate the DB needs correctly.

Still, better to have an unused "Future Tech #1" field if you know
you'll need it than to try to add it at the last minute when you do
need it, for simple stuff.

I suppose one could do a mysql dump of at least the schema and svn
that...

-- 
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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Jarrel Cobb

agreed, Dreamweaver is not the tool for you.  But I've found it to be useful
for whipping up quick HTML newsletters from slice photoshop layouts.  And I
like to see incremental change so if I used the browser refresh technique
trying to tweak the crappy table layouts photoshop spits out, I'd be
pressing "CTRL+S, ALT+TAB, CTRL+R" 100+ times!

On 4/11/07, Jochem Maas <[EMAIL PROTECTED]> wrote:


Jarrel Cobb wrote:
> There is a code view in Dreamweaver.  The split view is useful for
making
> handcoded changes to HTML in the top code view and seeing the immediate
> result in the bottom design view.   You dont have to use the WYSIWYG
> features.
>

ye

I'm glad to say my position allows me not to use *any* of it's 'features'.
simply put, in this day and age, HTML is not a visual thing at all - it's
purely
semantic (and writing things like '' or '' are not very hard),
layout and styling
is the realm of CSS (which dreamweaver is very good as screwing up).
not to mention these 'facts':

1. often as not I use javascript to manipulate the dom and build/change
pages,
there are plenty like me doing the same.
2. HTML and [php] code (other than simple presentation logic) should be
kept as
far apart as possible).
3. CTRL+R (what Robbert said)

but at the end of the day - whatever works for you, right?

darn - it's all turned serious :-)



Re: [PHP] location of the PHP executable

2007-04-11 Thread Jochem Maas
your script should try it's best to find the executable, on failure
you might consider having it mail an error to you so at least you
can pre-empt the client with regard to getting things working.

most windows machines will probably have there php binary at:

$_ENV['PHPRC'].'php.exe'

variations on the exe name can be (IIRC):

'php-win.exe'
'php-cli.exe'

I think you can be pretty sure about $_ENV['_'] on *nix
systems.

another to consider is a simple installer which tries to
find the exe and on failure offers the user a prompt to say where it
is .. that info can then be stored for use at a later date.

Mattias Thorslund wrote:
> Jochem Maas wrote:
> 
>>> have you tried looking for this info you want?
>>>   
>>   
> 
> Yup, but the manual seems kind of "light" on the subject.
> 
> 
>>> I can't say for sure if it always exists but on the few boxes
>>> I tried I found and entry in both $_SERVER and $_ENV:
>>>
>>> "_" => '/usr/bin/php'
>>>   
>>   
> 
> I found these in $_ENV and $_SERVER, on Linux. I don't have handy access
> to a working Windows installation, yet it needs to work on Windows as well.
> 
> If it really does exist on Windows, this might be the ticket, otherwise
> a partial solution for Linux only.
> 
> 
>>> but that was only on linux.
>>> on windows (where my php cli install is a bit borked),
>>> I didn't find it but I did find "PHPRC" which points to
>>> the directory that the php executable lives in.
>>>   
>>   
> 
> That's at least something. If someone could confirm, that would be great.
> 
> I used the following command (at the command-line) to check the contents
> of $_SERVER:
> 
> php -r 'print_r($_SERVER);'
> 
> Obviously, $_ENV can be checked similarly.
> 
> 
>>> these maybe of some use.
>>>   
>>   
> 
> Yes very useful, thanks.
> 
> 
>>> then again what ever it is your trying to do with the php script
>>> you seem to need to run inside another instance of php could probably
>>> be run within the context of the calling script - if you run it inside
>>> a function you can stop any kind of variable scope clashes (assuming there 
>>> are
>>> no symbol name clashes [e.g. duplicate functions/classes]):
>>>
>>> function runit()
>>> {
>>> include 'myscript.php';
>>> }
>>>
>>> it's just a thought.
>>>   
>>   
> 
> Unfortunately, I think it's not an option in my case. The sub-process I
> run this way are way, way too big to include in the main process.  As
> long as I was just running it on my own systems, it was easy to
> hard-code the location of the PHP executable but now that it's being
> distributed, it needs to "just work"...
> 
> Thanks again,
> 
> Mattias
> 

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



Re: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Robert Cummings
On Thu, 2007-04-12 at 03:24 +0200, Jochem Maas wrote:
> Robert Cummings wrote:
> > On Wed, 2007-04-11 at 21:14 -0400, Jarrel Cobb wrote:
> >> You have to save the HTML file to see the changes with a browser refresh.
> >> You can use the design view to make sure you are atleast in the ballpark
> >> before saving and using the IE/Firefox preview.  I know most people go with
> >> CSS layout now a days, but this was insanely useful for complicated table
> >> layouts involving many nested tables/col and row spans, etc.  Also good for
> >> detailing sliced photoshop templates...again not so useful for "good" 
> >> design
> >> but nice for a quick and dirty fix.  There are some rendering bugs in the
> >> design view but it does get you in the ballpark atleast.
> > 
> > You're right, I need to use CTRL+S, ALT+TAB, CTRL+R. Those 3 keystrokes
> > really slow me down... NOT! CSS or not, the browser has always
> > sufficed... in fact everything that would be expected to work in the
> > browser just works the way you'd expect... Flash, JavaScript, CSS,
> > header redirects, meta refreshes, etc, etc... maybe it's because I use
> > the browser *lol*. Anything else is just an imposter.
> 
> what did you just call me? :-D

Nothing, but don't look now... you've peed your pants too >:)

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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Jochem Maas
Robert Cummings wrote:
> On Wed, 2007-04-11 at 21:14 -0400, Jarrel Cobb wrote:
>> You have to save the HTML file to see the changes with a browser refresh.
>> You can use the design view to make sure you are atleast in the ballpark
>> before saving and using the IE/Firefox preview.  I know most people go with
>> CSS layout now a days, but this was insanely useful for complicated table
>> layouts involving many nested tables/col and row spans, etc.  Also good for
>> detailing sliced photoshop templates...again not so useful for "good" design
>> but nice for a quick and dirty fix.  There are some rendering bugs in the
>> design view but it does get you in the ballpark atleast.
> 
> You're right, I need to use CTRL+S, ALT+TAB, CTRL+R. Those 3 keystrokes
> really slow me down... NOT! CSS or not, the browser has always
> sufficed... in fact everything that would be expected to work in the
> browser just works the way you'd expect... Flash, JavaScript, CSS,
> header redirects, meta refreshes, etc, etc... maybe it's because I use
> the browser *lol*. Anything else is just an imposter.

what did you just call me? :-D

> 
> Cheers,
> Rob.

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



Re: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Jochem Maas
Jarrel Cobb wrote:
> There is a code view in Dreamweaver.  The split view is useful for making
> handcoded changes to HTML in the top code view and seeing the immediate
> result in the bottom design view.   You dont have to use the WYSIWYG
> features.
> 

ye

I'm glad to say my position allows me not to use *any* of it's 'features'.
simply put, in this day and age, HTML is not a visual thing at all - it's purely
semantic (and writing things like '' or '' are not very hard), layout 
and styling
is the realm of CSS (which dreamweaver is very good as screwing up).
not to mention these 'facts':

1. often as not I use javascript to manipulate the dom and build/change pages,
there are plenty like me doing the same.
2. HTML and [php] code (other than simple presentation logic) should be kept as
far apart as possible).
3. CTRL+R (what Robbert said)

but at the end of the day - whatever works for you, right?

darn - it's all turned serious :-)

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



Re: [PHP] dynamic web interface and size

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 10:57 am, Robert Cummings wrote:
> On Wed, 2007-04-11 at 17:44 +0200, Tijnema ! wrote:
>> On 4/11/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> >
>> >
>> > 1000 pixels?
>> >
>> > Woof.
>> >
>> > Guess my 800x600 box is not in your market...
>>
>> 800x600 :|
>>
>> Using 1600x1200 here :)
>>
>>
>> I like the idea,. because most sites are made for 800x600 and they
>> are
>> so small on my screen...
>
> Get Opera, it has the cool zoom that Microsoft copied. I too use
> 1600x1200 res.

Of the many computers I own/use regularly, one of them happens to be
my "main" desktop which I've had for about 10 years.

It's a screaming AMD K-6 450 MHz processor, with a whopping 128M RAM
and running RedHat 7.

I suppose, in theory, I could run out and buy new hardware to replace
it, and, actually, when I move into my new house, I probably will
re-purpose some other box as my main desktop...

In the meantime, yes, I use 800x600 a lot, no Flash, and have yet to
have a problem with anything I *need* this box to do.

'Course, I do have a new-ish laptop, for those rare moments when I
actually want to see a Flash page badly enough to haul it out and fire
it up...  Which hasn't happened so far, except for the bands that keep
sending me demos without reading the directions:
http://uncommonground.com/contact.htm

* Actually, I installed RAM up to 284M a few weeks back for $50, so
that I could thumb my nose at a guy who's abandoning a 450MHz 384M box
as "too old" by letting him know I had just upgraded my main desktop
to match the specs of the one he has to throw away to use MS
products...  But I'd be just as happy to pull that RAM out, as it made
little real difference.

YMMV
NAIAA
IANAL

-- 
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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 21:14 -0400, Jarrel Cobb wrote:
> You have to save the HTML file to see the changes with a browser refresh.
> You can use the design view to make sure you are atleast in the ballpark
> before saving and using the IE/Firefox preview.  I know most people go with
> CSS layout now a days, but this was insanely useful for complicated table
> layouts involving many nested tables/col and row spans, etc.  Also good for
> detailing sliced photoshop templates...again not so useful for "good" design
> but nice for a quick and dirty fix.  There are some rendering bugs in the
> design view but it does get you in the ballpark atleast.

You're right, I need to use CTRL+S, ALT+TAB, CTRL+R. Those 3 keystrokes
really slow me down... NOT! CSS or not, the browser has always
sufficed... in fact everything that would be expected to work in the
browser just works the way you'd expect... Flash, JavaScript, CSS,
header redirects, meta refreshes, etc, etc... maybe it's because I use
the browser *lol*. Anything else is just an imposter.

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] Posting a variable

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 20:12 -0500, Richard Lynch wrote:
> On Wed, April 11, 2007 12:53 pm, [EMAIL PROTECTED] wrote:
> > Quoting Robert Cummings <[EMAIL PROTECTED]>:
> >
> >> On Wed, 2007-04-11 at 09:59 -0700, [EMAIL PROTECTED] wrote:
> >> > 1- your mysql query statement is better to have a WHERE part too.
> >> > 2- I would use mysql_fetch_row instead of mysql_fetch_assoc
> >>
> >> Ummm, why would you want to reduce clarity and maintainability by
> >> using
> >> mysql_fetch_row()?
> >
> > hmmm, I just remember in my php class a while back, my teacher didn't
> > even
> > bother teaching us about mysql_fetch_assoc, and when a student asked
> > about it,
> > he said don't bother using it, just use mysql_fetch_row so I ended up
> > using this
> > function ever since. I'm guessing he was wrong??
> 
> He wasn't "wrong"
> 
> It's a religious question.
> 
> I find mysql_fetch_assoc to be less clear because you end up not
> necessarily using the data until much later, and by the time you get
> to the line that has:
> 
> $row['foozie']
> 
> in it, you've lost track of what 'foozie' is...

I'd rather lose track of $row['foozie'] than $row[1]. Either way, if
your code is structured well, the row data should be in close proximity
to it's use. At the very least, if your field names are informative
instead of 'foozie', maybe 'email' then I think you'll have less trouble
remembering. This isn't really a religious issue... it's a clarity
issue. I mean, why bother naming variables if you think you might get
confused later. Just call your vars $foo1 to $fooX-- at least that's the
path you've laid out as an argument.

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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Jarrel Cobb

You have to save the HTML file to see the changes with a browser refresh.
You can use the design view to make sure you are atleast in the ballpark
before saving and using the IE/Firefox preview.  I know most people go with
CSS layout now a days, but this was insanely useful for complicated table
layouts involving many nested tables/col and row spans, etc.  Also good for
detailing sliced photoshop templates...again not so useful for "good" design
but nice for a quick and dirty fix.  There are some rendering bugs in the
design view but it does get you in the ballpark atleast.

On 4/11/07, Robert Cummings <[EMAIL PROTECTED]> wrote:


On Wed, 2007-04-11 at 20:59 -0400, Jarrel Cobb wrote:
> There is a code view in Dreamweaver.  The split view is useful for
> making handcoded changes to HTML in the top code view and seeing the
> immediate result in the bottom design view.   You dont have to use the
> WYSIWYG features.

I see changes by hitting CTRL+R on any given browser for which I'm
debugging... at least when those browsers show rendering bugs I know I'm
fixing bugs for those browsers and not Dreamweaver bugs.

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.  |
`'




Re: [PHP] Posting a variable

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 12:53 pm, [EMAIL PROTECTED] wrote:
> Quoting Robert Cummings <[EMAIL PROTECTED]>:
>
>> On Wed, 2007-04-11 at 09:59 -0700, [EMAIL PROTECTED] wrote:
>> > 1- your mysql query statement is better to have a WHERE part too.
>> > 2- I would use mysql_fetch_row instead of mysql_fetch_assoc
>>
>> Ummm, why would you want to reduce clarity and maintainability by
>> using
>> mysql_fetch_row()?
>
> hmmm, I just remember in my php class a while back, my teacher didn't
> even
> bother teaching us about mysql_fetch_assoc, and when a student asked
> about it,
> he said don't bother using it, just use mysql_fetch_row so I ended up
> using this
> function ever since. I'm guessing he was wrong??

He wasn't "wrong"

It's a religious question.

I find mysql_fetch_assoc to be less clear because you end up not
necessarily using the data until much later, and by the time you get
to the line that has:

$row['foozie']

in it, you've lost track of what 'foozie' is...

I try to get my SELECT statement and a line with $foozie "near" each
other:
$query = "select  as foozie from whatsit where umnh-hunh";
$whatever = mysql_query($query, $connection);
if (!$connection){
  //insert proper error handling here
}
while (list($foozie) = mysql_fetch_row($whatever)){
}

But this is really just a religious question, and there are many other
equally valid idioms.

YMMV
IANAL
NAIAA

-- 
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] Posting a variable

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 11:21 am, Zhimmy Kanata wrote:

> echo "$username";
> echo "$username02";

Copy/paste these two lines *EVERYWHERE* in your script that you can find:
$username =
or
$username02 =

-- 
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] Re: Design Dilemma - Database Data Abstraction

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 3:40 pm, Roman Neuhauser wrote:
> What's easy for an idiot to use is often a weak tool if you need to
> get
> a bit more serious, cf the problems with composite keys you described.
> Sure, Lego duplo is so idiot proof that a year old can bang two pieces
> each against the other cheerfully.  You won't build a helicopter with
> it, however.

Sure you will!

http://shop.lego.com/Product/?p=7903

:-)

Actually, on a far more serious note, researchers HAVE built a working
helicopter with Lego:
http://lego.roerei.nl/helicopter-rotor-demo/helicopter-rotor-demo.htm

I dunno if I should insert a smilie on this one 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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 20:59 -0400, Jarrel Cobb wrote:
> There is a code view in Dreamweaver.  The split view is useful for
> making handcoded changes to HTML in the top code view and seeing the
> immediate result in the bottom design view.   You dont have to use the
> WYSIWYG features. 

I see changes by hitting CTRL+R on any given browser for which I'm
debugging... at least when those browsers show rendering bugs I know I'm
fixing bugs for those browsers and not Dreamweaver bugs.

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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Jarrel Cobb

There is a code view in Dreamweaver.  The split view is useful for making
handcoded changes to HTML in the top code view and seeing the immediate
result in the bottom design view.   You dont have to use the WYSIWYG
features.

On 4/11/07, Richard Lynch <[EMAIL PROTECTED]> wrote:


On Wed, April 11, 2007 6:00 pm, Jochem Maas wrote:
> Robert Cummings wrote:
>> On Wed, 2007-04-11 at 18:53 -0400, Robert Cummings wrote:
>>> On Wed, 2007-04-11 at 17:43 -0400, Arbitrio, Pat wrote:
 Other skills:

 * Dreamweaver
>>> *ROFLMFAO*
>>
>> Still *ROFLMFAO*
>
> I don't see what's so funny. there is great skill involved
> with becoming proficient in using Dreamweaver .

God knows I can't use it.

I tried once, and in about 3 minutes crashed the dang thing just
trying to drag some table borders around.

This was a repeatable problem (every time I tried, about 3) so then I
just gave up.

But I'm the guy who took ~10 years to figure out that cramming more
stuff into less screen real estate was a Bad Idea, and that some extra
white space was a Good Thing.

So there ya go.

Ya gotta at least give him points for having the location in the
Subject line, unlike *some* job posters.

--
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] location of the PHP executable

2007-04-11 Thread Mattias Thorslund
Jochem Maas wrote:

> > have you tried looking for this info you want?
> >   
>   

Yup, but the manual seems kind of "light" on the subject.


> > I can't say for sure if it always exists but on the few boxes
> > I tried I found and entry in both $_SERVER and $_ENV:
> >
> > "_" => '/usr/bin/php'
> >   
>   

I found these in $_ENV and $_SERVER, on Linux. I don't have handy access
to a working Windows installation, yet it needs to work on Windows as well.

If it really does exist on Windows, this might be the ticket, otherwise
a partial solution for Linux only.


> > but that was only on linux.
> > on windows (where my php cli install is a bit borked),
> > I didn't find it but I did find "PHPRC" which points to
> > the directory that the php executable lives in.
> >   
>   

That's at least something. If someone could confirm, that would be great.

I used the following command (at the command-line) to check the contents
of $_SERVER:

php -r 'print_r($_SERVER);'

Obviously, $_ENV can be checked similarly.


> > these maybe of some use.
> >   
>   

Yes very useful, thanks.


> > then again what ever it is your trying to do with the php script
> > you seem to need to run inside another instance of php could probably
> > be run within the context of the calling script - if you run it inside
> > a function you can stop any kind of variable scope clashes (assuming there 
> > are
> > no symbol name clashes [e.g. duplicate functions/classes]):
> >
> > function runit()
> > {
> > include 'myscript.php';
> > }
> >
> > it's just a thought.
> >   
>   

Unfortunately, I think it's not an option in my case. The sub-process I
run this way are way, way too big to include in the main process.  As
long as I was just running it on my own systems, it was easy to
hard-code the location of the PHP executable but now that it's being
distributed, it needs to "just work"...

Thanks again,

Mattias

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



Re: [PHP] location of the PHP executable

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 2:49 pm, Mattias Thorslund wrote:
> I have looked in the documentation but can't find it:
>
> My PHP script (which is run from the command prompt - CLI) needs to
> know
> the file system location of the PHP executable. This is because it
> needs
> to run a second PHP script. I know about the "which" command but it's
> not available in all OSes, and that might not be the currently running
> executable anyway.
>
> I could prompt the user for this, but that seems kind of silly.
> Surely,
> there must be some way of looking it up automatically?

The generalized answer to any question of this nature is:

If the answer you want isn't in  output, then the
answer you want probably isn't available.

In *my* installation:
which php
yields:
/usr/bin/php

Then:
php -i | grep "/usr/bin/php"
yields $_SERVER["_"] and $_ENV["_"]

No promise this works for any/all platforms, however.

PS For the 'locate' sub-thread -- You can't even guarantee that
'locate' will be available, much less initialized...  I don't think
it's a good solution, in general.

YMMV
NAIAA
IANAL

-- 
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] Re: PHP Directory List Script Files over 2 GB

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 3:36 pm, Robert M wrote:
> Does anyone else have any other ideas how to resolve this, I have
> tried
> multiple different methods all failed.
>
> Does the 2 GB limitation using filesize have an alternate method of
> producing the output. ?
>
> Thank you Logan for trying.

The first thing I'd recommend is writing a one-line test script that did:


As it stands now, I just deleted your emails as they were MUCH too
long...

That said, PHP will handle INT only up to ~2 billion, so I don't quite
know how it could come back as what you want, unless the function
returns 'text' datatype, which I doubt...

I do recall discussion of this and some kind of solutions from way
back when...

If nothing else, you could use http://php.net/exec to ask the OS how
big the file is, and bypass filesize altogether.

-- 
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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 6:00 pm, Jochem Maas wrote:
> Robert Cummings wrote:
>> On Wed, 2007-04-11 at 18:53 -0400, Robert Cummings wrote:
>>> On Wed, 2007-04-11 at 17:43 -0400, Arbitrio, Pat wrote:
 Other skills:

 * Dreamweaver
>>> *ROFLMFAO*
>>
>> Still *ROFLMFAO*
>
> I don't see what's so funny. there is great skill involved
> with becoming proficient in using Dreamweaver .

God knows I can't use it.

I tried once, and in about 3 minutes crashed the dang thing just
trying to drag some table borders around.

This was a repeatable problem (every time I tried, about 3) so then I
just gave up.

But I'm the guy who took ~10 years to figure out that cramming more
stuff into less screen real estate was a Bad Idea, and that some extra
white space was a Good Thing.

So there ya go.

Ya gotta at least give him points for having the location in the
Subject line, unlike *some* job posters.

-- 
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] mysql if empty

2007-04-11 Thread Jim Lucas

tedd wrote:

At 5:53 PM -0700 4/10/07, Jim Lucas wrote:

Anyways, here is the expanded version hopefully to your liking.


# Your request failed.  Make up your own custom way of displaying 
the error.

} else {
if ( mysql_num_rows($results) > 0 ) {
while ( $row = mysql_fetch_assoc($result) ) {
if ( isset($row['client']) && !empty($row['client']) ) {
echo $row['client'] . '';
}
}
} else {
echo 'No results found!';
}
}
?>

Does this satisfy you?


Actually, it's $result and not $results. Other than that, it works fine 
as far as I can tell.


Cheers,

tedd

good catch, missed that.

Thanks

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



Re: [PHP] Bind IP with fsockopen

2007-04-11 Thread chris
Hi ive tried \r\n\n and pretty much every other combination I can think of. 
But I still

cant get it to return a line break.

Otherwise the script is working though.


- Original Message - 
From: "Richard Lynch" <[EMAIL PROTECTED]>

To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 11, 2007 1:19 AM
Subject: Re: [PHP] Bind IP with fsockopen





fputs adds a newline, and you've got \r\n already, so your total
output in the original is \r\n\n

In the socket_bind one, you've got none of the \r\n stuff at all, much
less \r\n\n

On Tue, April 10, 2007 5:56 pm, [EMAIL PROTECTED] wrote:

Im having trouble converting this snippet to use the bind_socket
function.

my original code is..



I think im getting stuck on the fputs bit.. I have this which does not
work..



Thanks

--
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] Help with table in database and login scripts.

2007-04-11 Thread Chris

Karl James wrote:
 
Team,
 
I want to know if my table is setup correctly.
 
I am creating a site where team owners control fantasy football teams.

Imaginary teams. They can trade players, add and drop them as long as
they are under the salary cap at all times. if not they are given a warning
to make a different move or something along those lines.
 
I have created a table for league_members.

Can you tell me if I have this set up correctly.
 
This will be for the register.php form



  Field  Type Attributes Null Default Extra Action 
   fantasyteamname  varchar(30)   No  
   firstname  varchar(20)   No  
   lastname  varchar(30)   No  
   username  varchar(10)   No  
   emailaddress  varchar(50)   No  0
   address  varchar(50)   No  
   city   varchar(30)   No  
   state  varchar(30)   No  
   zipcode  tinyint(5)   No  0
   homephonenumber  tinyint(4)   No  0
   mobilephonenumber  tinyint(4)   No  0
   favoriteprofootballteam  varchar(50)   No  0
   favoritecollegeteam  varchar(50)   No  0   


I'd make fantasyteamname, favoriteprofootballteam, and 
favoritecollegeteam int's instead and have them as separate database tables.


I'm sure many people are going to share the same favourite pro team and 
college teams so you could make a dropdown box with those options 
instead of making your users type them in ;)


Fantasyteamname should go with the fantasy team details - not be with 
the user info so keep the team name with the other details, and just an 
id to link between them.


--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] SQL Source Control

2007-04-11 Thread Chris


I'm surprised (or rather, I'm unaware of) there is no native MySQL 
solution for this situation.


Considering it's not a mysql specific problem I'd be surprised if there was.

Postgres lets you do database changes inside a transaction, eg:

begin;
alter table x add column y int;
...
commit;

but two problems with that:

1) mysql doesn't support it (nor do a lot of databases) even when using 
innodb (and using myisam is out of the question for this because it 
doesn't support transactions)


2) it won't help in a web environment because you can't rollback once 
the transaction has finished & you are testing the changes and then find 
the problem.



No easily solution unfortunately apart from writing 'undo' scripts or 
having a backup handy..


--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread JM Guillermin
- Original Message - 
From: "Robert Cummings" <[EMAIL PROTECTED]>

To: "Jay Blanchard" <[EMAIL PROTECTED]>
Cc: "Jochem Maas" <[EMAIL PROTECTED]>; 
Sent: Thursday, April 12, 2007 1:05 AM
Subject: RE: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!



On Wed, 2007-04-11 at 18:03 -0500, Jay Blanchard wrote:

[snip]
Robert Cummings wrote:
> On Wed, 2007-04-11 at 18:53 -0400, Robert Cummings wrote:
>> On Wed, 2007-04-11 at 17:43 -0400, Arbitrio, Pat wrote:
>>> Other skills: 
>>>
>>> * Dreamweaver 
>> *ROFLMFAO*
> 
> Still *ROFLMFAO*


I don't see what's so funny. there is great skill involved
with becoming proficient in using Dreamweaver .
[/snip]

ROFLMMFAO


I think I peed my pants :B



me too :))

jm





--
..
| 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 18:03 -0500, Jay Blanchard wrote:
> [snip]
> Robert Cummings wrote:
> > On Wed, 2007-04-11 at 18:53 -0400, Robert Cummings wrote:
> >> On Wed, 2007-04-11 at 17:43 -0400, Arbitrio, Pat wrote:
> >>> Other skills: 
> >>>
> >>> * Dreamweaver 
> >> *ROFLMFAO*
> > 
> > Still *ROFLMFAO*
> 
> I don't see what's so funny. there is great skill involved
> with becoming proficient in using Dreamweaver .
> [/snip]
> 
> ROFLMMFAO

I think I peed my pants :B

-- 
..
| 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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Jay Blanchard
[snip]
Robert Cummings wrote:
> On Wed, 2007-04-11 at 18:53 -0400, Robert Cummings wrote:
>> On Wed, 2007-04-11 at 17:43 -0400, Arbitrio, Pat wrote:
>>> Other skills: 
>>>
>>> * Dreamweaver 
>> *ROFLMFAO*
> 
> Still *ROFLMFAO*

I don't see what's so funny. there is great skill involved
with becoming proficient in using Dreamweaver .
[/snip]

ROFLMMFAO

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



Re: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Jochem Maas
Robert Cummings wrote:
> On Wed, 2007-04-11 at 18:53 -0400, Robert Cummings wrote:
>> On Wed, 2007-04-11 at 17:43 -0400, Arbitrio, Pat wrote:
>>> Other skills: 
>>>
>>> * Dreamweaver 
>> *ROFLMFAO*
> 
> Still *ROFLMFAO*

I don't see what's so funny. there is great skill involved
with becoming proficient in using Dreamweaver .
















. without commiting suicide in the attempt.

> 
> Cheers,
> Rob.

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



Re: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 18:53 -0400, Robert Cummings wrote:
> On Wed, 2007-04-11 at 17:43 -0400, Arbitrio, Pat wrote:
> >
> > Other skills: 
> >
> > * Dreamweaver 
> 
> *ROFLMFAO*

Still *ROFLMFAO*

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] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 17:43 -0400, Arbitrio, Pat wrote:
>
> Other skills: 
>
> * Dreamweaver 

*ROFLMFAO*

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] location of the PHP executable

2007-04-11 Thread Jochem Maas
Mattias Thorslund wrote:
> Jim Lucas wrote:
...

> $ /my-location-of/php myscript.php
> /my-location-of/php
> $
> 
> I was hoping there's a function or $_SERVER property that would contain
> this?

have you tried looking for this info you want?
I can't say for sure if it always exists but on the few boxes
I tried I found and entry in both $_SERVER and $_ENV:

"_" => '/usr/bin/php'

but that was only on linux.
on windows (where my php cli install is a bit borked),
I didn't find it but I did find "PHPRC" which points to
the directory that the php executable lives in.

these maybe of some use.
then again what ever it is your trying to do with the php script
you seem to need to run inside another instance of php could probably
be run within the context of the calling script - if you run it inside
a function you can stop any kind of variable scope clashes (assuming there are
no symbol name clashes [e.g. duplicate functions/classes]):

function runit()
{
include 'myscript.php';
}

it's just a thought.
> 
> Thanks again,
> 
> Mattias
> 

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



RE: [PHP] location of the PHP executable

2007-04-11 Thread Buesching, Logan J
  IF db not exists THEN
locate -u 
  END-IF

I'd hate to see the time it'd take to create a first-time database...
this could take awhile to run.

-Original Message-
From: Davi [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 11, 2007 6:10 PM
To: php-general@lists.php.net
Subject: Re: [PHP] location of the PHP executable

Em Quarta 11 Abril 2007 18:50, Jarrel Cobb escreveu:
> Don't you have to run locate -u first to generate the database before
using
> locate?  You can't just assume a database exists already can you?
>

If you can use locate, you can use which... =P

BTW, do something to check OS then:

IF OS == *nix THEN
  IF exists /usr/bin/which THEN
which php
  ELSE
IF exists /usr/bin/locate THEN
  locate php | grep -iE "php$"
ELSE
  IF exists /usr/bin/find THEN
find / -name php | grep -iE "php$"
  ELSE
 cd / && ls php -Rv
  END-IF
   END-IF
  END-IF
ELSE
  cd \
  dir php*.exe /s
END-IF


Check if I don't miss any END-IF... =P

[]s

-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Agora com fortune:
"rugged, adj.:
Too heavy to lift."

-- 
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] location of the PHP executable

2007-04-11 Thread Mattias Thorslund
Jim Lucas wrote:
> Mattias Thorslund wrote:
>> Hi,
>>
>> I have looked in the documentation but can't find it:
>>
>> My PHP script (which is run from the command prompt - CLI) needs to know
>> the file system location of the PHP executable. This is because it needs
>> to run a second PHP script. I know about the "which" command but it's
>> not available in all OSes, and that might not be the currently running
>> executable anyway.
>>
>> I could prompt the user for this, but that seems kind of silly. Surely,
>> there must be some way of looking it up automatically?
>>
>> Thanks,
>>
>> Mattias
>>
>
> What OS are you working with
>
> Assuming you are on a *nix box this should work
>
> #locate "/php" | grep "/php$"
>
> this should give you locations that have /php as the end of the line
>
>
> on windows you could do this
>
> cd \
> dir /s php*.exe

Thanks Jim (and others) for the suggestions. I think they will be helpful if 
there
isn't a way to do what I'm looking for:

Ideally, I would like to get the location of the PHP executable that is
actually executing the script. I'm thinking there would be some way to
find out while the script is executing. Something like:



Running it from the command line (again fiction):

$ /my-location-of/php myscript.php
/my-location-of/php
$

I was hoping there's a function or $_SERVER property that would contain
this?

Thanks again,

Mattias

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



[PHP] Re: PHP textbook suggestions?

2007-04-11 Thread LuKreme

On 11-Apr-2007, at 13:06, Chris Lott wrote:

You're missing the point-- it's not that there is a practical
difference in the examples, it's that there IS a difference, the
students see it, and it is an extra point of confusion that isn't
needed if one is being consistent.


I have to disagree, and have had very little confusion myself in  
teaching php.  I jsut explain it the way I use it.  Use double quotes  
unless your quoted text is going to contain HTML with quotes; and as  
a bonus, php will expand variables in double quotes.



I completely recognize that the practical effects of the differences
are small, but the learning effects of the inconsistencies is much
larger, particularly with a group of students that are not techies,
not geeks, not computer science or IT students...


Well, non-techie non-geeks are going to get very little out of  
learning to code php and are likely going to end up writing crap code  
with loverly security holes that bring ebservers to their knees and  
propagate millions of spam emails.  Walk before you run, and all  
that.  PHP is not a good choice as a 'learning' language precisely  
because it is so flexible.


Much better to teach a much more rigid and concise language like obj- 
c or c++ if you want to teach programming to tyros.  Heck, even perl.



--
It was intended that when Newspeak had been adopted once and for all  
and Oldspeak forgotten, a heretical thought...should be literally  
unthinkable, at least so far as thought is dependent on words.


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



Re: [PHP] SQL Source Control

2007-04-11 Thread Travis Doherty
Richard Davey wrote:

> Hi all,
>
> I know a lot of you use various means for PHP source control (CVS,
> SVN, etc), which is all well and fine, but how do you manage source
> control on your databases?
>
> Say you've got an upgrade to a site, all of the new PHP files are
> controlled by SVN, so you can rollback at any time, but say the
> upgrade includes several key modifications to a MySQL table and
> perhaps the changing of some core data.
>
> How (if at all?!) do you handle the versioning of the database and
> data itself, so you can keep both PHP and SQL structure in sync?
>
> Cheers,
>
> Rich


One thing we do is add a table called 'versions' to each application,
this table just has one row and a column for the schema version (and
sometimes other stuff less important.)

When the app runs it checks to ensure that its defined constant
DBVERSION matches that of the database it is running against.  This has
actually helped out more than once, though not a solution to the actual
problem.

Travis Doherty

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



Re: [PHP] location of the PHP executable

2007-04-11 Thread Davi
Em Quarta 11 Abril 2007 18:50, Jarrel Cobb escreveu:
> Don't you have to run locate -u first to generate the database before using
> locate?  You can't just assume a database exists already can you?
>

If you can use locate, you can use which... =P

BTW, do something to check OS then:

IF OS == *nix THEN
  IF exists /usr/bin/which THEN
which php
  ELSE
IF exists /usr/bin/locate THEN
  IF db not exists THEN
locate -u 
  END-IF
  locate php | grep -iE "php$"
ELSE
  IF exists /usr/bin/find THEN
find / -name php | grep -iE "php$"
  ELSE
 cd / && ls php -Rv
  END-IF
   END-IF
  END-IF
ELSE
  cd \
  dir php*.exe /s
END-IF


Check if I don't miss any END-IF... =P

[]s

-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Agora com fortune:
"rugged, adj.:
Too heavy to lift."

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



Re: [PHP] PHP editor

2007-04-11 Thread Susana Carrasco

For Win, I use either Notepad++ or PHP Designer (www.mpsoftware.org). For
Linux I use Joe.


Re: [PHP] location of the PHP executable

2007-04-11 Thread Jarrel Cobb

Don't you have to run locate -u first to generate the database before using
locate?  You can't just assume a database exists already can you?

On 4/11/07, Jim Lucas <[EMAIL PROTECTED]> wrote:


Mattias Thorslund wrote:
> Hi,
>
> I have looked in the documentation but can't find it:
>
> My PHP script (which is run from the command prompt - CLI) needs to know
> the file system location of the PHP executable. This is because it needs
> to run a second PHP script. I know about the "which" command but it's
> not available in all OSes, and that might not be the currently running
> executable anyway.
>
> I could prompt the user for this, but that seems kind of silly. Surely,
> there must be some way of looking it up automatically?
>
> Thanks,
>
> Mattias
>

What OS are you working with

Assuming you are on a *nix box this should work

#locate "/php" | grep "/php$"

this should give you locations that have /php as the end of the line


on windows you could do this

cd \
dir /s php*.exe



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




[PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-11 Thread Arbitrio, Pat
You folks know anyone who fits this one?  

 

Description:

Your task would be the maintenance and extension of our dynamic and
cutting edge Intranet and Internet web sites written in PHP5.

PHP/Mysql Experience: 3-4 years, where 1 year must be PHP5.

 

Candidates must be well versed in: 

* PHP5 

* Mysql 

* JavaScript 

* Web services 

* Object-oriented programming 

 

Candidates must show: 

* Experience working through an entire life cycle of a web-based
application from concept, implementation, testing to maintenance. 

* Familiarity with application level network protocols (e.g., HTTP
and/or SSL). 

* Excellent communication and relationship skills along with being a
strong team player. 

* Demonstrable analytical problem-solving skills. 

* Ability to thrive in a high-pressured, unstructured, customer-oriented
environment. 

 

Other skills: 

* AJAX 

* XHTML/HTML, CSS 

* Linux 

* Dreamweaver 

* Subversion 

* Unix Shell/Perl

 

The link to apply is as follows.  

http://www.wwe-careers.com/wwe/jobboard/SearchPositions.asp?ShowJobID=61
1&Keywords
 =

 

Thanks,

Pat Arbitrio

Sr. Staffing Specialist

World Wrestling Entertainment, Inc.

1241 East Main Street

Stamford, CT 06902

 



Re: [PHP] location of the PHP executable

2007-04-11 Thread Jim Lucas

Mattias Thorslund wrote:

Hi,

I have looked in the documentation but can't find it:

My PHP script (which is run from the command prompt - CLI) needs to know
the file system location of the PHP executable. This is because it needs
to run a second PHP script. I know about the "which" command but it's
not available in all OSes, and that might not be the currently running
executable anyway.

I could prompt the user for this, but that seems kind of silly. Surely,
there must be some way of looking it up automatically?

Thanks,

Mattias



What OS are you working with

Assuming you are on a *nix box this should work

#locate "/php" | grep "/php$"

this should give you locations that have /php as the end of the line


on windows you could do this

cd \
dir /s php*.exe



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



[PHP] Re: PHP Directory List Script Files over 2 GB

2007-04-11 Thread Robert M

Well it looks like I am forced to use a different approach do to the
limitations of PHP
http://bugs.php.net/bug.php?id=27792


This Bug has been around now for HOW long now.

Seems to me that it would have been addressed in the past few years,
Gigabyte files have been around a long time. Maybe not for the average
WEB server but for intranets wanting to display files and sizes


well I cant complain too much , this has taught me quite a bit on how
to do things using php.

The sprintf("%u", filesize($file))  does not appear to resolve this
issue either.
Thanks to all

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



Re: [PHP] Re: PHP Directory List Script Files over 2 GB

2007-04-11 Thread Seak, Teng-Fong

Robert M wrote:

Does anyone else have any other ideas how to resolve this, I have tried
multiple different methods all failed.

Does the 2 GB limitation using filesize have an alternate method of
producing the output. ?

Thank you Logan for trying.

   I think you'd better file a bug report to PHP.  A lot of old/legacy 
applications were written in the period when Gigabytes is an 
astronomical number.  They're not supposed to support such a big number 
and need a rewrite.  PHP might be in this situation.


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



Re: [PHP] mysql if empty

2007-04-11 Thread tedd

At 5:53 PM -0700 4/10/07, Jim Lucas wrote:

Anyways, here is the expanded version hopefully to your liking.


	# Your request failed.  Make up your own custom way of 
displaying the error.

} else {
if ( mysql_num_rows($results) > 0 ) {
while ( $row = mysql_fetch_assoc($result) ) {
			if ( isset($row['client']) && 
!empty($row['client']) ) {

echo $row['client'] . '';
}
}
} else {
echo 'No results found!';
}
}
?>

Does this satisfy you?


Actually, it's $result and not $results. Other than that, it works 
fine as far as I can tell.


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] UPDATE and redirect

2007-04-11 Thread Lori Lay

Marcelo Wolfgang wrote:


and what if $_GET['id'] is something like
"1; DROP TABLE tb_emails;"
??

SQL injection just waits to happen


Something I just thought, he could do a drop table inside an update 
statement ? because the query is :


UPDATE tb_emails SET bol_active = $action WHERE auto_id = $id

so if he changed the $action or the $id, it will be inside the UPDATE, 
doesn't changing any of the variables to a DROP TABLE just give an 
error ?


TIA
Marcelo


No.  That's why he put the semi-colon after the 1.

It becomes

update tb_emails set bol_active = $action where auto_id = 1; drop table 
tb_emails;


That's two separate statements that will be happily executed if you're 
not careful.


Try it (on a scratch table).

Lori

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



Re: [PHP] UPDATE and redirect

2007-04-11 Thread Marcelo Wolfgang


and what if $_GET['id'] is something like
"1; DROP TABLE tb_emails;"
??

SQL injection just waits to happen


Something I just thought, he could do a drop table inside an update 
statement ? because the query is :


UPDATE tb_emails SET bol_active = $action WHERE auto_id = $id

so if he changed the $action or the $id, it will be inside the UPDATE, 
doesn't changing any of the variables to a DROP TABLE just give an error ?


TIA
Marcelo

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



[PHP] Re: SQL Source Control

2007-04-11 Thread Colin Guthrie
Zoltán Németh wrote:
> yeah I have the same problem ;)
> 
> I have two kind of SQL files:
> 1) SQL of the complete, blank DB structure - I store it for each main
> version (I should store it for each version if I wouldn't be so
> lazy... ;) )
> 2) SQL instructions to upgrade from a DB version to another - I need
> these to upgrade working databases
> 
> however I have no real solution for rollback, and if something is broken
> in a new version and I have to revert a working DB to an older state,
> well that's real serious trouble (and usually a lot of cursing and stuff
> like that)
> 
> so, if anyone has a good solution I also would like to hear it :)

No technical solution, but just put a "Swear Box" in the office and that
way when a borkage happens you'll all have to put a £/$/€ in the tub
with each curse you utter... It wont help but at least come Friday night
you can all enjoy a few extra beers in the pub ;)

Col

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



Re: [PHP] UPDATE and redirect

2007-04-11 Thread Zoltán Németh
2007. 04. 11, szerda keltezéssel 17.36-kor Marcelo Wolfgang ezt írta:
> > and what if $_GET['id'] is something like
> > "1; DROP TABLE tb_emails;"
> > ??
> > 
> > SQL injection just waits to happen
> 
> I think tha tit will be too much of a hacker effort just to kill a table 
>   of contact emails, and also he will have to guess ( is there other way 
> ? ) the table name, but just to be on a safer side:
> 
> - Is there a way to say that id can only be a number ?
> 
> something like $id:Number = $_GET['id']?

that was just an example, any kind of hacker SQL code can be put
there...

if $id should be a number typecast it to int like this:

$id = (int) $_GET['id'];

greets
Zoltán Németh

> 
> TIA
> 

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



Re: [PHP] UPDATE and redirect

2007-04-11 Thread Lori Lay

Marcelo Wolfgang wrote:

and what if $_GET['id'] is something like
"1; DROP TABLE tb_emails;"
??

SQL injection just waits to happen


I think tha tit will be too much of a hacker effort just to kill a 
table  of contact emails, and also he will have to guess ( is there 
other way ? ) the table name, but just to be on a safer side:


- Is there a way to say that id can only be a number ?

something like $id:Number = $_GET['id']?

TIA


If your id should only have digits in it, use

if (! ctype_digit($_GET['id'])) {
   print "invalid parameter error message or exit or whatever";
}

This doesn't work with negative integers - it really checks to make sure 
that there are only digits, but it is very handy for validating GET or 
POST variables.


There are other ctype functions as well...

Lori

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



Re: [PHP] Re: Design Dilemma - Database Data Abstraction

2007-04-11 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-04-11 16:34:27 -0300:
> 2007/4/11, Roman Neuhauser <[EMAIL PROTECTED]>:
> >
> ># [EMAIL PROTECTED] / 2007-04-09 19:45:41 -0300:
> >> Thanks but that's not what I'm looking for. As I said before, my problem
> >> isn't to find an implementation of an ORM, but that the concept I'm
> >working
> >> on will use a very restricted API (array operations), and I'm having
> >trouble
> >> to keep it coherent.
> >
> >Yeah, it's a bad idea, and doesn't work.
> 
> 
> If it is my idea that you think is bad and wouldn't work, I kindly ask if
> you could explain your thoughs throughly.

You have explained my thoughts quite thoroughly in the thread opener.

: I could index by the order as they are presented by the DB:
: 
: $DB['users'][0] is the first user from the query "SELECT * FROM users"
: $DB['users'][1] is the second user from the query "SELECT * FROM users"
: etc..

That's a stillborn as soon as you care about what data the 0, 1, etc
represents, for example when updating.

Or, how is it supposed to support WHERE other than on the primary key?
What if select * from atable produces more data than there's memory for?

Operator overloading is syntactic sugar, coating over method calls,
except there are additional restrictions for array keys over function
parameters (in PHP).  You still don't have the basics straight
(identifying the rows), so why bother with operator overloading.

> Besides, what's with those funky ['s and ]'s? What are they for?
> >I didn't bother to RTFM.
> 
> The operator [] is known as the array access operator, is used to refer to
> an item in an array through its index, which is contained inside the square
> brackets. It is possible to overload this operator, and the basic related
> actions (isset, unset, foreach), in PHP5.

I know, I was suggesting that no matter how idiot-proof you build it,
a loving couple somewhere will have produced a bigger idiot.

What's easy for an idiot to use is often a weak tool if you need to get
a bit more serious, cf the problems with composite keys you described.
Sure, Lego duplo is so idiot proof that a year old can bang two pieces
each against the other cheerfully.  You won't build a helicopter with
it, however.

You have trouble identifying behavior that would go naturally with the
ArrayAccess interface.  That suggests that such natural behavior might
not exist, and a method-based interface would do your users better
service.  After all, fetchByPrimaryKey($id) says much more than [$key].

Etc etc..

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



[PHP] Re: PHP Directory List Script Files over 2 GB

2007-04-11 Thread Robert M

Does anyone else have any other ideas how to resolve this, I have tried
multiple different methods all failed.

Does the 2 GB limitation using filesize have an alternate method of
producing the output. ?

Thank you Logan for trying.

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



Re: [PHP] UPDATE and redirect

2007-04-11 Thread Marcelo Wolfgang

and what if $_GET['id'] is something like
"1; DROP TABLE tb_emails;"
??

SQL injection just waits to happen


I think tha tit will be too much of a hacker effort just to kill a table 
 of contact emails, and also he will have to guess ( is there other way 
? ) the table name, but just to be on a safer side:


- Is there a way to say that id can only be a number ?

something like $id:Number = $_GET['id']?

TIA

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



Re: [PHP] Re: SQL Source Control

2007-04-11 Thread Zoltán Németh
2007. 04. 11, szerda keltezéssel 16.19-kor Colin Guthrie ezt írta:
> Richard Davey wrote:
> > Hi all,
> > 
> > I know a lot of you use various means for PHP source control (CVS, SVN,
> > etc), which is all well and fine, but how do you manage source control
> > on your databases?
> > 
> > Say you've got an upgrade to a site, all of the new PHP files are
> > controlled by SVN, so you can rollback at any time, but say the upgrade
> > includes several key modifications to a MySQL table and perhaps the
> > changing of some core data.
> > 
> > How (if at all?!) do you handle the versioning of the database and data
> > itself, so you can keep both PHP and SQL structure in sync?
> 
> Yeah this is a weak point in my chain too!
> 
> I keep database schema's in a file which can start with a blank db and
> create all the tables allowing for modifications and updates etc. over
> time with new deployments.
> 
> But if something breaks... rolling back is well. a pain
> 
> I could use a backup file and MySQL binary logs to replay to the point
> prior to deployment/update if the world depended on it, but this would
> take several hours to do and so I really wouldn't say I "relied" on this
> method.. it's more disaster recovery!
> 
> Any suggestions in this area would be interesting.

yeah I have the same problem ;)

I have two kind of SQL files:
1) SQL of the complete, blank DB structure - I store it for each main
version (I should store it for each version if I wouldn't be so
lazy... ;) )
2) SQL instructions to upgrade from a DB version to another - I need
these to upgrade working databases

however I have no real solution for rollback, and if something is broken
in a new version and I have to revert a working DB to an older state,
well that's real serious trouble (and usually a lot of cursing and stuff
like that)

so, if anyone has a good solution I also would like to hear it :)

greets
Zoltán Németh

> 
> Col
> 

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



Re: [PHP] UPDATE and redirect

2007-04-11 Thread Zoltán Németh
2007. 04. 11, szerda keltezéssel 16.57-kor Fredrik Thunberg ezt írta:
> marcelo Wolfgang skrev:
> > Hi all,
> > 
> > I'm new to this list and new to php programming so sorry if I do 
> > something wrong here :)
> > 
> > Ok, now to my problem.
> > 
> > I've created a query to update a mysql db, and it isn't working, and 
> > it's not throwing me any errors, so I need some help to figure out 
> > what's wrong here. My code follows :
> > 
> >  > if($_GET['act'] = 'a'){
> > $action = 1;
> > } else if ($_GET['act'] = 'd'){
> > $action = 0;
> > }
> 
> 
> Don't use "=", use "==" (or in some cases "===").
> "=" is for assignment.
> 
> Also, what if $_GET['act'] is neither 'a' or 'd'?
> 
> 
> > $id = $_GET['id'];
> > 
> 
> Again, what if $_GET['id'] is null?

and what if $_GET['id'] is something like
"1; DROP TABLE tb_emails;"
??

SQL injection just waits to happen

greets
Zoltán Németh

> 
> > mysql_connect("localhost","","") or die (mysql_error());
> > mysql_select_db ("taiomara_emailList");
> 
> > $email_Query = mysql_query("UPDATE 'tb_emails' SET 'bol_active' = 
> > $action WHERE `auto_id` = $id");
> 
> Use backticks if you think you need them
> In this case you don't
> 
> $sql = "UPDATE `tb_emails` SET `bol_active` = $action WHERE `auto_id` = 
> $id";
> 
> echo "DEBUG: $sql";
> 
> $email_Query = mysql_query( $sql );
> 
> This is how to get the error:
> 
> if ( !$email_Query )
>   echo mysql_error();
> 
> 
> > mysql_close();
> > ?>
> > 
> > The page is executed, but it don't update the table ... I've tried with 
> > the '' and without it ( the phpmyadmin page is where I got the idea of 
> > using the '' ). Any clues ?
> > 
> > Also, how can I make a redirect after the query has run ?
> > 
> 
> header("Location: http://www.foobar.com";);
> 
> Will work as long as you don't print out any output whatsoever to the 
> browser before this line of code.
> 
> 
> > TIA
> > Marcelo Wolfgang
> > 
> 
> /T
> 

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



Re: [PHP] PHP editor

2007-04-11 Thread Zoltán Németh
I use jEdit
http://www.jedit.org/

and I like it ;)
it's not specifically for php but for any kind of programming, and has
nice plugins for several programming languages you might edit with it

greets
Zoltán Németh

2007. 04. 11, szerda keltezéssel 10.12-kor Jonathan Kahan ezt írta:
> Hi all,
> 
> I beleive this is in the realm of php (I have learned my lesson from last 
> time). Does anyone have recomendation for any free (I.E. permanently free 
> not 30 day trial) of a good php editor. The ones i am seeing all only allow 
> usage for a limited time.
> 
> Kind Regards
> Jonathan Kahan
> 
> Systems Developer
> Estrin Technologies, inc.
> 1375 Broadway, 3rd Floor, New York, NY, 10018
> 
> Email: [EMAIL PROTECTED]
> Web: http://www.estrintech.com 
> 

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



[PHP] location of the PHP executable

2007-04-11 Thread Mattias Thorslund
Hi,

I have looked in the documentation but can't find it:

My PHP script (which is run from the command prompt - CLI) needs to know
the file system location of the PHP executable. This is because it needs
to run a second PHP script. I know about the "which" command but it's
not available in all OSes, and that might not be the currently running
executable anyway.

I could prompt the user for this, but that seems kind of silly. Surely,
there must be some way of looking it up automatically?

Thanks,

Mattias

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



Re: [PHP] Re: Design Dilemma - Database Data Abstraction

2007-04-11 Thread Martin Alterisio

2007/4/11, Roman Neuhauser <[EMAIL PROTECTED]>:


# [EMAIL PROTECTED] / 2007-04-09 19:45:41 -0300:
> Thanks but that's not what I'm looking for. As I said before, my problem
> isn't to find an implementation of an ORM, but that the concept I'm
working
> on will use a very restricted API (array operations), and I'm having
trouble
> to keep it coherent.

Yeah, it's a bad idea, and doesn't work.



If it is my idea that you think is bad and wouldn't work, I kindly ask if
you could explain your thoughs throughly. If it is not, I would also like to
know more about it, but if you fell it won't affect the thread of the
discussion.

Thanks.

Besides, what's with those funky ['s and ]'s? What are they for?

I didn't bother to RTFM.



The operator [] is known as the array access operator, is used to refer to
an item in an array through its index, which is contained inside the square
brackets. It is possible to overload this operator, and the basic related
actions (isset, unset, foreach), in PHP5.


[PHP] Re: PHP editor

2007-04-11 Thread Sady Marcos
Using with CVS, PHP Eclipse no doubt 
http://download.eclipse.org/tools/pdt/downloads/?release=S20070401-RC3
Unzip and execute eclipse.exe.. It's free...
No CVS.. can use Zend Studio.. but isn't free...
My choose is Eclipse..


""Jonathan Kahan"" <[EMAIL PROTECTED]> escreveu na mensagem 
news:[EMAIL PROTECTED]
> Hi all,
>
> I beleive this is in the realm of php (I have learned my lesson from last 
> time). Does anyone have recomendation for any free (I.E. permanently free 
> not 30 day trial) of a good php editor. The ones i am seeing all only 
> allow usage for a limited time.
>
> Kind Regards
> Jonathan Kahan
> 
> Systems Developer
> Estrin Technologies, inc.
> 1375 Broadway, 3rd Floor, New York, NY, 10018
> 
> Email: [EMAIL PROTECTED]
> Web: http://www.estrintech.com 

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



Re: [PHP] PHP textbook suggestions?

2007-04-11 Thread Chris Lott

On 4/10/07, Richard Lynch <[EMAIL PROTECTED]> wrote:

> print 'The cost is ' . $cost;
> NOT
> print "The cost is $cost";
> AND CERTAINLY NOT
> print ("The cost is $cost");

echo "The cost is ", $cost;

If you're going to be this picky, you'd better write your own textbook...

:-)

Perhaps instead of a textbook, just use http://php.net/manual


The manual is not nearly enough reference for a beginning students.
You illustrate the problem with quotes in your example above-- why
double quotes with no variable being interpolated?

The . is the documented string operator for concatenation... that's
one of the reasons I dislike the unneeded parentheses with the print
function-- then I have to explain-- before I want to-- arguments to
functions, which is necessary to explain the comma.

c

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



Re: [PHP] Re: PHP textbook suggestions?

2007-04-11 Thread Chris Lott

You're missing the point-- it's not that there is a practical
difference in the examples, it's that there IS a difference, the
students see it, and it is an extra point of confusion that isn't
needed if one is being consistent.

I completely recognize that the practical effects of the differences
are small, but the learning effects of the inconsistencies is much
larger, particularly with a group of students that are not techies,
not geeks, not computer science or IT students...

c

On 4/10/07, LuKreme <[EMAIL PROTECTED]> wrote:

On 6-Apr-2007, at 08:13, Chris Lott wrote:
> echo substr("abcdef", 1);
>
> So they naturally want to know-- why the double quotes? And there's no
> good logical reason for double quotes in the example-- and there are
> languages where the function could take a variable to be interpolated
> that DOES need double quotes-- so it is very confusing to them.

But it's quite simple: it's a matter of preference, style, or just
the mood of the programmer.  Basically, there is NO difference between

echo substr("abcdef", 1);
echo substr('abcdef', 1);

Oh sure, there is some number of nanoseconds difference in evaluation
time, but that's meaningless as it is an insignificant amount of time
(and takes millions and millions of iterations to make any
perceivable difference).

Use whichever you want.  For me, I use " mostly, and usually only use
' when I am enclosing "'s to save myself having to escape them.

On 5-Apr-2007, at 14:52, Chris Lott wrote:
> print 'The cost is ' . $cost;
> NOT
> print "The cost is $cost";

But that is certainly a silly destination to make.  Both are
perfectly valid and, in fact, I would argue the latter is better as
it is clearer, cleaner, and shorter.

> echo substr('abcdef', 1);
> NOT
> echo substr("abcdef", 1);

Both are perfectly fine.  I'd use the latter myself as I tend to
reserve the single quotes for enclosing strings containing double
quotes, but that's just my preference.  I certainly wouldn't deign to
argue that my way was 'correct'.

--
A: You can never go too far. B: If I'm gonna get busted, it is *not*
gonna be by a guy like *that*.

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





--
Chris Lott

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



Re: [PHP] SQL Source Control

2007-04-11 Thread Lori Lay

Richard Davey wrote:

Hi all,

I know a lot of you use various means for PHP source control (CVS, 
SVN, etc), which is all well and fine, but how do you manage source 
control on your databases?


Say you've got an upgrade to a site, all of the new PHP files are 
controlled by SVN, so you can rollback at any time, but say the 
upgrade includes several key modifications to a MySQL table and 
perhaps the changing of some core data.


How (if at all?!) do you handle the versioning of the database and 
data itself, so you can keep both PHP and SQL structure in sync?


Cheers,

Rich

Rich,

This is a well-known problem that comes from the fact that the database 
is an infrastructure component rather than a source component.  You 
would have the same issue if you were to upgrade the operating system 
software, for example.


What most people do is use their tool of choice to create the DDL/DML 
update scripts and put those under source control.  To version the data 
you need to make database backups at well-understood times and grab the 
data files if appropriate.  Rolling back a change is a matter of 
recovering the database and files to a point in time along with the 
sources.


I don't know of any management tools for this part of it.  Most larger 
organizations have different people responsible for the database and web 
tiers, so a single tool won't do.  Some folks are trying to use 
ClearCase automation to manage a lot of it, but it's still a work in 
progress...


In a smaller environment I would be inclined to create shell/whatever 
scripts to do the actual implementation.  If you parameterize the 
connection/server details you can test the implementation in a QA 
environment before going live - less need for rollbacks that way.  The 
shell scripts greatly reduce the chance of finger trouble which is key 
if your implementation is being done at some uncivilized hour or by 
rookies.  If you want to truly embrace the New World, you can do all of 
this using Ant, which has built-in tasks for CVS/SVN as well as file 
movement, etc.  It can also run shell scripts for the database stuff.


...Lori


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



Re: [PHP] Posting a variable

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 10:53 -0700, [EMAIL PROTECTED] wrote:
> Quoting Robert Cummings <[EMAIL PROTECTED]>:
> 
> > On Wed, 2007-04-11 at 09:59 -0700, [EMAIL PROTECTED] wrote:
> > > 1- your mysql query statement is better to have a WHERE part too.
> > > 2- I would use mysql_fetch_row instead of mysql_fetch_assoc
> > 
> > Ummm, why would you want to reduce clarity and maintainability by using
> > mysql_fetch_row()?
> 
> hmmm, I just remember in my php class a while back, my teacher didn't even
> bother teaching us about mysql_fetch_assoc, and when a student asked about it,
> he said don't bother using it, just use mysql_fetch_row so I ended up using 
> this
> function ever since. I'm guessing he was wrong??

It's a terrible idea-- to grok the code you need to keep referring back
to the query itself so that you can remember what index maps to what
field. I guess that's not so much a problem if you export the row values
to variables, but then again, why do in userspace what the
mysql_fetch_assoc() function readily does for you in engine space? :)

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] Posting a variable

2007-04-11 Thread Richard Davey

[EMAIL PROTECTED] wrote:


Quoting Robert Cummings <[EMAIL PROTECTED]>:


On Wed, 2007-04-11 at 09:59 -0700, [EMAIL PROTECTED] wrote:

1- your mysql query statement is better to have a WHERE part too.
2- I would use mysql_fetch_row instead of mysql_fetch_assoc

Ummm, why would you want to reduce clarity and maintainability by using
mysql_fetch_row()?


hmmm, I just remember in my php class a while back, my teacher didn't even
bother teaching us about mysql_fetch_assoc, and when a student asked about it,
he said don't bother using it, just use mysql_fetch_row so I ended up using this
function ever since. I'm guessing he was wrong??


Not 'wrong', but half the PHP developers out there would disagree with 
him apparently:


http://www.php-mag.net/magphpde/magphpde_news/psecom,id,27094,nodeid,5.html

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] output gz compression

2007-04-11 Thread Eric Butera

I am just curious if anybody else has this issue.  My platform is OSX
10.4.9 using a custom compiled PHP 4.4.x (4.4.6 & 4.4.7RC1)

I've tried using the php.ini setting zlib.output_compression = On and
also ob_start("ob_gzhandler"); directly.  Each time I call up the page
it crashes.

On the server side I see this in the error log:
[Wed Apr 11 13:57:49 2007] [notice] child pid 10608 exit signal Bus error (10)

I even grabbed zlib and compiled that too to try and remedy this.
phpinfo says I have 1.2.3:
ZLib Supportenabled
Compiled Version1.2.3
Linked Version  1.2.3

The best part is that I also have a 5.2.x install and I can use gz
output just fine on that build.  Any ideas?

Thanks!

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



Re: [PHP] Posting a variable

2007-04-11 Thread Jochem Maas
Robert Cummings wrote:
> On Wed, 2007-04-11 at 09:59 -0700, [EMAIL PROTECTED] wrote:
>> 1- your mysql query statement is better to have a WHERE part too.
>> 2- I would use mysql_fetch_row instead of mysql_fetch_assoc
> 
> Ummm, why would you want to reduce clarity and maintainability by using
> mysql_fetch_row()?

job protection ;-)

> 
> Cheers,
> Rob.

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



Re: [PHP] Posting a variable

2007-04-11 Thread siavash1979
Quoting Robert Cummings <[EMAIL PROTECTED]>:

> On Wed, 2007-04-11 at 09:59 -0700, [EMAIL PROTECTED] wrote:
> > 1- your mysql query statement is better to have a WHERE part too.
> > 2- I would use mysql_fetch_row instead of mysql_fetch_assoc
> 
> Ummm, why would you want to reduce clarity and maintainability by using
> mysql_fetch_row()?

hmmm, I just remember in my php class a while back, my teacher didn't even
bother teaching us about mysql_fetch_assoc, and when a student asked about it,
he said don't bother using it, just use mysql_fetch_row so I ended up using this
function ever since. I'm guessing he was wrong??


Thanks,
Siavash


> 
> 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Design Dilemma - Database Data Abstraction

2007-04-11 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-04-09 19:45:41 -0300:
> Thanks but that's not what I'm looking for. As I said before, my problem
> isn't to find an implementation of an ORM, but that the concept I'm working
> on will use a very restricted API (array operations), and I'm having trouble
> to keep it coherent.

Yeah, it's a bad idea, and doesn't work.

Besides, what's with those funky ['s and ]'s? What are they for?
I didn't bother to RTFM.

-- 
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] Posting a variable

2007-04-11 Thread Robert Cummings
On Wed, 2007-04-11 at 09:59 -0700, [EMAIL PROTECTED] wrote:
> 1- your mysql query statement is better to have a WHERE part too.
> 2- I would use mysql_fetch_row instead of mysql_fetch_assoc

Ummm, why would you want to reduce clarity and maintainability by using
mysql_fetch_row()?

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] Posting a variable

2007-04-11 Thread siavash1979
1- your mysql query statement is better to have a WHERE part too.
2- I would use mysql_fetch_row instead of mysql_fetch_assoc
3- in your form, you're using a single quote. anything in between single 
quotes will be printed as is. you need to close your single quote and print 
username and open another single quote. Like this:

'...' . $username02 . '.'

Or I personally would close my php, print the form in html and use  where you need the username. And then I would start another :

> Hi,
>
>   I am trying to pass a variable into a textfield and then pass the variable
> onto a php page for insertion into a Mysql database.
>
>   However, I want to send the username of the person logging on. But instead
> php is taking the username of the logon information of the database. Which I
> obviously don't want for many obvious reasons.
>
>   Oddly enough it echo's $username02 so it shouldn't be a pass down issue.
> But when the insert.php I also ask it to echo and it doesn't. 
>
>   Any suggestions?
>
>  require("config.php");
>   $sql = "SELECT `username`, `password` FROM `user_system`";
> $result = mysql_query($sql);
>   $check = mysql_fetch_assoc($result);
>   $username_to_check = mysql_real_escape_string($_POST['username']);
> $password_to_check = md5($_POST['password']);
> 
>   $username02 = mysql_real_escape_string($_POST['username']);
>   
> if ($check['username'] != $username_to_check || $check['password'] !=
> $password_to_check) {
> echo "The username or password was wrong!";
> }
> else {
>   
>   echo 'The username and password was correct!
>   
>   
>   cellspacing="0">
>   
>   
>   
>   
>   
>
>Question 1
> 
>  
>  
>   
> Yes I strongly agree
> Yes I agree 
> I disagree
> I strongly disagree
>   
> 
> 
>   
>  
>    
>
>   
> 
>   
> 
>   
> 
> 
> ';
> echo "$username";  
> echo "$username02";
>   
>}
> ?>
> 
>
> -
> The best gets better. See why everyone is raving about the All-new Yahoo!
> Mail.  

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



Re: [PHP] Design Dilemma - Database Data Abstraction

2007-04-11 Thread Martin Alterisio

2007/4/10, Richard Lynch <[EMAIL PROTECTED]>:


On Sat, April 7, 2007 11:49 am, Martin Alterisio wrote:
> The solution I presented is to access, and act upon, a database as if
> they
> were PHP arrays, meaning that a table is presented as an array of
> records.

I don't quite get why you think this is any more fool-proof than using
a database in the first place, but okay, I guess...



It's not intended to be fool-proof, and I never said so. I said
"those-who-never-RTFM-proof", maybe some of those are fools, but many of
those have not received the proper preparation in computer sciences, and
maybe it's not their fault they can't read a manual meant for us coders to
read.

Anyway, if there is already an API that allows us to create objects that
look and act like PHP arrays, why don't just use that API for something like
an ORM?


My dilemma is as follows: a PHP array is a construct more restricted
> than a
> DB table. In a PHP array the index is either an int or a string, in a
> table
> de index can be any combination of fields. Then, my problem is how to
> design
> coherently the indexing of the arrays that represent the DB tables.



> I could index by the order as they are presented by the DB:

You have not specified any ORDER BY for the DB so far.



Why should I impose an order if the implementation may want to decide this
order.

By definition, then, the order is UNDEFINED and the DB is free to

return the result set in ANY order it finds convenient.



And that's okay, and I shall use the order the DB finds convenient.


$DB['users'][0] is the first user from the query "SELECT * FROM users"
> $DB['users'][1] is the second user from the query "SELECT * FROM
> users"
> etc..
>
> But this have many cons. First, without a deterministic order, the
> array can
> change its logic order on the whim of the DB, nobody assures that the
> order
> will be kept after a modification is made to the data, and this can be
> confusing and error prone:

Until you define an ORDER BY in the DB, there is no order, period.



If the DB presents the result sequentially there is an order, even if it
follows an undefined criteria.

If you *DO* define an ORDER BY in the DB, you'll have to be able to

write a PHP function which can duplicate that ORDER BY and
http://php.net/usort the array, or dis-allow changes to the array that
introduce new keys, and disallow using integer keys.



Why? I just let the DB manage the order. To use usort I'll have to actually
put the results in a real array, wasting memory, cpu time, and db access.


$name1 = $DB['users'][3]['name'];
> $name2 = $DB['users'][5]['name'];
> $DB['users'][3]['name'] = $name2;
> $DB['users'][5]['name'] = $name1;
>
> The last sentence may not be writing to the adequate record.

What's wrong here?



For example, if the current order for the 'users' table is by the 'name'
field, after the first write this order may have changed, then the record
we'll be trying to write next won't be the one we intended to.

If 5 isn't 5, then you are screwed from the get-go...


That's why I don't like this indexing criteria.


Another possible indexation could be by the value of the PK, but this
> also
> have some problems. First, it can be confusing if the PK is an
> autonumeric
> int, as this might be seen as a numeric indexation. Second, not all
> tables
> have only one field as PK (I can ask that all tables have at least a
> PK, but
> I can't ask that the PK is made of only one field).

Exposing an auto_increment field to anything above the DB layer is
almost always a Bad Idea (tm).



Why? Or, what do you mean by exposing the auto_increment field?

Show me one site that doesn't expose the value of this field (when needed)
in the url.


$user = $DB['users'][$userid]; // get
> $DB['users'][$userid] = $user; // update or insert
> $DB['users'][] = $userid; // insert
> unset($DB['users'][$userid]); // delete

I think you will find that detecting the array changes and pushing
them back down to the DB will be much more difficult than just
providing an API to a database in some kind of normalized functions...



That's the easy part, I'll just use the SPL interfaces. Sorry, I forgot to
mention this in my first email as I explained in the following emails.


There is also the problem with many-to-many relationships. If there
> was only
> one table that related two tables in this way, I could do the
> following:

Well, yeah...

You are going to have to have at least 2 if not 3 arrays to do that
with any efficiency at all...



Hey. Would you think I'll even propose this here if I didn't think I could
guarantee at least the same efficiency as other ORMs?


$DB['users'][$userid]['groups'] <- groups where the user belongs
> $DB['groups'][$groupid]['users'] <- the users of a group
>
> There would be a third table other than users and groups which doesn't
> show
> up. But, what to do when there is more than one relationship table for
> the
> same two tables? And if the relationship table also ha

  1   2   >