php-general Digest 29 Apr 2007 19:03:13 -0000 Issue 4763
Topics (messages 254104 through 254112):
Re: Help me put this into phpinesse!
254104 by: Tijnema !
Running processes in windows
254105 by: Nathan Wallis
254108 by: Tijnema !
Re: how to detect type of image
254106 by: tedd
254107 by: Edward Vermillion
254112 by: tedd
PHP 6: Mysql with iso-8859-1 chars outputting utf-8: "Could not convert binary
string to Unicode string"
254109 by: Rangel Reale
small picture into thumbnail
254110 by: Alain Roger
254111 by: Robert Cummings
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:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
On 4/29/07, Brad Sumrall <[EMAIL PROTECTED]> wrote:
<?php
ob_start();
session_start();
header("Cache-control: private");
require("includes/configure.php");
$conn=mysql_connect(DB_SERVER,DB_SERVER_USERNAME,DB_SERVER_PASSWORD);
mysql_select_db(DB_DATABASE) or die(mysql_error().": database
not available");
$show="no";
isset($_SESSION['userid']);
What's the sense of above line?
isset is a function, that returns true or false.
if $SESSION=NULL
include './phpbb/login_global.php'
$show="yes";
?>
What am I missing?
Brad
There's no concrete question what you want here. So i guess that is missing.
Tijnema
--- End Message ---
--- Begin Message ---
Howdy.
I have an application in windows that I am running with a PHP page using
exec ("start......
I am wondering as to the efficiency of such a statement and how taxing it is
on the server. If multiple people access a page with such a statement, what
toll does it take on the server and is there a better way to manage calls to
the server side executable? When this statement is called a command prompt
window appears for the duration of the execution. I am guessing it would be
possible to crash the server if thousands of these processes we created at
around the same time....just anyone experience would be greatly appreciated.
Thanks.
Nathan
--- End Message ---
--- Begin Message ---
On 4/29/07, Nathan Wallis <[EMAIL PROTECTED]> wrote:
Howdy.
I have an application in windows that I am running with a PHP page using
exec ("start......
I am wondering as to the efficiency of such a statement and how taxing it is
on the server. If multiple people access a page with such a statement, what
toll does it take on the server and is there a better way to manage calls to
the server side executable? When this statement is called a command prompt
window appears for the duration of the execution. I am guessing it would be
possible to crash the server if thousands of these processes we created at
around the same time....just anyone experience would be greatly appreciated.
Thanks.
Nathan
Switch to linux.
If you still want to stick to windows. I believe it is possible to
hide the command window, that would help also (Or was it a patch in
PHP-DEV?).
Windows won't be able to handle thousands of such processes. Even if
you have a really fast server, more then hundred processes is too much
for windows. It might still continue to run, but then it would be
extremely slow. If you're really expecting 1000s of requests, you
should definitely switch to linux.
Tijnema
--- End Message ---
--- Begin Message ---
At 4:46 PM -0500 4/28/07, Edward Vermillion wrote:
On Apr 28, 2007, at 12:21 PM, tedd wrote:
At 9:22 AM -0500 4/28/07, Edward Vermillion wrote:
It should, but instead try this:
$image_size = getimagesize($filename);
echo $image_size['mime'];
$image_size['mime'] ? Where did that come from?
I duno, maybe the manual.
http://us2.php.net/getimagesize <-- 5th or 6th example down.
Ahhh... that's for sending a mime type to the browser.
Ahhh no, it's just a way to get contents of the file.
If you really want to study this, try opening every different image
file (gif, jpg, png, etc.) you have on your desktop and examine each
of the header files via a HEX editor. You will find that every file
has an id of some type in it's header.
The php functions that provide data about files, do just that. They
inspect the header of the file and report what they have found. How
you use them, is your business.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On Apr 29, 2007, at 8:03 AM, tedd wrote:
At 4:46 PM -0500 4/28/07, Edward Vermillion wrote:
On Apr 28, 2007, at 12:21 PM, tedd wrote:
At 9:22 AM -0500 4/28/07, Edward Vermillion wrote:
It should, but instead try this:
$image_size = getimagesize($filename);
echo $image_size['mime'];
$image_size['mime'] ? Where did that come from?
I duno, maybe the manual.
http://us2.php.net/getimagesize <-- 5th or 6th example down.
Ahhh... that's for sending a mime type to the browser.
Ahhh no, it's just a way to get contents of the file.
If you really want to study this, try opening every different image
file (gif, jpg, png, etc.) you have on your desktop and examine
each of the header files via a HEX editor. You will find that every
file has an id of some type in it's header.
The php functions that provide data about files, do just that. They
inspect the header of the file and report what they have found. How
you use them, is your business.
Well, from the example it looks like that's returning a string that
can go straight into the header() function...
<?php
$size = getimagesize($filename);
$fp=fopen($filename, "rb");
if ($size && $fp) {
header("Content-type: {$size['mime']}");
fpassthru($fp);
exit;
} else {
// error
}
?>
whereas index 2 in the array returns an integer that corresponds to
the IMAGETYPE_* constants. I would assume they both get the
information from the same place, but just return it in different
formats based on the intended usage. Just like index 3 will get you a
string of 'width=? height=?' to add to an image tag, while index 0
and 1 returns an integer of width and height respectively.
I can get the width and height from index 3, but that's not what it
was designed for.
Ed
--- End Message ---
--- Begin Message ---
At 9:53 AM -0500 4/29/07, Edward Vermillion wrote:
On Apr 29, 2007, at 8:03 AM, tedd wrote:
The php functions that provide data about files, do just that. They
inspect the header of the file and report what they have found. How
you use them, is your business.
Well, from the example it looks like that's returning a string that
can go straight into the header() function...
<?php
$size = getimagesize($filename);
$fp=fopen($filename, "rb");
if ($size && $fp) {
header("Content-type: {$size['mime']}");
fpassthru($fp);
exit;
} else {
// error
}
?>
whereas index 2 in the array returns an integer that corresponds to
the IMAGETYPE_* constants. I would assume they both get the
information from the same place, but just return it in different
formats based on the intended usage. Just like index 3 will get you
a string of 'width=? height=?' to add to an image tag, while index 0
and 1 returns an integer of width and height respectively.
I can get the width and height from index 3, but that's not what it
was designed for.
It was designed to provide information. As I said you use it as you
want. Index 3 could have been used in and image tag, or in a report
of the image -- whatever you can find a use for it, use it.
The above example uses 'mime' for a header, but the below code uses
it more directly.
http://sperling.com/a/image_data/
Whatever floats your boat.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Hello!
I have a MySQL database where all tables are in the latin1 character set, with
accented (Portuguese) characters.
In my php.ini I have
;;;;;;;;;;;;;;;;;;;;
; Unicode settings ;
;;;;;;;;;;;;;;;;;;;;
unicode.semantics = on
unicode.runtime_encoding = iso-8859-1
unicode.script_encoding = iso-8859-1
unicode.output_encoding = utf-8
unicode.from_error_mode = U_INVALID_SUBSTITUTE
unicode.from_error_subst_char = 3f
unicode.fallback_encoding = iso-8859-1
because all my files and data in mysql server are in iso-8859-1.
When connecting to mysql I issue:
mysql_query('set names latin1', $this->mysql_link);
but when I do query in any record that have accented characters I get this
warning (using mysql_fetch_assoc):
----------
Could not convert binary string to Unicode string (converter UTF-8 failed on
bytes (0xE7) at offset 9)
----------
for all accented characters in all fields.
If I changed the set names query to:
mysql_query('set names utf8', $this->mysql_link);
it works, but I would like to keep compatibility with PHP 5, and for my
application it requires set names to be latin1. Also, my databases are not
created with the "utf8" option.
As I understood PHP 6's unicode support, all string characters (including mysql
result values) are converted from unicode.runtime_encoding to unicode (utf-16),
but looks like it is trying to convert from ASCII, which does not have all the
accented characters. Am I assuming right? How to make mysql_fetch_assoc assume
field values are in iso-8859-1 instead of ASCII?
Thanks,
Rangel Reale
--- End Message ---
--- Begin Message ---
Hi,
I would like to know how i can display small sized picture in my web
application ?
I mean in my database, picture can have max. 500 Kb, however as on 1 PHP
page i will display 20 pictures at once, i do not want to force end users to
download all 20 pictures (10Mb around) to have an overview.
I would like directly on server to resize picture to display them to end
user in format 100px*120px (for example) and like that size should be around
20 or 50Kb per picture.
I was thinking to use imagecopyresized function for that, but will it no
kill the server CPU and RAM ?
If you have some other suggestion, they are welcome, but do not forget that
i must have pictures in Database and 500 Kb (due to picture printing later
on - so good enough quality).
thanks a lot,
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5
--- End Message ---
--- Begin Message ---
On Sun, 2007-04-29 at 18:15 +0200, Alain Roger wrote:
> Hi,
>
> I would like to know how i can display small sized picture in my web
> application ?
> I mean in my database, picture can have max. 500 Kb, however as on 1 PHP
> page i will display 20 pictures at once, i do not want to force end users to
> download all 20 pictures (10Mb around) to have an overview.
>
> I would like directly on server to resize picture to display them to end
> user in format 100px*120px (for example) and like that size should be around
> 20 or 50Kb per picture.
> I was thinking to use imagecopyresized function for that, but will it no
> kill the server CPU and RAM ?
>
> If you have some other suggestion, they are welcome, but do not forget that
> i must have pictures in Database and 500 Kb (due to picture printing later
> on - so good enough quality).
Create the thumbnail once and cache it. On subsequent requests check if
thumbnail exists, if so use the cache. If not build from original image.
This way you incur the heavy CPU hit once for each image requested. This
take more disk space though, but not terribly.
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. |
`------------------------------------------------------------'
--- End Message ---