|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 20 Apr 2005 10:09:38 -0000 Issue 3408
php-general-digest-help
lists.php.net
Date: Wed Apr 20 2005 - 05:09:38 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 20 Apr 2005 10:09:38 -0000 Issue 3408
Topics (messages 213427 through 213484):
Re: php and linux shell script
213427 by: Rory Browne
213454 by: Richard Lynch
Re: can I join two mp3 files with php
213428 by: Rory Browne
213456 by: Richard Lynch
Re: Session variables are not stored when set in implicitly calledconstructor!??
213429 by: Jason Barnett
Why is the default value for arg_separator.output '&'?
213430 by: David Dorward
213432 by: Tom Rogers
213433 by: Roger B.A. Klorese
213434 by: Jared Williams
213437 by: Tom Rogers
213452 by: Richard Lynch
213455 by: Roger B.A. Klorese
213468 by: Richard Lynch
213478 by: David Dorward
213480 by: David Dorward
Re: set cookie function problem
213431 by: Ospinto
213459 by: Richard Lynch
213483 by: Mark Rees
Re: Last visitors
213435 by: Ryan A
213450 by: Richard Lynch
213464 by: Richard Lynch
Matching Number of Times a Word Occurs...
213436 by: Russell P Jones
213439 by: Al
213442 by: Matthew Fonda
213465 by: Prathaban Mookiah
Encoding help!
213438 by: Brian Dunning
213479 by: Petar Nedyalkov
Re: Convert gif to jpg
213440 by: scottkovach.bellsouth.net
Re: Sorting table columns dynamically on normalized MySQL tables
213441 by: Kim Briggs
213458 by: Richard Lynch
Re: Date class
213443 by: Rob Agar
PHP script problem (with MySQL)
213444 by: Sugimoto
213447 by: Richard Lynch
213448 by: Richard Lynch
213472 by: Satyam
script
213445 by: tommy
213446 by: Stephen Johnson
213449 by: Rob Agar
Re: post & redirect
213451 by: Matthew Weier O'Phinney
Re: Sessions - going back in browser
213453 by: Matthew Weier O'Phinney
213461 by: Richard Lynch
Thanks but problem again! Re: [PHP] PHP script problem (with MySQL)
213457 by: Sugimoto
213473 by: Petar Nedyalkov
213475 by: Satyam
dynamic class loaders
213460 by: php.electroteque.org
213467 by: Richard Lynch
213470 by: php.electroteque.org
213471 by: Markus Fischer
213474 by: Petar Nedyalkov
213476 by: php.electroteque.org
213481 by: Markus Fischer
Re: Images - Converting TIFF Format?
213462 by: Richard Lynch
213469 by: Tom Rogers
Re: explode a string
213463 by: Richard Lynch
Re: php output fills apache buffer for clients with slow internet connections
213466 by: Richard Lynch
One more time (Duft Punk) about hyperlink
213477 by: Sugimoto
213482 by: Mark Rees
Gunzip problem
213484 by: Oskar
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
> http://gtk.php.net/
>
Can you elaborate on what gtk has to do with making command line dialog boxes?
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
On Tue, April 19, 2005 2:24 pm, Rory Browne said:
>> http://gtk.php.net/
>>
>
> Can you elaborate on what gtk has to do with making command line dialog
> boxes?
Well, you run it from the command line.
And it makes dialog boxes.
Maybe not the kind of dialog boxes you wanted or whatever, but that pretty
much sums up GTK PHP in a nutshell...
One should also consider http://php.net/ncurses, but that was already
referenced, I do believe.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Are you on Windoze or Linux. If you're on linux, I'm sure you could
rig up something with mencoder.
If you're on windoze, you might still be able to use mencoder, but I'm
not sure, and you may find yourself with the need to explore other
options.
attached mail follows:
On Tue, April 19, 2005 1:17 pm, QT said:
> is it easy like this, I tried and works good. Shouldn't I need to handle
> something inside mp3? just easy to put each file together in the another
> file?
Some players will play it, and some won't.
Technically, it's an invalid MP3, but most players will ignore the extra
data in the middle of your file.
Check into the PHP ID3 software.
In addition to being able to add ID3 meta tags to MP3s I'm pretty sure it
can correctly append MP3s and fix all the data up correctly so it is a
totally legit MP3, instead of one that happens to work in most players.
It might even handle amr files, whatever those are.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Adam wrote:
> Hallo again,
> thank You for Your response.
>
>
>>>// singleton for request
>>>class Request {
>>> function __destructor() {
>>> $_SESSION["variable"] = "hallo";
>>
>>The __destructor() method is supposed to be about killing the class
>>(Request). It's probably bad practice to be changing $_SESSION vars
>>inside of there even if that $_SESSION var affects your class. Here,
>>read this page and maybe it will make more sense to you:
>>http://php.net/manual/en/language.oop5.decon.php
>
>
> i agree that in *most* cases destructor should only clean up after object.
> unfortunatly for "request" class there are few requirements:
> 1) must allow immidiate use w/o any explicit initialization or finalizaion.
> e.g. at any file You can use only Request::getInstance()->isRefresh() /**
> test if this request was caused by browser refresh */. this should be one
> and only line (except for inclusion of request.php oc) referencing request
> class -- no explicit call to Request::saveToSession() or anything ugly and
> potentialy disastrous like that.
Well ok, but why can't you just have saveToSession() in the conditional
block?
<?php
$_SESSION['Request'] = Request::getInstance();
if ($_SESSION['Request']->isRefresh() ) {
$_SESSION['Request']->saveToSession();
/* etc. */
exit();
}
/* Rest of script follows here */
?>
IMHO the point of OOP is to keep each function split into the minimal
functionality that you need. This allows you to reuse code easier
because a function does only the *minimum* amount of work necessary
instead of extra (unintended) functionality.
> 2) must provide mechanism for generating per session uniqe request
> identiers. now implemented as md5($_SESSION["next_reqest_id"]++) not very
> effective but handy:-P
The default session IDs aren't unique enough for you? Well then you can
use uniqid()
<?php $sess_id = md5(uniqid(rand(), TRUE)); ?>
> 3) must be serializable (this is why i can not put that session manipulation
> at __sleep function)
>
> these requirements (1,3) cast out __destruct, __sleep and explicit call to
> some saveToSession function. do You have any other idea when to store this
> information , please?
>
So... Request must be serializable? Forgive me but I don't see how this
is a problem. Perhaps someone else will understand what you mean here.
Do you mean that you need to serialize Request when condition in #1 is
true? If that's the case then you should be able to use the code block
above.
>
>>Heck, look at the user contributed notes since one of them will directly
>>affect this idea of yours.
>
>
> *doh* i don't know how could i coverlooke taht user reaction:-( thank You.
>
>
>>If the reference count for $req is greater than 0 (i.e. there is a
>>Singleton) then __destruct won't be called. And why should it be
>>called? Because, again, __destruct is for cleaning up the class while
>>the object is getting destroyed.
>
>
> Isn't __destruct is called even if reference count is gr then zero as a part
> of script finalization? imo yes -- i tried this with echoing something
> within singletons destructor (no invoke with explicit delete:-) and it
> worked.
>
>
> BR
> a3c
>
>
Yes, __destruct() gets called as part of the script finalization and
depending on your needs this might or might not be "A Good Thing."
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
attached mail follows:
For documents to conform to the XHTML recommendation, ampersand characters
much be encoded as &. The documentation for PHP recognises this. The
same applies to HTML (with some exceptions that the session code will never
encounter), although the PHP documentation makes no mention of this.
Given this, why is the default value of arg_separator.output '&' and not
'&'?
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
attached mail follows:
Hi,
Wednesday, April 20, 2005, 5:56:44 AM, you wrote:
DD> For documents to conform to the XHTML recommendation, ampersand characters
DD> much be encoded as &. The documentation for PHP recognises this. The
DD> same applies to HTML (with some exceptions that the session code will never
DD> encounter), although the PHP documentation makes no mention of this.
DD> Given this, why is the default value of arg_separator.output '&' and not
DD> '&'?
DD> --
DD> David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
DD> Home is where the ~/.bashrc is
You can set this with arg_separator.output in php.ini
--
regards,
Tom
attached mail follows:
On Wed, 20 Apr 2005, Tom Rogers wrote:
> You can set this with arg_separator.output in php.ini
That doesn't really answer why the choice was made to default to what
not only shouldn't be the default, but should probably be illegal
altogether.
attached mail follows:
>
> For documents to conform to the XHTML recommendation,
> ampersand characters much be encoded as &. The
> documentation for PHP recognises this. The same applies to
> HTML (with some exceptions that the session code will never
> encounter), although the PHP documentation makes no mention of this.
>
> Given this, why is the default value of arg_separator.output
> '&' and not '&'?
URLs don't have & in them.
The & is specific escaping for _only_ XML.
Jared
attached mail follows:
Hi,
Wednesday, April 20, 2005, 9:05:39 AM, you wrote:
RBAK> On Wed, 20 Apr 2005, Tom Rogers wrote:
>> You can set this with arg_separator.output in php.ini
RBAK> That doesn't really answer why the choice was made to default to what
RBAK> not only shouldn't be the default, but should probably be illegal
RBAK> altogether.
Well it would appear that '&' is the correct one to use and it is PHP
that gets it wrong when using it in a url reference such as <a
href="...." where it should by convert it to be &.
But it doesn't so I guess we have to force it in the ini file.
--
regards,
Tom
attached mail follows:
On Tue, April 19, 2005 4:05 pm, Roger B.A. Klorese said:
> On Wed, 20 Apr 2005, Tom Rogers wrote:
>> You can set this with arg_separator.output in php.ini
>
> That doesn't really answer why the choice was made to default to what
> not only shouldn't be the default, but should probably be illegal
> altogether.
Errrr.
Some of us don't *USE* XHTML (blech!)
Why in the world should we be forced to follow your narrow-minded
so-called "standard"? :-)
Furthermore, the & as separator pre-dates & by *years* and billions of
lines of code could be affected by altering the default.
So, really, Backwards Compatibility alone makes this a no-brainer default
value of: &
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Richard Lynch wrote:
>Why in the world should we be forced to follow your narrow-minded
>so-called "standard"? :-)
>
>
Hint: smileys indicate that you're joking. If you're joking, I don't
get what's humorous -- please explain. If you're making a serious point
but trying to have the rhetorical equivalent of "no offense, but..." you
should probably know that any time someone says "no offense, but..."
they really mean to offend but get off scot-free.
>Furthermore, the & as separator pre-dates & by *years* and billions of
>lines of code could be affected by altering the default.
>So, really, Backwards Compatibility alone makes this a no-brainer default
>value of: &
>
So default behaviors should never change?! Absurd. you should be
notified that they are changed, and should have a mechanism to configure
for the previous behavior... but they have to be allowed to change as
standards do.
attached mail follows:
On Tue, April 19, 2005 7:45 pm, Roger B.A. Klorese said:
> Richard Lynch wrote:
>
>>Why in the world should we be forced to follow your narrow-minded
>>so-called "standard"? :-)
>>
>>
>
> Hint: smileys indicate that you're joking. If you're joking, I don't
> get what's humorous -- please explain. If you're making a serious point
> but trying to have the rhetorical equivalent of "no offense, but..." you
> should probably know that any time someone says "no offense, but..."
> they really mean to offend but get off scot-free.
Okay, I meant to offend. :-)
Happy? :-) :-) :-)
>>Furthermore, the & as separator pre-dates & by *years* and billions
>> of
>>lines of code could be affected by altering the default.
>>So, really, Backwards Compatibility alone makes this a no-brainer default
>>value of: &
>>
> So default behaviors should never change?! Absurd. you should be
> notified that they are changed, and should have a mechanism to configure
> for the previous behavior... but they have to be allowed to change as
> standards do.
Please feel free to take this up with the Developers on PHP-Dev or
PHP-Internals or whatever and argue the issue with them.
But if it's going to break a billion scripts, it's probably not gonna
happen to follow a "standard" that isn't the only game in town. XHTML is
not ubiquitous. [shrug]
Since there are still browsers in use that will choke on & in the URL,
last time I checked, you're pretty much fighting for a lost cause, as far
as I'm concerned.
Good Luck!
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Jared Williams wrote:
>> Given this, why is the default value of arg_separator.output
>> '&' and not '&'?
> URLs don't have & in them.
> The & is specific escaping for _only_ XML.
No, XML and SGML which includes XHTML and HTML. How often are PHP sessions
used to generate output for languages other then those?
And even if you want to generate for other languages, why not set
arg_separator.output to ; instead? Its already in arg_separator.input and
doesn't need escaping to be represented in an HTML or XHTML document. The
HTML specification even goes so far as to explicitly recommend it.
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
attached mail follows:
Richard Lynch wrote:
> But if it's going to break a billion scripts, it's probably not gonna
> happen to follow a "standard" that isn't the only game in town. XHTML is
> not ubiquitous. [shrug]
Representing & characters as & has been a requirement of SGML and XML
based languages, HTML included, since long before XHTML appeared on the
scene.
What scripts would making this change be likely to break? I have difficulty
believing it could cause problems for other then a very small proprotion of
users - unlike the change in register_globals a few years ago.
> Since there are still browsers in use that will choke on & in the URL,
> last time I checked, you're pretty much fighting for a lost cause, as far
> as I'm concerned.
We aren't talking about "in the URL", we're talking about "in the href
attribute". Browsers convert & in HTML documents (including in href
attributes) to & before they think about them being part of URLs.
Can you name any browser that gets it wrong? I stress that typing
http://www.example.com/?foo=bar&baz=baa into the address bar is not how
the issue should be tested.
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
attached mail follows:
Marek, you're right. Thanks. Solved the problem
"Marek Kilimajer" <lists
kilimajer.net> wrote in message
news:4265509C.1050704
kilimajer.net...
> Ospinto wrote:
> > o....k.......what does that have to do with my problem?
>
> The time is send in GMT, and your computer is set to GMT -7. So the
> cookie is set to expire in the past.
>
> >
> > "Marek Kilimajer" <lists
kilimajer.net> wrote in message
> > news:42654D30.30500
kilimajer.net...
> >
> >>Ospinto wrote:
> >>
> >>>Hi,
> >>>Can someone help me with this problem?
> >>>setcookie('myCookie',"blah");
> >>>works fine. but when i try to set it with an expiry time, it doesn't.
> >>>setcookie('myCookie',"blah",time()+3600);
> >>>
> >>>I have cookies enabled on my browser of course. And the way I know the
> >>>second statement is not working is cos I'm doing a var_dump of
> >
> > $_COOKIES.
> >
> >>>Thanks for your help.
> >>>
> >>
> >>Fix the timezone on your computer. It's 20:25 here and your message
> >>"will" arrive in my mailbox at 23:20.
> >
> >
attached mail follows:
On Tue, April 19, 2005 2:20 pm, Ospinto said:
> Can someone help me with this problem?
> setcookie('myCookie',"blah");
> works fine. but when i try to set it with an expiry time, it doesn't.
> setcookie('myCookie',"blah",time()+3600);
>
> I have cookies enabled on my browser of course. And the way I know the
> second statement is not working is cos I'm doing a var_dump of $_COOKIES.
> Thanks for your help.
If the user's computer clock is way out of whack, and you are setting a
cookie to expire in 1 hour, you're likely to have problems...
Though *maybe* browsers account for this by comparing your Date: header
and your clock time, and ignore the user clock.
For sure, though, *some* versions of IE will *NOT* work when you set a
Cookie time, but not a path.
That's because the Microsoft engineers mis-read the Cookie spec (on
purpose perhaps) and require *both* time and path, or neither, but not
just path.
YMMV
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
You might consider using JavaScript to set the cookie, as that will
execute on the client and therefore use the client's time to make any
calculations regarding expiry. This may or may not suit your purpose.
Mark
-----Original Message-----
From: Richard Lynch [mailto:ceo
l-i-e.com]
Sent: 20 April 2005 04:18
To: Ospinto
Cc: php-general
lists.php.net
Subject: Re: [PHP] set cookie function problem
On Tue, April 19, 2005 2:20 pm, Ospinto said:
> Can someone help me with this problem? setcookie('myCookie',"blah");
> works fine. but when i try to set it with an expiry time, it doesn't.
> setcookie('myCookie',"blah",time()+3600);
>
> I have cookies enabled on my browser of course. And the way I know the
> second statement is not working is cos I'm doing a var_dump of
> $_COOKIES. Thanks for your help.
If the user's computer clock is way out of whack, and you are setting a
cookie to expire in 1 hour, you're likely to have problems...
Though *maybe* browsers account for this by comparing your Date: header
and your clock time, and ignore the user clock.
For sure, though, *some* versions of IE will *NOT* work when you set a
Cookie time, but not a path.
That's because the Microsoft engineers mis-read the Cookie spec (on
purpose perhaps) and require *both* time and path, or neither, but not
just path.
YMMV
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, Cisco, Sun Microsystems, 3Com
GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 2000' REGISTERED COMPANY
**********************************************************************
CONFIDENTIALITY NOTICE:
This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.
GENERAL STATEMENT:
Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order, subject to our Terms and Conditions available from http://www.gammaglobal.com
E&OE
**********************************************************************
**********************************************************************
attached mail follows:
Hey,
Thanks for replying, I tried using the test example of Petar Nedyalkov, but
when i try to create the following:
CREATE TABLE `profile_log` (
`profile_id` int(10) default NULL,
`user_id` int(10) default NULL,
`last_login` timestamp NOT NULL
) ENGINE=MyISAM CHARSET=utf8
I get an error on both
ENGINE=MyISAM
and
CHARSET=utf8
What are they for really? can I omit them? or will that effect the program
later on?
Thanks,
Ryan
On 4/19/2005 4:42:08 PM, Tom Crimmins (php
pottcounty.com) wrote:
> On Tuesday, April 19, 2005 09:09, John Nichel wrote:
>
>
>
> > Petar Nedyalkov wrote:
>
> > <snip>
>
> >> You can store only 10 records for each user by using the following
>
> >> logic:
>
> >>
>
> >> mysql> show create table profile_log\G
>
> >> *************************** 1. row ***************************
>
> >> Table: profile_log Create Table: CREATE TABLE `profile_log` (
>
> >> `profile_id` int(10) default NULL,
>
> >> `user_id` int(10) default NULL,
>
> >> `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update
>
> >> CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8
>
> >> 1 row in set (0.00 sec)
>
> >>
>
> >> When you create a profile you fill 10 blank records with timestamp
>
> >> 0000-00-00 00:00:00.
>
> >>
>
> >> Then if a user sees a profile:
>
> >>
>
> >> PSEUDO SQL:
>
> >>
>
> >> $SQL = "UPDATE profile_log SET user_id=".$userId.
> " WHERE
> >> profile_id=". $profileId." ORDER BY timestamp ASC LIMIT 1
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.16 - Release Date: 4/18/2005
attached mail follows:
On Tue, April 19, 2005 4:46 pm, Ryan A said:
> Hey,
> Thanks for replying, I tried using the test example of Petar Nedyalkov,
> but
> when i try to create the following:
>
> CREATE TABLE `profile_log` (
> `profile_id` int(10) default NULL,
> `user_id` int(10) default NULL,
> `last_login` timestamp NOT NULL
> ) ENGINE=MyISAM CHARSET=utf8
ENGINE= is MySQL 4.x for TYPE= in MySQL 3.x
I dunno about the CHARSET stuff.
But then, this is a *MySQL* question, not PHP!
Try here: http://mysql.com/
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Tue, April 19, 2005 5:57 am, Ryan A said:
> On the profile page there should be "last 10 visitors", it will not
> register
> the guests, but if someone had logged in and visited your profile, it
> should
> show their username....if there are 10 enteries in the db and when the
> 11th
> person comes...then the first person who came should be "bumped" off and
> the
> 11th person takes his place and so on....
One possibility not yet discussed...
I *think* MySQL has an 'array' data type.
You could then have an array of size 10 on each record.
Then, if MySQL has some kind of array_push and array_slice, you'd be able
to do:
update users set profile_viewers = array_slice(array_push($this_visitor,
profile_viewers), 1, 10) where user_id = $this_profile_id
Hopefully, you can even do something like:
select * from users as viewers, users as this_one
where this_one.user_id = $this_profile_id
and in_array(viewers.user_id, this_one.profile_viewers)
I have NO IDEA if MySQL actually has all this functionality, but if it
does, it may be more clear and/or efficient than a 10-to-1 table...
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Im trying to count the number of times a word occurs in a string - is the
only way to do this preg_match_all?
Russ Jones
attached mail follows:
Russell P Jones wrote:
> Im trying to count the number of times a word occurs in a string - is the
> only way to do this preg_match_all?
>
> Russ Jones
No, there are hundreds of other ways; but, preg_match_all() is probably
the easiest.
$number= preg_match_all("%$word%sm", $string, $matches);
attached mail follows:
Hello,
http://us4.php.net/substr_count
Regards,
Matthew Fonda
Russell P Jones wrote:
> Im trying to count the number of times a word occurs in a string - is the
> only way to do this preg_match_all?
attached mail follows:
substr_count() should be more easy, but limited in functionality.
Prathap
attached mail follows:
I know this is a common question but I have RTFM and STFW until I'm
blue in the face - I really need some help here. :)
I've got some forms into which users are going to enter text that
frequently contains funny characters (pilcrows, foreign text, etc). So
I need to encode it before writing it into MySQL, and decode it when
reading it back out and writing it to the page. I've tried
base64_encode/base64_decode, rawurlencode/rawurldecode,
utf8_encode/utf8_decode, combinations, and others. My MySQL table is
set to use UTF8 and my web pages are all set to UTF8. Most of what I've
tried takes:
™©ƒ
And when I read it from MySQL and output it to the web page, it's
turned into:
�©�
I need some help here! Thanks. :) :) :)
attached mail follows:
On Wednesday 20 April 2005 03:05, Brian Dunning wrote:
> I know this is a common question but I have RTFM and STFW until I'm
> blue in the face - I really need some help here. :)
>
> I've got some forms into which users are going to enter text that
> frequently contains funny characters (pilcrows, foreign text, etc). So
> I need to encode it before writing it into MySQL, and decode it when
> reading it back out and writing it to the page. I've tried
> base64_encode/base64_decode, rawurlencode/rawurldecode,
> utf8_encode/utf8_decode, combinations, and others. My MySQL table is
> set to use UTF8 and my web pages are all set to UTF8. Most of what I've
> tried takes:
>
> ™©ƒ
>
> And when I read it from MySQL and output it to the web page, it's
> turned into:
>
> �©�
What is the default content-type of the webserver you use?
What is the content-type you return to the user through your php scripts?
>
> I need some help here! Thanks. :) :) :)
--
Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)
PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQBCZfplLT98C3rkVDYRAkU2AKCc5/ScwPKWxzfAGJteTBLxavu/rgCcDZDU
GXBgtBOFTAmqv2AmkQSvlIs=
=O1l8
-----END PGP SIGNATURE-----
attached mail follows:
This should work for you:
$image_dimensions =
getimagesize($uploadedfilename);
$src_image =
imagecreatefromgif($uploadedfilename);
$resized_image =
imagecreatetruecolor($width,$height); // can be resized,
or else set these vars to the same as the original
if (($src_image) && ($resized_image)) {
if(
imagecopyresampled($resized_image,$src_image,0,0,0,0,$iw,$ih,$image_dimensions[0],$image_dimensions[1])
){
$filepath = "/path/to/new/image/newimagename.jpg";
$jpg_quality = 80;
imagejpeg($resized_image, $filepath, $jpg_quality);
}
}
"Roman Duriancik" <rduriancik
indprop.gov.sk> wrote in message
news:4264EE4B.8070207
indprop.gov.sk...
> Hello,
> Is it possible to convert pictures in gif format to jpg format in php
> script ?
> Thank you for yours responses.
> Roman
attached mail follows:
Greetings,
If you are still looking for "tips" and want to get complicated/fancy,
I have seen columns used called sort_order more than a few times.
This should not be too hard to maintain for things like a few
buildings, etc., where the lookup table does not change much over
time. You would then have another option for your "oder by" clause.
cheers,
KB
On 4/19/05, Jay Blanchard <jay.blanchard
niicommunications.com> wrote:
> [snip]
> I can do that, but is there a better way? How do you all handle
> dynamic sorting of normalized DBs?
> [/snip]
>
> Normalization has no effect on sort order where any DB is concerned.
> Sort order is determined in the sort clause in the query. So if you want
> to sort by location and you are using MySQL your ORDER BY clause should
> be location....(regardless of joins)
>
> SELECT foo
> FROM bar
> ORDER BY location
>
> returns
>
> course instructor location
> Science Bill Elementary School
> Basket Weaving Dave High School
> Math Dave Middle School
> Biology Jessica Middle School
>
> The results with course as the sort qualifier
>
> course instructor location
> Basket Weaving Dave High School
> Biology Jessica Middle School
> Math Dave Middle School
> Science Bill Elementary School
>
> You have over-compicated a simple issue
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
On Tue, April 19, 2005 12:10 pm, Leif Gregory said:
> I've been wrestling with this one for a bit and wanted to see if
> anyone had a nice magic bullet (yeah right) to do this.
Yes.
> Now, I want to display all the courses and have the names instead of
> id numbers show up, so I'd select from Courses and output that.
>
> course instructor location
> Basket Weaving Dave High School
> Math Dave Middle School
> Science Bill Elementary School
> Biology Jessica Middle School
>
>
> I've done this by building arrays previous to doing the select on
> Course and in the While loop to list the courses pull the name from
> the instructors array and locations array based on the matching id.
Don't do that.
Just build a JOIN query and do one query.
The only time to do what you are doing is when your JOIN would be millions
(literally) of records, and your hardware can't handle it, and you only
want 10 rows at a time anyway.
*THEN* you can break the rules and send 10 little queries instead of one
big one that will bring your server to its knees.
> Since the DB is normalized, it's sorting by the ID number which has no
> relation to being sorted alphabetically.
No, it is *NOT* sorting on the ID number.
By definition, in SQL, if you don't specify a sort order (or in this case
a second order) then the SQL engine can and will output the records in any
order it feels like.
In that case of MySQL and ISAM tables, that *HAPPENS* to be the ID order,
because the under-lying SQL engine happens to find it convenient to have
them in that order.
If you *DELETE* an ID number, then put another one in, but force it to be
the same ID number you'll probably see the records come out in a different
order. It's usually a really Bad Idea to do that (forcing an ID to be
re-used) but for the purposes of learning/demonstration you can do it.
At any rate, MySQL is *NOT* sorting by ID number. It's not sorting *AT*
*ALL* except for what you told it to sort. It just spews out the records
in any old order at all after "location" is done -- Which happens to be ID
order, but that's more like coincidence than plan [*].
[*] Technically, it's not coincidence at all, and has to do with the
low-level MySQL ISAM code and how it works, but that's not a documented
feature, per se.
> i.e. If they sort on Location, they get the records back like this
>
> course instructor location
> Math Dave Middle School
> Biology Jessica Middle School
> Basket Weaving Dave High School
> Science Bill Elementary School
>
> Because Middle is id 1, High is id 2, and Elementary is id 3.
>
> That's not what they want obviously.
Why not?
What *DO* they want, then?
Do you want, perhaps, to have a DEFAULT sort order, which kicks in after
their chosen ordering?
Perhaps you could do (here's your magic bullet):
<?php
$default_sort_order = "course, instructor, location";
.
.
.
$query .= "ORDER BY $_GET[order_by], $default_sort_order ";
?>
So now, they click on the link with: ?order_by=location
And their choice of "location" kicks in *FIRST*.
After that, because of the ", $default_sort_order" you also sort (within
location) by "course"
Then by "instructor"
Then, oddly enough, by "location" again, but that's kinda irrelevant. It
won't *hurt* anything [**], mind you, it's just kinda silly, since you
have already sorted by location in the very first place.
But in this case, kinda silly makes your life really simple.
[**] Technically, it's a little inefficient to have that extra bogus
"location" in there at the end, but you're probably not sorting enough
rows for it to make any measurable difference in your results... And
MySQL might even be smart enough to optimize it out anyway.
> How I got into this mess was by trying to do the right thing and
> normalize my DB. It wasn't until they threw the sorting deal at me
> that I realized I probably should have used the instructor name and
> location name in the Course.instructorID and Course.locationID fields.
> It would have saved me some grief, but part of the problem is that the
> location name can be something like this:
No, no, no.
You did the right thing. :-)
You just needed to go farther down the road you are on, instead of
stopping partway.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Matthias wrote:
> Have you looked at the PEAR Date class?
>
> http://pear.php.net/package/Date
PEAR Date is good - I use it a lot - but watch out for this bug if
you're running on Windows http://pear.php.net/bugs/bug.php?id=2344
basically, there's some getenv/putenv trickery in the
Date_Timezone::inDaylightTime method called in Date::before &
Date::after which causes access violations. Unfortunately the Date
owner's attitude is roughly 'not my problem, windows sucks' (which may
be true but doesn't help much :-/ )
R
attached mail follows:
Hello,
I need your help about PHP (ver 4.3.1) and MySQL (ver 3.23) database.
I am struggling to customise a database (using left command etc), and am
stuck now.
Please have a brief look at my scripts below.
What I do like to do is to get first 3 letters from "loc1" column from
openart_table (MySQL).
And show the data in the follwoing part...
<td><? echo $row["loc1"]; ?><br></td>
but also I would like to make hyperlinks to jpg files to images/"the first 3
letters from loc1".jpg
So it will be something like this...
<td>
<a href="/image/<? echo $row["loc1"]; ?>.jpg"><? echo $row["loc1"];
?></a><br>
</td>
But when I tried, "select left (loc1,3) from openart_table where......"
doesnt work properly.
I do not want to destroy anything for the rest of the table.
I need all data from "tit1", "pub1", "id1", and "ref1" in each column.
Could you show me a script example?
Could you help me, please? Thank you.
---------------------------------------------PHP script from here
<html>
<body>
<table border="1" bordercolor="black" cellspacing="0" align="center"
BGCOLOR="#CCFFFF" width="900">
<tr bgcolor="#ffcc66">
<td align="center"><b>ID No</b><br></td>
<td align="center" BGCOLOR="#CC3366"><b>Book Title</b><br></td>
<td align="center"><b>Publisher</b><br></td>
<td align="center"><b>ID</b><br></td>
<td align="center"><b>Reference</b><br></td>
<td align="center" width="10%"><b>Location</b><br></td>
</tr>
<?
mysql_connect(localhost,root,cheers);
mysql_select_db(openart);
if($tit == "" &&
$res == "" &&
$pub == "" &&
$date == "" &&
$id == "" &&
$ref == "" &&
$loc == "" &&
$type == "" &&
$vol == "" &&
$fre == "" &&
$note == "")
{
echo 'Type something';
}
elseif($tit == "%" || $res == "%" || $pub == "%" || $date == "%" || $id ==
"%" ||
$ref == "%" || $loc == "%" || $type == "%" || $vol == "%" || $fre ==
"%" || $note == "%"){
echo 'Not Valid';
}
else{
if($tit == ""){
$tit = '%';
}
if($res == ""){
$res = '%';
}
if($pub == ""){
$pub = '%';
}
if($date == ""){
$date = '%';
}
if($id == ""){
$id = '%';
}
if($ref == ""){
$ref = '%';
}
if($loc == ""){
$loc = '%';
}
if($type == ""){
$type = '%';
}
if($vol == ""){
$vol = '%';
}
if($fre == ""){
$fre = '%';
}
if($note == ""){
$note = '%';
}
$result = mysql_query("select * from openart_table
where tit1 like '%$tit%'
and res1 like '%$res%'
and pub1 like '%$pub%'
and date1 like '%$date%'
and id1 like '%$id%'
and ref1 like '%$ref%'
and loc1 like '%$loc%'
and type1 like '%$type%'
and vol1 like '%$vol%'
and fre1 like '%$fre%'
and note1 like '%$note%' order by tit1");
$rows = mysql_num_rows($result);
echo $rows,"Records Found <p>";
while($row = mysql_fetch_array($result)){
?>
<tr>
<td><a href = "openart_detail.php ?iden=<? echo $row["openart_id"] ?>"><?
echo $row["openart_id"]; ?></a><br></td>
<td><? echo $row["tit1"]; ?><br></td>
<td><? echo $row["pub1"]; ?><br></td>
<td><? echo $row["id1"]; ?><br></td>
<td><? echo $row["ref1"]; ?><br></td>
<td><? echo $row["loc1"]; ?><br></td>
</tr>
<?
}
}
?>
</table>
</body>
</html>
----------------------------------------------------end of script
attached mail follows:
On Tue, April 19, 2005 6:25 pm, Sugimoto said:
> What I do like to do is to get first 3 letters from "loc1" column from
> openart_table (MySQL).
select substring(loc1, 1, 3) as THREE_LETTER_CODE, * from openart_table ...
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
[Connective issues may make this a duplicate post. Sorry.]
On Tue, April 19, 2005 6:25 pm, Sugimoto said:
> What I do like to do is to get first 3 letters from "loc1" column from
openart_table (MySQL).
select substring(loc1, 1, 3) as THREE_LETTER_CODE, * from openart_table ...
--
Like Music?
http://l-i-e.com/artists.htm
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
May I sugest that you assemble the SQL statement in a different way? With
such a big conditional, it will slow down the Sql server.
if ($tit != '') $condition .= "and tit1 like '%$tit%'";
.... and so on for each search field ...
$sql = "Select *, substring(loc1, 1, 3) as loc1 from openart_table where" .
substr($condition,4);
'like' conditions are hard on the server, specially if they start with a '%'
since then no indexes can be used. The server can only go through each and
every single record in the database. If, instead, you avoid the % at the
begining, some index information can be used. You might also want to check
FullText searches
Satyam
"Sugimoto" <sugimoto
momat.go.jp> wrote in message
news:002601c54547$e007a880$d405a8c0
sugimoto...
> Hello,
> I need your help about PHP (ver 4.3.1) and MySQL (ver 3.23) database.
> I am struggling to customise a database (using left command etc), and am
> stuck now.
> Please have a brief look at my scripts below.
>
> What I do like to do is to get first 3 letters from "loc1" column from
> openart_table (MySQL).
> And show the data in the follwoing part...
> <td><? echo $row["loc1"]; ?><br></td>
>
> but also I would like to make hyperlinks to jpg files to images/"the first
> 3
> letters from loc1".jpg
> So it will be something like this...
> <td>
> <a href="/image/<? echo $row["loc1"]; ?>.jpg"><? echo $row["loc1"];
> ?></a><br>
> </td>
>
> But when I tried, "select left (loc1,3) from openart_table where......"
> doesnt work properly.
> I do not want to destroy anything for the rest of the table.
> I need all data from "tit1", "pub1", "id1", and "ref1" in each column.
>
> Could you show me a script example?
> Could you help me, please? Thank you.
>
> ---------------------------------------------PHP script from here
> <html>
> <body>
> <table border="1" bordercolor="black" cellspacing="0" align="center"
> BGCOLOR="#CCFFFF" width="900">
> <tr bgcolor="#ffcc66">
> <td align="center"><b>ID No</b><br></td>
> <td align="center" BGCOLOR="#CC3366"><b>Book Title</b><br></td>
> <td align="center"><b>Publisher</b><br></td>
> <td align="center"><b>ID</b><br></td>
> <td align="center"><b>Reference</b><br></td>
> <td align="center" width="10%"><b>Location</b><br></td>
> </tr>
>
> <?
> mysql_connect(localhost,root,cheers);
> mysql_select_db(openart);
> if($tit == "" &&
> $res == "" &&
> $pub == "" &&
> $date == "" &&
> $id == "" &&
> $ref == "" &&
> $loc == "" &&
> $type == "" &&
> $vol == "" &&
> $fre == "" &&
> $note == "")
> {
> echo 'Type something';
> }
>
> elseif($tit == "%" || $res == "%" || $pub == "%" || $date == "%" || $id ==
> "%" ||
> $ref == "%" || $loc == "%" || $type == "%" || $vol == "%" || $fre ==
> "%" || $note == "%"){
> echo 'Not Valid';
> }
>
> else{
> if($tit == ""){
> $tit = '%';
> }
> if($res == ""){
> $res = '%';
> }
> if($pub == ""){
> $pub = '%';
> }
> if($date == ""){
> $date = '%';
> }
> if($id == ""){
> $id = '%';
> }
> if($ref == ""){
> $ref = '%';
> }
> if($loc == ""){
> $loc = '%';
> }
> if($type == ""){
> $type = '%';
> }
> if($vol == ""){
> $vol = '%';
> }
> if($fre == ""){
> $fre = '%';
> }
> if($note == ""){
> $note = '%';
> }
> $result = mysql_query("select * from openart_table
> where tit1 like '%$tit%'
> and res1 like '%$res%'
> and pub1 like '%$pub%'
> and date1 like '%$date%'
> and id1 like '%$id%'
> and ref1 like '%$ref%'
> and loc1 like '%$loc%'
> and type1 like '%$type%'
> and vol1 like '%$vol%'
> and fre1 like '%$fre%'
> and note1 like '%$note%' order by tit1");
>
> $rows = mysql_num_rows($result);
> echo $rows,"Records Found <p>";
> while($row = mysql_fetch_array($result)){
> ?>
> <tr>
> <td><a href = "openart_detail.php ?iden=<? echo $row["openart_id"] ?>"><?
> echo $row["openart_id"]; ?></a><br></td>
> <td><? echo $row["tit1"]; ?><br></td>
> <td><? echo $row["pub1"]; ?><br></td>
> <td><? echo $row["id1"]; ?><br></td>
> <td><? echo $row["ref1"]; ?><br></td>
> <td><? echo $row["loc1"]; ?><br></td>
> </tr>
> <?
> }
> }
> ?>
> </table>
> </body>
> </html>
>
> ----------------------------------------------------end of script
attached mail follows:
I'm hoping someone on this list can help me with something I've been
struggling with lately...
I have a php based web page that I'd like to have load an include file
only when it is Tuesday 11pm - Weds 1 am Eastern Standard time (USA).
At other times I would like my page to load and alternate include file.
If someone could help me with the code or point me in the right
direction it would be very appreciated.
Thanks.
Tommy.
attached mail follows:
http://php.net/time
http://php.net/date
http://php.net/mktime
one or a combination of these functions will help you do what you want.
HTH
On Apr 19, 2005, at 6:37 PM, tommy wrote:
> I'm hoping someone on this list can help me with something I've been
> struggling with lately...
>
> I have a php based web page that I'd like to have load an include file
> only when it is Tuesday 11pm - Weds 1 am Eastern Standard time (USA).
> At other times I would like my page to load and alternate include
> file.
>
> If someone could help me with the code or point me in the right
> direction it would be very appreciated.
>
> Thanks.
>
> Tommy.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
*********
Stephen Johnson
stephen
thelonecoder.com
http://www.thelonecoder.com
--continuing the struggle against bad code--
*********
attached mail follows:
here's the clue to the other half of the puzzle:
you can do this kind of thing in php
if (whatever)
{
include 'something.php';
}
else
{
include 'something else.php';
}
hth,
Rob
> -----Original Message-----
> From: Stephen Johnson [mailto:Freeway
pets4u.com]
> Sent: Wednesday, 20 April 2005 11:53 AM
> To: tommy
> Cc: php-general
lists.php.net
> Subject: Re: [PHP] script
>
>
> http://php.net/time
> http://php.net/date
> http://php.net/mktime
>
>
> one or a combination of these functions will help you do what
> you want.
>
> HTH
> On Apr 19, 2005, at 6:37 PM, tommy wrote:
>
> > I'm hoping someone on this list can help me with something
> I've been
> > struggling with lately...
> >
> > I have a php based web page that I'd like to have load an
> include file
> > only when it is Tuesday 11pm - Weds 1 am Eastern Standard
> time (USA).
> > At other times I would like my page to load and alternate include
> > file.
> >
> > If someone could help me with the code or point me in the right
> > direction it would be very appreciated.
> >
> > Thanks.
> >
> > Tommy.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> *********
> Stephen Johnson
> stephen
thelonecoder.com
> http://www.thelonecoder.com
>
> --continuing the struggle against bad code--
> *********
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
* Jem777 <camillo
rockit.it>:
> If I submit a post and then, serverside, I redirect the request to another
> page, do the post variables still live in the new page?
No. HTTP requests are stateless, meaning they have no memory of what
requests happened before or after, or how those requests were made. PHP
does not affect that behaviour at all; it's entirely a matter of the
HTTP protocol.
If you want the POST variables to propogate to the redirected page, use
a session.
--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:matthew
garden.org | http://vermontbotanical.org
attached mail follows:
* Craig Donnelly <craig
deconstructor.net>:
> I had an issue that I needed to be able to go back in the browser while in a
> session without getting "page has expired", I was reading through the manual
> and came across a comment about adding the following to the sessions page to
> allow users to traverse back:
>
> header("Cache-control: private");
> (http://www.php.net/manual/en/function.session-start.php)
>
> This works fine on a Win32 dev box running Apache 1.3.x and PHP 5.0.3, but
> then I loaded the pages onto a RedHat box running PHP 5.0.3 on Apache
> 1.3.27. This box is running these pages through SSl (https)
>
> Anyone any ideas?
This is a standard issue with browsers and the HTTP protocol. POST
operations are supposed to contain dynamic data, and thus, by their very
nature, pages returned from such a request are supposed to contain
content that should rightfully expire.
Of course, in many situations, this expiring is not desired.
Basically, you have to fool the browser into thinking that the way you
got to the page was NOT via a POST operation. One standard way of doing
this is to have a middle page that processes the POST request, stores
some relevant information, and redirects to the final page that displays
the results. Hitting the back button in this scenario takes you back to
the first page.
Chris Shifflet has a great tutorial on this; google for his name and
'page expired'.
--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:matthew
garden.org | http://vermontbotanical.org
attached mail follows:
On Tue, April 19, 2005 9:26 am, Craig Donnelly said:
> I had an issue that I needed to be able to go back in the browser while in
> a
> session without getting "page has expired", I was reading through the
> manual
> and came across a comment about adding the following to the sessions page
> to
> allow users to traverse back:
>
> header("Cache-control: private");
> (http://www.php.net/manual/en/function.session-start.php)
>
> This works fine on a Win32 dev box running Apache 1.3.x and PHP 5.0.3, but
> then I loaded the pages onto a RedHat box running PHP 5.0.3 on Apache
> 1.3.27. This box is running these pages through SSl (https)
Presumably you want the user to *NOT* be able to go back...
Different browsers, and different versions of different browsers, require
different headers, because they are following different "standards" or, in
some cases, not really following different standards.
You'll have to Google around and find all the headers about Expiration,
Cache-control, Pragma, and then add them all in, like a good stew, and
test and re-test until you find the ones that end up making all the
browsers you care about behave the way you want.
It would be nice if there were just *ONE* standard for this, that all the
browsers, past, present, and future, followed. There isn't.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Thank you, Richard,
I simply change this part
(select * from openart_table) into
(select substring(loc1, 1, 3) as THREE_LETTER_CODE, * from openart_table)
but Ive got this error, whats wrong with it?
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in c:\apache......\openart\test\openart_search.php on line 98
Records Found
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in c:\apache....\openart\test\openart_search.php on line 100
Cheers
attached mail follows:
On Wednesday 20 April 2005 06:07, Sugimoto wrote:
> Thank you, Richard,
>
> I simply change this part
> (select * from openart_table) into
> (select substring(loc1, 1, 3) as THREE_LETTER_CODE, * from openart_table)
> but Ive got this error, whats wrong with it?
>
> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
> resource in c:\apache......\openart\test\openart_search.php on line 98
> Records Found
Why don't you try the query in the mysql console? You'll see what it returns
and debug the error easily.
>
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
> resource in c:\apache....\openart\test\openart_search.php on line 100
>
> Cheers
--
Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)
PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQBCZfq9LT98C3rkVDYRAgmZAJ0WcCjZlz45e5W+fWg3cbf0WXmsYQCeMUn/
x9LZQ7YtJXD0Mpj5Jxil5uY=
=6TAB
-----END PGP SIGNATURE-----
attached mail follows:
I think that in your database it is :
substring(loc, 1, 3) as loc1
Anyway, the error is not where you are getting the message, the query failed
and this you don't have a valid resource to ask the number of rows or do
anything else. You should add an 'or die("message: " . mysql_error()) to
your query to trap the error.
Satyam
"Sugimoto" <sugimoto
momat.go.jp> wrote in message
news:005301c54556$29488650$d405a8c0
sugimoto...
> Thank you, Richard,
>
> I simply change this part
> (select * from openart_table) into
> (select substring(loc1, 1, 3) as THREE_LETTER_CODE, * from openart_table)
> but Ive got this error, whats wrong with it?
>
> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
> resource in c:\apache......\openart\test\openart_search.php on line 98
> Records Found
>
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
> result
> resource in c:\apache....\openart\test\openart_search.php on line 100
>
> Cheers
attached mail follows:
Hi there i was wondering if there is such an extension available or
possbility to have a dynamicclass loader extension which would use the request_uri as loading the
class constructors ? I justthink building such a thing in php which is what i am doing too slow for
each request and think itshould happen in the internals ? Let me know if its an insane idea.
attached mail follows:
On Tue, April 19, 2005 8:28 pm, php
electroteque.org said:
> Hi there i was wondering if there is such an extension available or
> possbility to have a dynamicclass loader extension which would use the
> request_uri as loading the
> class constructors ? I justthink building such a thing in php which is
> what i am doing too slow for
> each request and think itshould happen in the internals ? Let me know if
> its an insane idea.
I don't quite see how:
<?php
require "bloated_class.inc";
?>
can be sped up much...
The problem isn't in the require function, but in the Class source bloat...
But maybe I'm just being stoopid.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On 20/04/2005, at 2:52 PM, Richard Lynch wrote:
>
> I don't quite see how:
>
> <?php
> require "bloated_class.inc";
> ?>
>
> can be sped up much...
>
> The problem isn't in the require function, but in the Class source
> bloat...
>
> But maybe I'm just being stoopid.
>
>
First thing first, I am sure you are not new to the list and so arent
I but dont try and reply unless you have something useful to say. Ok
let me explain myself, I store my classes in classes/ , I use a
request_uri of thepackage/theclass/thesubclass will load currently the
class in question thepackage_theclass_thesubclass. I am just testing
things atm and asking if something has already been achieved in the
extension layer, as i'd prefer to reduce the ammount of interface
scripts.
attached mail follows:
php
electroteque.org wrote:
> Hi there i was wondering if there is such an extension available or
> possbility to have a dynamicclass loader extension which would use the request_uri as loading the
> class constructors ? I justthink building such a thing in php which is what i am doing too slow for
> each request and think itshould happen in the internals ? Let me know if its an insane idea.
PHP5 provides autoload, see
http://at2.php.net/manual/en/language.oop5.autoload.php for details.
HTH
attached mail follows:
On Wednesday 20 April 2005 06:28, php
electroteque.org wrote:
> Hi there i was wondering if there is such an extension available or
> possbility to have a dynamicclass loader extension which would use the
> request_uri as loading the class constructors ? I justthink building such a
> thing in php which is what i am doing too slow for each request and think
> itshould happen in the internals ? Let me know if its an insane idea.
Use the autoload extension.
http://www.php.net/manual/en/language.oop5.autoload.php
Have in mind the exception case when loading an unexisting class definition.
--
Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)
PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQBCZftPLT98C3rkVDYRAv+nAJ9NiEIoSaSfhL9mJeOMikBC+KoySQCglzHC
4VwGcTImCOyVXiMwv4UK2b8=
=KuWl
-----END PGP SIGNATURE-----
attached mail follows:
Thanks this seemed to work except say you had a class
Packagename_Classname
its trying to load the file like that Packagename_Classname.php
On 20/04/2005, at 4:23 PM, Markus Fischer wrote:
> php
electroteque.org wrote:
>> Hi there i was wondering if there is such an extension available or
>> possbility to have a dynamicclass loader extension which would use
>> the request_uri as loading the
>> class constructors ? I justthink building such a thing in php which
>> is what i am doing too slow for
>> each request and think itshould happen in the internals ? Let me know
>> if its an insane idea.
>
> PHP5 provides autoload, see
> http://at2.php.net/manual/en/language.oop5.autoload.php for details.
>
>
attached mail follows:
Dan Rossi wrote:
> Thanks this seemed to work except say you had a class Packagename_Classname
>
> its trying to load the file like that Packagename_Classname.php
Well, you can put whatever logic you need into the autoload function.
It's up to you.
HTH
attached mail follows:
On Tue, April 19, 2005 7:39 am, The Disguised Jedi said:
> Is there a quick way to convert a TIFF format picture to a GIF quickly? I
I'm reasonably certain you can get GD to read TIFF files, if you install
TIFF on your server, and then the GD extension again...
Start reading at http://php.net/gd to be sure.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Hi,
Wednesday, April 20, 2005, 12:39:54 AM, you wrote:
TDJ> Is there a quick way to convert a TIFF format picture to a GIF quickly? I
TDJ> can only find support for GIFs in PHP, but maybe I'm missing something. I
TDJ> have a client running a photography business, and I have designed an image
TDJ> watermark and resizing engine, and a server to check the request, serve the
TDJ> file, and then delete it. I mainly made this to help him run the site
TDJ> himself, since he isn't very good with Photoshop, and can't watermark the
TDJ> images (I shouldn't say that...he probably could, but not very fast....but
TDJ> anyway...).
TDJ> This is all working fine and dandy, but the system will only accept GIF
TDJ> format. His images are all raw scans in TIFF format. This means that he has
TDJ> to open the image in Photoshop, resize it, and convert it to a GIF. I think
TDJ> he can do this himself, but I'd like to make it even simpler, which is why
TDJ> I'm writing.
TDJ> I need a quick way, preferably in PHP, but it doesn't have to be, to
TDJ> convert large batches of TIFF format images to GIF. Does anyone know of a
TDJ> way to do this?
TDJ> Thanks for reading, and for your responses in advance...
I use netpbm for conversion to png from tiffs and windows bitmaps like this:
//$tempname from fileupload tmpname
//$file from fileupload name
$jobpath = '/wherever/you/want/files/stored';
if($im = getimagesize($tempname)){
if($im[0] > 0){
//cleanup filename
$file = ereg_replace("'","",$file);
$file = ereg_replace("%20","_",$file);
$file = ereg_replace(" ","_",$file);
$ext =
substr($file, (
strrpos($file, ".") ?
strrpos($file, ".") + 1 :
strlen($file)),
strlen($file));
$fname = basename($file,$ext);
switch(intval($im[2])){
case 7:
case 8:
//force a tif extension for netpbm
$tfilename = $jobpath.'/'.$fname.'tif';
move_uploaded_file($tempname, $tfilename);
$file = $fname.'png';
$filename = $jobpath.'/'.$file;
shell_exec ("/path/to/netpbm/bin/tifftopnm -quiet $tfilename | /path/to/netpbm/bin/pnmtopng > $filename");
break;
case 6:
//force a bmp extension for netpbm
$tfilename = $jobpath.'/'.$fname.'bmp';
move_uploaded_file($tempname, $tfilename);
$file = $fname.'png';
$filename = $jobpath.'/'.$file;
shell_exec ("/path/to/netpbm/bin/bmptoppm -quiet $tfilename | /path/to/netpbm/bin/pnmtopng > $filename");
break;
default:
$filename = $jobpath.'/'.$file;
move_uploaded_file($tempname, $filename);
break;
}
}
}
--
regards,
Tom
attached mail follows:
On Tue, April 19, 2005 7:03 am, Jochem Maas said:
> The 'other' guy mentioned that while() is faster than foreach,
> is this true?
Don't know ; Don't care.
You should never loop through so many things in PHP that it matters in the
first place :-)
> I read a few days ago somewhere on php.net that foreach() is the
> recommended (by php devs) way of iterating over arrays....
[shrug]
That's probably because they're tired of people not understanding the
internal pointer array, and asking FAQs about it. Or maybe not. Ask them
why they prefer it. I sure don't know.
> also, compare these 2 lines:
>
> while (list(, $idcat) = each($idcats)){ /* ... */ }
> foreach ($idcats as $idcat){ /* ... */ }
>
> now its seems to me that the foreach version is 'up' 2 function calls
None of those are function calls.
They are all language constructs. Okay, each() *might* be a function...
I'm not sure how much difference there is in the number of language
constructs used, nor if they are even comparable in sheer numbers the way
functions are.
foreach is probably slower, I think, because it creates a *copy* of the
array to work on, so it won't mess up the original and its internal
pointer.
Again, with 200 bytes, you are wasting your time to worry about any of this.
> on the while loop, all else being equal the foreach loop has to be faster
> (given that calling functions is relatively very expensive)...
> or is foreach() _really_ heavy when compared to while()?
Why don't you just benchmark it on your own machine and find out?
> not that I care too much, I find foreach() more pleasing to the eye and
> there is
> less to type (in the given example).
I'm an old dog, and I don't quite understand for sure how this new-fangled
foreach thingie works. I'd spend more time looking it up and reading
about it than just typing what I *know* works. [shrug]
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Tue, April 19, 2005 2:13 am, Martin Mandl said:
> Therefore (finally) here come the questions:
> Is there a way to control the output speed of the php script according
> to the actual download speed between the browser and the server?
> Or is there a way to monitor the memory usage of the apache process (to
> slow down the data output when it increases)?
> Or is writing my own socket to act as web server a solution (is it
> possible to monitor the connection speed this way)?
> Or what should I do else?
Perhaps you should consider making the files available via FTP.
And perhaps even in, say, 10Meg chunks, using command line split.
Cuz if I have to download 100Meg through HTTP over a modem, I ain't gonna
do it.
Also consider this: If the end goal of your user is to put this file
somewhere else, on another server, maybe give dial-up users the option of
not downloading it at all, but give them an SSL page to put in one-time
throw-away never-stored username/password/domain/path and their choice of
FTP, SCP, SFTP and then *you* copy the file from your server to their
server for them.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Thank you very much, I do appreciate your help.
Ur script doens work, but, curiously, it works when I changed a bit...
select left(loc1,3) as locx, openart_id, tit1, pub1, id1, ref1 from
openart_table
If possible, can I ask one more thing?
This part is the problem
<A HREF="/momatlib/image/<? echo $row["locx"]; ?>.jpg"><? echo
$row["locx"]; ?></A>
I got 3 letters, but I would like to show all "loc1" data (eg "1-2 near
entrance") in the table, and have first 3 letters of "loc1" for jpg
hyperlink (http://www.heyjude.com/image/1-2.jpg).
Do you know how to fix this?
----script------------------
$result = mysql_query("select left(loc1,3) as locx, openart_id, tit1, pub1,
id1, ref1 from openart_table
where tit1 like '%$tit%'
and res1 like '%$res%'
and pub1 like '%$pub%'
and date1 like '%$date%'
and id1 like '%$id%'
and ref1 like '%$ref%'
and loc1 like '%$loc%'
and type1 like '%$type%'
and vol1 like '%$vol%'
and fre1 like '%$fre%'
and note1 like '%$note%' order by tit1");
$rows = mysql_num_rows($result);
echo $rows,"Record Found <p>";
while($row = mysql_fetch_array($result)){
?>
<tr>
<td><a href = "openart_detail.php ?iden=<? echo $row["openart_id"] ?>"><?
echo $row["openart_id"]; ?></a><br></td>
<td><? echo $row["tit1"]; ?><br></td>
<td><? echo $row["pub1"]; ?><br></td>
<td><? echo $row["id1"]; ?><br></td>
<td><? echo $row["ref1"]; ?><br></td>
<td>
<A HREF="/momatlib/image/<? echo $row["locx"]; ?>.jpg"><? echo
$row["locx"]; ?>
</A><br>
</td>
</tr>
attached mail follows:
Why not try selecting both the short and the full values of loc1 from
the database? Then you can display them both in the html output.
Select loc1, left(loc1,3) as locx, etc
Have I missed your point here?
Mark
-----Original Message-----
From: Sugimoto [mailto:sugimoto
momat.go.jp]
Sent: 20 April 2005 08:15
To: PHP ML
Subject: [PHP] One more time (Duft Punk) about hyperlink
Thank you very much, I do appreciate your help.
Ur script doens work, but, curiously, it works when I changed a bit...
select left(loc1,3) as locx, openart_id, tit1, pub1, id1, ref1 from
openart_table
If possible, can I ask one more thing?
This part is the problem
<A HREF="/momatlib/image/<? echo $row["locx"]; ?>.jpg"><? echo
$row["locx"]; ?></A>
I got 3 letters, but I would like to show all "loc1" data (eg "1-2 near
entrance") in the table, and have first 3 letters of "loc1" for jpg
hyperlink (http://www.heyjude.com/image/1-2.jpg).
Do you know how to fix this?
----script------------------
$result = mysql_query("select left(loc1,3) as locx, openart_id, tit1,
pub1, id1, ref1 from openart_table
where tit1 like '%$tit%'
and res1 like '%$res%'
and pub1 like '%$pub%'
and date1 like '%$date%'
and id1 like '%$id%'
and ref1 like '%$ref%'
and loc1 like '%$loc%'
and type1 like '%$type%'
and vol1 like '%$vol%'
and fre1 like '%$fre%'
and note1 like '%$note%' order by tit1");
$rows = mysql_num_rows($result);
echo $rows,"Record Found <p>";
while($row = mysql_fetch_array($result)){
?>
<tr>
<td><a href = "openart_detail.php ?iden=<? echo $row["openart_id"]
?>"><? echo $row["openart_id"]; ?></a><br></td>
<td><? echo $row["tit1"]; ?><br></td>
<td><? echo $row["pub1"]; ?><br></td>
<td><? echo $row["id1"]; ?><br></td>
<td><? echo $row["ref1"]; ?><br></td>
<td>
<A HREF="/momatlib/image/<? echo $row["locx"]; ?>.jpg"><? echo
$row["locx"]; ?>
</A><br>
</td>
</tr>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, Cisco, Sun Microsystems, 3Com
GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 2000' REGISTERED COMPANY
**********************************************************************
CONFIDENTIALITY NOTICE:
This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.
GENERAL STATEMENT:
Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order, subject to our Terms and Conditions available from http://www.gammaglobal.com
E&OE
**********************************************************************
**********************************************************************
attached mail follows:
Hello,
I have txt file "text.txt" that contains:
line1:one
line2:two
line3:three
line4:
Line 4 contains empty string.
If I use f*() functions to read from the file:
$handle=fopen("text.txt","r");
while (!feof($handle)) echo("-".chop(fgets($handle))."-<BR>");
fclose($handle);
the RESULT will be:
-one-
-two-
-three-
--
I gzipped the file using ZLIB functions.
If I use gz*() function to read from the gzip file:
$handle=gzopen("text.txt.gz","r");
while (!gzeof($handle)) echo("-".chop(gzgets($handle))."-<BR>");
gzclose($handle);
the RESULT will be:
-one-
-two-
-three-
SEE? The last (empty) line is not returned .
What am I doing wrong?
OKi98
- application/pgp-signature attachment: OpenPGP digital signature
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]