php-general Digest 23 Jun 2006 19:13:24 -0000 Issue 4202
Topics (messages 238544 through 238559):
Re: GD problems
238544 by: Chris
Finding out the upload date of the file
238545 by: Ko Ko
238546 by: Aaron Koning
STRING TO ASCII CHARACTERS
238547 by: Juanjo Pascual
238548 by: cajbecu
238549 by: Juanjo Pascual
238550 by: cajbecu
Re: templating
238551 by: Ryan A
238553 by: tedd
238554 by: tedd
Re: GET, POST, REQUEST
238552 by: John Nichel
Re: Equivelant to mysql_fetch_row for normal array
238555 by: Dave M G
238558 by: Jochem Maas
xmldoc
238556 by: weetat
238557 by: Brad Bonkoski
238559 by: Mariano Guadagnini
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 ---
Beauford wrote:
Since I know nothing of how this works, does this actually create a physical
image, and if it does I'm assuming it would be in the originating directory
from where the script was run - if this is the case, I got nothing.
This is a moot point now as I have done what I need without using gd, but it
would be nice to find out what the problem is.
Thanks.
Anyone know of a way I can test this further. A small script perhaps.
<?php
$image = imagecreatetruecolor(50, 50);
imagefilledrectangle($image, 0, 0, 50, 50, 0xffffff);
imagejpeg($image);
?>
It creates it in memory and it's a 50 x 50 white square.
Change the 0xffffff to 0xFF6600 and it should be a red square.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Hi,
How can I find out the upload date of the file to the server using PHP
function?
Regards,
Ko Ko
Reality starts with Dream
---------------------------------
How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates.
--- End Message ---
--- Begin Message ---
http://ca.php.net/stat
Might do it for you. Maybe check access time, although if you access the
file at after its uploaded, the access time is changed. Maybe mtime?
Aaron
On 6/23/06, Ko Ko <[EMAIL PROTECTED]> wrote:
Hi,
How can I find out the upload date of the file to the server using PHP
function?
Regards,
Ko Ko
Reality starts with Dream
---------------------------------
How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call
rates.
--
+--------------------------------------------
| Aaron Koning
| Information Technologist
| Prince George, BC, Canada.
+--------------------------------------------
| http://datashare.gis.unbc.ca/fist/
| http://datashare.gis.unbc.ca/gctp-js/
+--------------------------------------------
--- End Message ---
--- Begin Message ---
Do you know any way to convert any string to ascii characters??
I mean:
*"abcdefgh"*
to
*"abcdefgh"*
Juanjo.
--- End Message ---
--- Begin Message ---
function stransform($string) {
for ($i=0;$i<length($string);$i++) {
$data .= "&#".ord(substr($string,$i,1)).";";
}
return $data;
}
Juanjo Pascual wrote:
> Do you know any way to convert any string to ascii characters??
>
> I mean:
>
>
> *"abcdefgh"*
>
> to
>
> *"abcdefgh"*
>
>
> Juanjo.
>
--- End Message ---
--- Begin Message ---
Ok. Thanks.
You only have to change the function *length() *by the function *strlen()*
cajbecu escribió:
function stransform($string) {
for ($i=0;$i<length($string);$i++) {
$data .= "&#".ord(substr($string,$i,1)).";";
}
return $data;
}
Juanjo Pascual wrote:
Do you know any way to convert any string to ascii characters??
I mean:
*"abcdefgh"*
to
*"abcdefgh"*
Juanjo.
--- End Message ---
--- Begin Message ---
That`s true, my mistake.. (length is in pascal)
cheers,
Juanjo Pascual wrote:
> Ok. Thanks.
>
> You only have to change the function *length() *by the function *strlen()*
>
>
> cajbecu escribió:
>> function stransform($string) {
>> for ($i=0;$i<length($string);$i++) {
>> $data .= "&#".ord(substr($string,$i,1)).";";
>> }
>> return $data;
>> }
>>
>>
>> Juanjo Pascual wrote:
>>
>>> Do you know any way to convert any string to ascii characters??
>>>
>>> I mean:
>>>
>>>
>>> *"abcdefgh"*
>>>
>>> to
>>>
>>> *"abcdefgh"*
>>>
>>>
>>> Juanjo.
>>>
>>>
>>
>>
>>
--- End Message ---
--- Begin Message ---
Hi Rich,
Thanks for replying.
> > He just needs maybe 5 template
> > pages, same pages, different color.
>
> For something THIS simple, I truly believe you are
> Better Off (tm)
> with a simple head() and foot() function in a
> globals.inc file:
Sorry, dont know where my brain was that day, what I
meant was he needs like 5 template pages, with 5
"dynamic" spots on them (meaning that php will
generate the content for these 5 spots and they are
the parts that will be constantly changing depending
on the page), and identical pages will be used to
serve people with other languages except with a color
difference (meaning different colored graphics, not
just css)
My fault for not explaining it better, sorry.
Thanks,
Ryan
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
At 9:57 PM -0500 6/22/06, Richard Lynch wrote:
>On Thu, June 22, 2006 7:23 pm, tedd wrote:
>-snip-
> >> <body bgcolor="<?php echo $bgcolor?>">
>
>> Well... I prefer to separate the header and footer into two files and
>> load them as needed in my web page. In addition, I would most
>> certainly remove ALL attribute stuff that could/should be controlled
>> by css out of html and php and into a css file.
>
>Putting the stuff into CSS is fine with what I did -- I do that all
>the time.
I'm not criticizing. You may do whatever is your custom, but the attribute
"bgcolor" for the body tag is better served in a css format. The whole point of
css is to remove attributes from markup.
I realize that people have their own ways that work better for them -- nothing
wrong with that. And, if you need (for whatever reason) to change the
background color of a body tag programmatically, then your way works for you.
But for me, I would move it to embedded css -- that way I know where all
attributes are (embedded or in a css file) and don't have to go through my
markup trying to find why some presentational element isn't working correctly.
> > In between the two <body></body> tags it's pretty simple to manage the
>> html and keep track of div's. I never have a header or footer that
>> goes beyond the body tags -- so even if there is NO html in between, I
>> still have a valid page.
>
>The header and footer frequently contain the logo, site nav, possibly
>a site-wide context-sensitive nav, maybe a mailing list signup, and
>then copyright and so on.
>
>There's no need to be doing a bunch of include files to hit the HD
>(expensive) separately for each.
The need is in organization.
We don't write code in machine language, which would be faster. We write it in
whatever language (organization) is our custom, which is expensive. Everything
has a price. But, I would guess that the hit to the HD for loading a few extra,
but shorter, files would be very minimal as compared to loading one larger file
per page.
After all, we use includes in php the same way and I don't hear people saying
"Don't use includes because of the extra hits to the HD" -- do we? We do it for
organization.
>It's also all too easy to forget one of the include files on one of
>the pages and never even notice it... I've done it too many times when
>I went back to add some fluff page to some ancient site. :-(
That's the housekeeping I spoke of. We all have different techniques and
manners of organization. Mine works for me. If I forget an include, then that
page would simply be missing that feature, but the page would still work and
validate.
>A reasonable amount of the "all the same" stuff in head() handles all
>that, and the footer, in one HD seek, with matching tags between
>head() and foot() in a single file.
>
>It's also very easy to call foot() in an error condition to be sure
>all tags balance.
The tags in my "includes" always balance because I design them that way --
again, that's my organizational manner. The only includes that don't balance
are my header and footer includes -- but the header ends, and the footer
starts, with a body tag.
In short, my organization technique works and I don't have the problems you
describe.
Cheers,
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
At 3:37 AM -0700 6/23/06, Ryan A wrote:
>Hi Rich,
>Thanks for replying.
>
>
>> > He just needs maybe 5 template
>> > pages, same pages, different color.
>>
>> For something THIS simple, I truly believe you are
>> Better Off (tm)
>> with a simple head() and foot() function in a
>> globals.inc file:
>
>Sorry, dont know where my brain was that day, what I
>meant was he needs like 5 template pages, with 5
>"dynamic" spots on them (meaning that php will
>generate the content for these 5 spots and they are
>the parts that will be constantly changing depending
>on the page), and identical pages will be used to
>serve people with other languages except with a color
>difference (meaning different colored graphics, not
>just css)
>
>My fault for not explaining it better, sorry.
>
>Thanks,
>Ryan
Then within each of the "dynamic" spots run your php.
<?php include('spot1.php');?>
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Tue, June 20, 2006 2:38 am, Satyam wrote:
I come from languages
where
you not only have to initialize a variable but have to declare it as
well so
initializing comes natural, I feel wrong if I don't do it, even if the
interpreter does not care.
Just to be pedantic...
The interpreter actually DOES care, but you have to be wise enough to
enable E_NOTICE messages for the interpreter to tell you that it does
care.
You may want to get in the habit of using .htaccess to do that, as you
will be more comfy with PHP helping you catch any typos in failing to
initialize vars.
:-)
I do that here....our development and staging servers have all errors
turned on whereas on our production server, pretty much everything is
turned off. In a /perfect/ world, you would never see an error in my
code, as I _try_ to write clean code, and trap all the errors before
they get to the screen (no, not by the use of '@'). Since this is not a
perfect world, and I don't always write clean code, it's nice to see
those notices/errors pop up on the screen before the code gets live. ;)
--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Nicolas, Jochem, Tul,
I have been going mental, reading the online manual and trying different
things. I can not get this loop to work.
Please understand that I have endeavored to read up on list(), each(),
foreach(), while(). key(), and everything else I can. I've even looked
at online tutorials and I have to PHP books here. I'm asking on list not
because I come here before searching for existing help, it's because I
don't understand the help that I've found.
In fact, I've tried lifting code directly from a book I recently bought
on PHP, called "All In One: PHP, MySQL and Apache".
foreach($elements as $e){
while(list($key, $value) = each($e)){
echo "key = " . $key . "<br />";
echo "value = " . $value . "<br />";
}
}
But it still doesn't work. It says:
Warning: Variable passed to each() is not an array or object in
/home/dave/web_sites/thinkingworks.com/web/Article.class on line 60
I tested my code upstream to make sure my array does have the correct
values in it:
echo "This is the id for elements : " . $elements['id'] . "<br />";
echo "This is the type for elements : " . $elements['type'] . "<br />";
echo "This is the resource for elements : " . $elements['resource'] .
"<br />";
echo "This is the parent for elements : " . $elements['parent'] . "<br />";
This outputs:
This is the id for elements : 2
This is the type for elements : Text
This is the resource for elements : 1
This is the parent for elements : 1
Which is all I really want to do, but since it's a multidimensional
array, I can't get at the next set of values that follows the first.
Part of what I don't get, and part of what led me to the first question,
is that I don't get why a while() loop is so easy with
mysql_fetch_array, and yet to act on a multidemensional array in any
other way seems to be so complicated, with so many ways to skin a cat.
I tried what was suggested here on this list, by Tul, too:
foreach($elements as $e){
echo "e[type] = " . $e['type'] . "<br />";
echo "e[resource] = " . $e['resource'] . "<br />";
}
Which produced really weird results:
e[type] = 2
e[resource] = 2
e[type] = 2
e[resource] = 2
e[type] = T
e[resource] = T
e[type] = T
e[resource] = T
e[type] = 1
e[resource] = 1
e[type] = 1
e[resource] = 1
e[type] = 1
e[resource] = 1
e[type] = 1
e[resource] = 1
I could cycle through the other variants I've tried, but the bottom line
remains the same - it ain't working, the results don't match what I'm
seeing in the references, and I don't understand what's going on.
It would be really great if someone could lead me out of the darkness.
Thank you for your advice.
--
Dave M G
--- End Message ---
--- Begin Message ---
Dave M G wrote:
> Nicolas, Jochem, Tul,
>
> I have been going mental, reading the online manual and trying different
> things. I can not get this loop to work.
>
> Please understand that I have endeavored to read up on list(), each(),
> foreach(), while(). key(), and everything else I can. I've even looked
> at online tutorials and I have to PHP books here. I'm asking on list not
> because I come here before searching for existing help, it's because I
> don't understand the help that I've found.
>
> In fact, I've tried lifting code directly from a book I recently bought
> on PHP, called "All In One: PHP, MySQL and Apache".
> foreach($elements as $e){
> while(list($key, $value) = each($e)){
> echo "key = " . $key . "<br />";
> echo "value = " . $value . "<br />";
> }
> }
don't fix list()+each() with foreach() ...
// things to do when your stuck:
echo '<pre>';
var_dump($elements);
print_r($elements);
foreach($elements as $e) {
var_dump($e);
print_r($e);
}
echo '</pre>';
// example 1
foreach($elements as $e) {
echo "value= ",$e,"<br />";
}
// example 2
foreach($elements as $key => $value) {
echo "value= ",$value,"<br />";
echo "key= ",$key,"<br />";
}
// example 3
reset($elements);
while(list(, $value) = each($elements)) {
echo "value = " . $value . "<br />";
}
// example 4
reset($elements);
while(list($key, $value) = each($elements)) {
echo "key = " . $key . "<br />";
echo "value = " . $value . "<br />";
}
--- End Message ---
--- Begin Message ---
Hi all,
I have simple code below :
It run ok in one of my test server (Red Hat Enterprise) , PHP 4.3.2.
However in the one of production server which have same OS and PHP
version , the code did not display "done parsing xml" in log file. It
just display "starting parsing xml" only.
I have check all setting in php.ini , however cannot found any
different between 2 server.
Anybody have any ideas what happening here ? Thanks
<?php
$xmlfile = '/test/test.xml';
$_logger->logdebug("starting parsing xml");
$doc = xmldoc($xmlfile);
$_logger->logdebug("done parsing xml");
?>
--- End Message ---
--- Begin Message ---
weetat wrote:
Hi all,
I have simple code below :
It run ok in one of my test server (Red Hat Enterprise) , PHP 4.3.2.
However in the one of production server which have same OS and PHP
version , the code did not display "done parsing xml" in log file. It
just display "starting parsing xml" only.
I have check all setting in php.ini , however cannot found any
different between 2 server.
Anybody have any ideas what happening here ? Thanks
<?php
$xmlfile = '/test/test.xml';
$_logger->logdebug("starting parsing xml");
$doc = xmldoc($xmlfile);
$_logger->logdebug("done parsing xml");
?>
What does xmldoc() do? Perhaps it reaches some critical error within
that segment and causes the script to never complete?
--- End Message ---
--- Begin Message ---
Brad Bonkoski wrote:
weetat wrote:
Hi all,
I have simple code below :
It run ok in one of my test server (Red Hat Enterprise) , PHP 4.3.2.
However in the one of production server which have same OS and PHP
version , the code did not display "done parsing xml" in log file.
It just display "starting parsing xml" only.
I have check all setting in php.ini , however cannot found any
different between 2 server.
Anybody have any ideas what happening here ? Thanks
<?php
$xmlfile = '/test/test.xml';
$_logger->logdebug("starting parsing xml");
$doc = xmldoc($xmlfile);
$_logger->logdebug("done parsing xml");
?>
What does xmldoc() do? Perhaps it reaches some critical error within
that segment and causes the script to never complete?
Maybe when parsing the xml, the function throws an exception. That
happened to me with PHP 5 xml builtin support, which uses libxml to
process xml's, it can be that your document is malformed, you could try
with a php debugger (like zend debugger).
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.2/373 - Release Date: 22/06/2006
--- End Message ---