php-general Digest 5 Jun 2006 16:21:11 -0000 Issue 4168
Topics (messages 237393 through 237410):
Re: Delete
237393 by: Rabin Vincent
237394 by: Larry Garfield
Using variable content to name a class
237395 by: Dave M G
237396 by: Chris
237397 by: Dave M G
Re: How do I make a HTML tree for a set of nodes?
237398 by: David Robley
237401 by: Niels
Unicode
237399 by: tedd
pager fix - cash offered
237400 by: Ross
237405 by: João Cândido de Souza Neto
Re: Retrieving Content
237402 by: Adam Zey
Re: SPL Iterator and Associative Array
237403 by: Adam Zey
PHP/MySQL question
237404 by: Wolf
237406 by: Jay Blanchard
237407 by: Richard Lynch
Re: Explicit Stream Flush with fsockopen()
237408 by: Richard Lynch
i have a problem inserting blob data larger than 1 mb
237409 by: sunaram patir
Re: When is "z" != "z" ?
237410 by: tg-php.gryffyndevelopment.com
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On 6/4/06, Larry Garfield <[EMAIL PROTECTED]> wrote:
Only if delete.php is a confirmation page. Never ever ever have a delete
function that operates solely by GET.
Here's why: http://thedailywtf.com/forums/thread/66166.aspx
Yes, I've seen that one before. IMO the main problem there
is the faulty authentication system. If you put delete links
public, and fail to put proper authentication in place, someone's
going to delete your content, no matter if the delete action
is a POST submit button or a GET link.
I don't see how POST is better/more secure for a delete action.
Rabin
--- End Message ---
--- Begin Message ---
On Monday 05 June 2006 00:41, Rabin Vincent wrote:
> On 6/4/06, Larry Garfield <[EMAIL PROTECTED]> wrote:
> > Only if delete.php is a confirmation page. Never ever ever have a
> > delete function that operates solely by GET.
> >
> > Here's why: http://thedailywtf.com/forums/thread/66166.aspx
>
> Yes, I've seen that one before. IMO the main problem there
> is the faulty authentication system. If you put delete links
> public, and fail to put proper authentication in place, someone's
> going to delete your content, no matter if the delete action
> is a POST submit button or a GET link.
>
> I don't see how POST is better/more secure for a delete action.
>
> Rabin
Data-modification actions should always be made via POST, not GET, because
they're harder to make by accident that way. They can't be bookmarked or
easily picked up by spiders and search engines. GET should be used only for
read-only actions. That's what it's for (GETting data).
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
--- End Message ---
--- Begin Message ---
PHP list,
I suspect this is a rather basic concept, but I could not find the
specifics in the online manual.
I have a set of classes, and the name of each class is stored in a
column in a table in my MySQL database. When I want to create an object
from one of my classes, I also query the database to get a bunch of data
the object needs, along with its name.
So what I end up with is a variable with the name of the class that I
want to use stored as a string.
This means that I want to create an object by naming which class with
the contents of a variable:
$className = "nameFromDatabase";
$object = new $className();
Is this possible?
I hope I've asked my question clearly. Thank you for any advice.
--
Dave M G
--- End Message ---
--- Begin Message ---
Dave M G wrote:
PHP list,
I suspect this is a rather basic concept, but I could not find the
specifics in the online manual.
I have a set of classes, and the name of each class is stored in a
column in a table in my MySQL database. When I want to create an object
from one of my classes, I also query the database to get a bunch of data
the object needs, along with its name.
So what I end up with is a variable with the name of the class that I
want to use stored as a string.
This means that I want to create an object by naming which class with
the contents of a variable:
$className = "nameFromDatabase";
$object = new $className();
Is this possible?
If in doubt, test it out ;)
Yes, it will work.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Chris,
Thank you for replying.
$object = new $className();
Is this possible?
If in doubt, test it out ;)
Yes, it will work.
Oh, that's actually the code I can use? I just wrote it as an
explanatory aid, not thinking that it could be literally done like that.
I assumed there was a specific command I was missing.
Well, anyway, I guess I've stumbled on the right syntax. Thank you for
pointing it out to me.
--
Dave M G
--- End Message ---
--- Begin Message ---
Niels wrote:
> Hi,
>
>
> I have a set of nodes. Each node has a parent and so the set can be
> thought of as a tree. I want to show that tree somehow on a webpage,
> served by PHP. I cannot use Dot/Graphwiz for various reasons. What I'm
> looking for is an output of DIVs or tablecells, showing the nodes and
> their connections. It's not a trivial task, IMO, but doable. Possibly
> somebody has already made something similiar, but I can't find anything on
> Google. Can anybody point me to helpful information?
>
> Thanks,
> Niels
For the concept of storage, you might want to look at
http://www.sitepoint.com/article/hierarchical-data-database
For a very simple implementation of the idea for display and editing,
http://www.auseinet.com/test/treeedit.php
I can provide the code for the above if you want it.
Cheers
--
David Robley
Death is a nonmaskable interrupt.
Today is Sweetmorn, the 10th day of Confusion in the YOLD 3172.
--- End Message ---
--- Begin Message ---
On Monday 05 June 2006 13:32, David Robley wrote:
> Niels wrote:
>
>> Hi,
>>
>>
>> I have a set of nodes. Each node has a parent and so the set can be
>> thought of as a tree. I want to show that tree somehow on a webpage,
>> served by PHP. I cannot use Dot/Graphwiz for various reasons. What I'm
>> looking for is an output of DIVs or tablecells, showing the nodes and
>> their connections. It's not a trivial task, IMO, but doable. Possibly
>> somebody has already made something similiar, but I can't find anything
>> on Google. Can anybody point me to helpful information?
>>
>> Thanks,
>> Niels
>
> For the concept of storage, you might want to look at
>
> http://www.sitepoint.com/article/hierarchical-data-database
>
This I had already found. But it's a very basic article, and it's not about
how to transform a set of data into a nice looking piece of HTML. It does
show some cool trees, but the display_tree function shown just uses
indents, like my own.
> For a very simple implementation of the idea for display and editing,
>
> http://www.auseinet.com/test/treeedit.php
>
> I can provide the code for the above if you want it.
>
Thanks, but this is more or less what I have. If you can add branches to
that, I'd like to hear more.
Thank you for your answer, I appreciate it!
Niels
--- End Message ---
--- Begin Message ---
At 7:08 PM -0700 6/4/06, Rasmus Lerdorf wrote:
>Larry Garfield wrote:
>>In C or C++, yes. In PHP, do not assume the same string->number mapping.
>>Numeric definition is irrelevant.
>
>Right, and now bring Unicode into the picture and this becomes even more true.
>
-Rasmus
I know there's always RTFM, but if you would care to discuss it, I would like
to know why. How does php handle Unicode code-points and char-sets?
Thanks.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
I need this pager fixed
http://scottishsocialnetworks.org/editorx.php
http://scottishsocialnetworks.org/editorx.php
http://scottishsocialnetworks.org/class.pager.phps
The problem is it resets when the numbered pages are pressed at the bottom.
I think the query string gets reset when the page is self submitted
I need it to page the results correctly. I can pay by paypal as soon as
someone provides (i) an agreed cost (ii) a working solution (iii) a brief
explanation.
I do not think this is a big job but I do not have enough time to fix it and
need it done asap.
thanks,
Ross
--- End Message ---
--- Begin Message ---
I could fix it for you, but, i just can look at it in the evening when i´ll
be at home.
If it could be, wait for my contac e-mail this evening.
Thanks.
""Ross"" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
>
> I need this pager fixed
>
> http://scottishsocialnetworks.org/editorx.php
>
> http://scottishsocialnetworks.org/editorx.php
>
> http://scottishsocialnetworks.org/class.pager.phps
>
>
> The problem is it resets when the numbered pages are pressed at the
> bottom. I think the query string gets reset when the page is self
> submitted
>
> I need it to page the results correctly. I can pay by paypal as soon as
> someone provides (i) an agreed cost (ii) a working solution (iii) a brief
> explanation.
>
> I do not think this is a big job but I do not have enough time to fix it
> and need it done asap.
>
> thanks,
>
> Ross
>
>
--- End Message ---
--- Begin Message ---
chris smith wrote:
On 6/3/06, Adam Zey <[EMAIL PROTECTED]> wrote:
Rodrigo de Oliveira Costa wrote:
> I just discovered the problem I have to retrieve the output of the
> site and not the url since its dynamic. Ca I do it like retrieve the
> output of this url:
>
> www.tryout.com/1/2/
>
> And of course store it on a variable? How to do it? I founr the func
> below but couldnt understand how to make it work with a url.
>
> Thanks guys,
> Rodrigo
>
>
> ob_start();
> include('file.php'); // Could be a site here? What should I do to
> retrieve it from an url?
> $output = ob_get_contents();
> ob_end_clean();
Umm..... As I said, just use file_get_contents():
$file = file_get_contents("http://www.tryout.com/1/2/");
Assuming allow_url_fopen is on.
If not, you could try using curl - see http://www.php.net/curl
allow_url_fopen is on by default, and curl requires custom compile-time
options. Considering that, it is logical that if the user can't enable
allow_url_fopen, they're not going to be allowed to recompile PHP.
Regards, Adam Zey.
--- End Message ---
--- Begin Message ---
Jason Karns wrote:
-----Original Message-----
From: Greg Beaver [mailto:[EMAIL PROTECTED]
Sent: Friday, June 02, 2006 10:39 PM
To: Jason Karns
Cc: php-general@lists.php.net
Subject: Re: SPL Iterator and Associative Array
Jason Karns wrote:
I'm going to try my best to explain what I'm trying to do.
I have my own class that has an array member. This class itself
implements Iterator. One of the fields in the array is itself an
array that I would like to iterate over. Here's some code:
<snip>
<snip>
Hi Jason,
The code you pasted is littered with fatal errors and bugs (I
marked one example with "^^" above). Please paste a real
batch of code that you've tested and reproduces the error and
that will be much more helpful. The PHP version would be
helpful to know as well.
Greg
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.8.1/354 - Release
Date: 6/1/2006
<?php
class Folio implements Iterator {
private $projects = array();
private $valid = FALSE;
public function __construct($file = null) {
if(!is_null($file))
$this->load($file);
}
public function load($file){
...
$keys = array();
$values = array();
foreach ($projects as $project) {
$small = array();
$big = array();
foreach
($xpath->query('showcase/images/screenshot/thumbnail',$project) as $img){
$small[] = $img->nodeValue;}
foreach
($xpath->query('showcase/images/screenshot/src',$project) as $img){
$big[] = $img->nodeValue;}
$keys[] =
$xpath->query('@id',$project)->item(0)->nodeValue;
$values[] = array(
'title'=>$xpath->query('showcase/title',$project)->item(0)->nodeValue,
'href'=>$xpath->query('livesite',$project)->item(0)->nodeValue,
'clip'=>$xpath->query('showcase/images/feature/thumbnail',$project)->item(0)
->nodeValue,
'big'=>$big,
'small'=>$small,
'text'=>$xpath->query('showcase/description',$project)->item(0)->nodeValue);
}
$this->projects = array_combine($keys,$values);
}
function &smalls($x=null){
if(is_null($x) or !key_exists($x,$this->projects)) $x =
$this->key();
return $this->projects[$x]['small'];
}
function small_src($x=null){
if(is_null($x) or !key_exists($x,$this->projects)) $x =
$this->key();
return current($this->projects[$x]['small']);
}
function small($x=null){
if(is_null($x) or !key_exists($x,$this->projects)) $x =
$this->key();
return '<a href="'.$this->small_href().'"
title="'.$this->small_title().'">'.$this->small_img($x).'</a>';
}
}
?>
<?php
reset($folio->smalls());
while($s = current($folio->smalls())){
echo $folio->small();
next($folio->smalls());
}
foreach($folio->smalls() as $s){
echo $folio->small();
}
?>
Production server will be PHP 5.1.2, developing on 5.0.5
I am also considering making my own 'project' object and having Folio have
an array of 'projects' rather than using the array of associative arrays.
Would this provide a solution?
Thanks,
Jason
If you're going to be using 5.1.2 in production, develop on 5.1.2. PHP
doesn't guarantee backwards compatibility, especially in such a big
change as 5.0.x -> 5.1.x. Better to develop on 5.1.2 from the start than
to develop on 5.0.5, put the code on 5.1.2, get a bunch of errors, and
then have to develop again on 5.1.2 to fix the bugs. Not to mention that
any testing done with 5.0.5 is invalid since you can't be sure that
things will behave the same with the different production version. You
may even waste time working around bugs in 5.0.5 that don't exist in 5.1.2.
Regards, Adam Zey.
--- End Message ---
--- Begin Message ---
I have a php form that pulls data from the database (hence the problems)
I need to do an OR search on three columns, and AND the rest, anyone
have a good way to do this? So far my searching on the MySQL lists have
been fruitless more then anything, and I figured we've probably come
across this ourselves at some point.
Here's the code I have so far:
$query = "select * from honorclub";
if ($dead != "" || $unknown != "" || $name != "" || $county != "" ||
$year != "" || $countynow != "" || $state != "")
{$query .= " WHERE ";}
if ($dead == "")
{$query .= " `Deceased`='N' AND";}
if ($unknown == "")
{$query .= " `USPS_Unknown`='N' AND ";}
if ($name != "")
{$query .= " `Last_Name` like '$name%' AND ";}
if ($county != "")
{$query .= " `County` like '$county' AND ";}
if ($year != "")
{$query .= " `Year_Tapped` like '$year' AND ";}
if ($countynow != "")
{$query .= " `County_Now` like '$countynow' AND ";}
if ($state != "")
{$query .= " `State_Now` like '$state' AND ";}
$query = rtrim($query," AND");
$query .= " order by $order_by";
What needs to be 'OR' is the $name section to be:
$query .= "`Last_Name` like '%$name%' OR `First_Name` like '%$name%' OR
`Maiden_Name` like '%$name%'";
Thanks,
Wolf
--- End Message ---
--- Begin Message ---
[snip]
I need to do an OR search on three columns, and AND the rest, anyone
have a good way to do this? So far my searching on the MySQL lists have
been fruitless more then anything, and I figured we've probably come
across this ourselves at some point.
[/snip]
More of a MySQL question, but easily enough answered;
Always group the OR with parenthese and the AND individually. Write the
query and test with MySQL before placing into PHP code;
SELECT * FROM `table`
WHERE (`foo` = 'bar'
OR `foo` = 'glorp'
OR `sqirk` = 'glorp')
AND `today` = CURDATE()
AND `userID` = 'Marvin'
--- End Message ---
--- Begin Message ---
On Mon, June 5, 2006 10:32 am, Wolf wrote:
> I have a php form that pulls data from the database (hence the
> problems)
>
> I need to do an OR search on three columns, and AND the rest, anyone
> have a good way to do this? So far my searching on the MySQL lists
> have
> been fruitless more then anything, and I figured we've probably come
> across this ourselves at some point.
>
> Here's the code I have so far:
I'm confused just by the indenting (or lack thereof) but one standard
technique is to start off with a "yeast" such as:
$query = "select * from honorclub "; //Fix * to be actual columns!
$query .= " WHERE 1 ";
if ($dead != "" ...){
$query .= " AND Deceased = 'N' ";
}
$query .= " AND (First_name like '%$name%' or Last_name like '%$name%'
) ";
> $query = "select * from honorclub";
> if ($dead != "" || $unknown != "" || $name != "" || $county != "" ||
> $year != "" || $countynow != "" || $state != "")
> {$query .= " WHERE ";}
> if ($dead == "")
> {$query .= " `Deceased`='N' AND";}
> if ($unknown == "")
> {$query .= " `USPS_Unknown`='N' AND ";}
> if ($name != "")
> {$query .= " `Last_Name` like '$name%' AND ";}
> if ($county != "")
> {$query .= " `County` like '$county' AND ";}
> if ($year != "")
> {$query .= " `Year_Tapped` like '$year' AND ";}
> if ($countynow != "")
> {$query .= " `County_Now` like '$countynow' AND ";}
> if ($state != "")
> {$query .= " `State_Now` like '$state' AND ";}
> $query = rtrim($query," AND");
> $query .= " order by $order_by";
>
> What needs to be 'OR' is the $name section to be:
> $query .= "`Last_Name` like '%$name%' OR `First_Name` like '%$name%'
> OR
> `Maiden_Name` like '%$name%'";
>
> Thanks,
> Wolf
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
http://php.net/fflush
On Sun, June 4, 2006 9:51 pm, Oliver John V. Tibi wrote:
> Hi Guys,
>
> I know this may sound fundamental to some of you, but do you know any
> way of explicitly flushing out stream buffers off to the socket using
> fsockopen()/fputs() combos? Hope to hear from you soon.
>
> Note: I'm not using http, and I'm connecting to some other arbitrary
> port other than http, so I don't know if ob_flush() and its family of
> functions will work.
>
> Thanks! :)
>
> --
> Oliver John V. Tibi
> Software Programmer/Web Application Developer
> IAMD Software Solutions
> [EMAIL PROTECTED]
> "Live free() or die()."
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
hi list,
i am facing a problem inserting binary data into a blob field.this is my
/etc/my.cnf file.
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
connect_timeout=60
[mysql.server]
user=mysql
basedir=/var/lib
[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
please help me. and this is what i get after running the comand mysql --help
.......................
.......................
.......................
Possible variables for option --set-variable (-O) are:
connect_timeout current value: 0
max_allowed_packet current value: 16777216
net_buffer_length current value: 16384
select_limit current value: 1000
max_join_size current value: 1000000
i guess there is some problem with connect_timeout.
--- End Message ---
--- Begin Message ---
I know this discussion doesn't need to continue any further..hah.. but I think
the biggest confusion people are having is that they're looking at two things
and assuming that PHP operates the same on both and these two things serve
different purposes.
1. Incrementing strings: Best example giving was "File1"++ == "File2" or
"FileA"++ == "FileB". In that case, wouldn't you want it to go from FileZ to
FileAA? Makes sense right?
2. Comparing "greatness" of strings: Rasmus mentioned this earlier, but I
wante to illustrate it a little more because I think it was overlooked. If you
have a list of names, for instance, and you alphabetize them, you'd get
something like this:
Bob
Brendan
Burt
Frank
Fred
Just become a name is longer doesn't mean it comes after the rest of the names
in the list. So in that vane, anything starting in "A" will never be >
something starting with a "Z". a < z aa < z aaa < z because:
a
aa
aaa
z
When using interation and a for loop and " <= z" it gets to "y" and it's true,
gets to "z" and it's still true, then increments to "az" and yup.. still < "z".
As mentioned, it's not until you get to something starting in "z" with
something after it that you're > "z".
So hopefully that makes a little more sense.
-TG
= = = Original message = = =
tedd wrote:
> At 1:09 PM -0700 6/4/06, Rasmus Lerdorf wrote:
>>> I agree with [1] and [2], but [3] is where we part company. You see, if you
>>> are right, then "aaa" would also be less than "z", but that doesn't appear
>>> so.
>> Of course it is.
>>
>> php -r 'echo "aaa" < "z";'
>> 1
>
> You missed the point, why does --
>
> for ($i="a"; $i<="z"; $i++)
>
> echo($i);
>
>
> -- not continue past "aaa"? Clearly, if "aaa" is less than "z" then why does
> the loop stop at "yz"?
I thought I explained that a few times. The sequence is:
a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab
Your loop stops at yz and doesn't get anywhere near aaa because za > z
-Rasmus
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
--- End Message ---