php-general Digest 28 Sep 2003 23:18:45 -0000 Issue 2324

Topics (messages 164158 through 164181):

where are the good examples of using OOP?
        164158 by: anders thoresson
        164160 by: Burhan Khalid
        164165 by: Eugene Lee
        164168 by: Robert Cummings
        164177 by: Daevid Vincent

Re: Submit button
        164159 by: Eugene Lee
        164162 by: Karina S
        164164 by: Nitin
        164166 by: Eugene Lee
        164180 by: Chris Shiflett

Dwonload with PHP do not work..
        164161 by: Ms Carlsson
        164167 by: Boaz Yahav

Re: IIS Ports
        164163 by: Burhan Khalid

checked / unchecked
        164169 by: phpu
        164173 by: phpu

Re: SQL statement
        164170 by: sfdgfg

array_multisort ... unsupported in different builds?
        164171 by: john
        164172 by: Jason Wong
        164174 by: john

$php_as_cgi == "error";
        164175 by: Ms Carlsson
        164179 by: Marek Kilimajer

gettext: changed .mo file, caching issue
        164176 by: daniel hahler

fgets prob... !?
        164178 by: mArK

Re: Search Submission Tool
        164181 by: Erich Kolb

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

I'm just about to take the first step into OOP with PHP. I've searched the web for tutorials, and even if there are alot, most of them use metaphores with houses or cars or other real life things to explain what classes and methods are.

I wonder if someone can point me to tutorials that uses real PHP examples instead, examples that shows me in a direct way how to use OOP. My biggest trouble right now is what should be the classes and what should be the methods.

Also, I wonder if someone could name a blog-application och web album-application that uses OOP in a good way and which I can have a look at to see how things are done.

Best regards,

--
anders thoresson

--- End Message ---
--- Begin Message --- anders thoresson wrote:

I'm just about to take the first step into OOP with PHP. I've searched the web for tutorials, and even if there are alot, most of them use metaphores with houses or cars or other real life things to explain what classes and methods are.

http://pear.php.net http://www.phpclasses.org

Both of these have excellent scripts that are OOP based.

I wonder if someone can point me to tutorials that uses real PHP examples instead, examples that shows me in a direct way how to use OOP. My biggest trouble right now is what should be the classes and what should be the methods.

As a general rule, a class is anything that can be an /object/ or a /thing/. Methods are things you can do to it.


Also, I wonder if someone could name a blog-application och web album-application that uses OOP in a good way and which I can have a look at to see how things are done.

A good OOP application for community websites is Drupal - www.drupal.org


--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com

--- End Message ---
--- Begin Message ---
On Sun, Sep 28, 2003 at 12:52:40PM +0200, anders thoresson wrote:
: 
:  I wonder if someone can point me to tutorials that uses real PHP examples 
: instead, examples that shows me in a direct way how to use OOP. My biggest 
: trouble right now is what should be the classes and what should be the 
: methods.

Objects should try to model a real thing.  A thing may have properties
(e.g. weight, color, dimensions, temperature, gender, age) and/or states
(e.g. solid/liquid/gas, running/ready/waiting, eating/sleeping/working);
properties are stored in instance variables.  And the thing can do tasks
or have tasks done to them; these tasks are your methods.

Here's a simple exercise you can do: make a "watch" class that models a
real watch.  You can get the current time from a watch; and you can also
set the watch's time.  This class should have 3 methods (i.e. 2 methods
and 1 constructor) and 1 instance variable.  If you use Unix timestamps,
this should be really short (maybe around 10 lines of PHP code).

--- End Message ---
--- Begin Message ---
On Sun, 2003-09-28 at 07:09, Burhan Khalid wrote:
> anders thoresson wrote:
> 
> >  I'm just about to take the first step into OOP with PHP. I've searched 
> > the web for tutorials, and even if there are alot, most of them use 
> > metaphores with houses or cars or other real life things to explain what 
> > classes and methods are.
> 
> http://pear.php.net
> http://www.phpclasses.org
> 
> Both of these have excellent scripts that are OOP based.

(shameless plug) http://www.interjinn.com

The whole framework is OOP.

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 ---
--- Begin Message ---
http://daevid.com/examples/dhcp/index.php

Was my first try with php's OOP. Source linked at bottom of page.

> -----Original Message-----
> From: anders thoresson [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, September 28, 2003 3:53 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] where are the good examples of using OOP?
> 
> 
> Hi,
> 
>   I'm just about to take the first step into OOP with PHP. 
> I've searched 
> the web for tutorials, and even if there are alot, most of them use 
> metaphores with houses or cars or other real life things to 
> explain what 
> classes and methods are.
> 
>   I wonder if someone can point me to tutorials that uses 
> real PHP examples 
> instead, examples that shows me in a direct way how to use 
> OOP. My biggest 
> trouble right now is what should be the classes and what 
> should be the 
> methods.
> 
>   Also, I wonder if someone could name a blog-application och web 
> album-application that uses OOP in a good way and which I can 
> have a look 
> at to see how things are done.
> 
>   Best regards,
> 
> -- 
> anders thoresson
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
On Sun, Sep 28, 2003 at 12:49:27PM +0200, Karina S wrote:
: 
: I want to use an image as submit button on my form. Now I use the following
: code with button:
: 
:   if (!(isset($_Post['SubmitForm'])))
:   {
:     .......
:     .....
:      <input type="submit" name="SubmitForm" value="Submit">
:     }
: else
: {
:     .....
: }
: 
: Is it possible to change the Submit button with an image?

Yep.  It's a feature of HTML.

        <input name="SubmitForm" type="image" src="image.gif" alt="SubmitForm">

Note that the x,y coordinates of where you clicked on the image gets
submitted as "SubmitForm.x" and "SubmitForm.y", so watch out for the
existence of these variables.

--- End Message ---
--- Begin Message ---
I have changed the code, but it doesn't work.

 if (!(isset($_Post['SubmitForm_x'])))
  {
    .......
    .....
     <input name="SubmitForm" type="image" src="image.gif" alt="SubmitForm">
    }
else
{
    .....
}


"Eugene Lee" <[EMAIL PROTECTED]> az alábbiakat írta a következo üzenetben
news:[EMAIL PROTECTED]
> On Sun, Sep 28, 2003 at 12:49:27PM +0200, Karina S wrote:
> :
> : I want to use an image as submit button on my form. Now I use the
following
> : code with button:
> :
> :   if (!(isset($_Post['SubmitForm'])))
> :   {
> :     .......
> :     .....
> :      <input type="submit" name="SubmitForm" value="Submit">
> :     }
> : else
> : {
> :     .....
> : }
> :
> : Is it possible to change the Submit button with an image?
>
> Yep.  It's a feature of HTML.
>
> <input name="SubmitForm" type="image" src="image.gif" alt="SubmitForm">
>
> Note that the x,y coordinates of where you clicked on the image gets
> submitted as "SubmitForm.x" and "SubmitForm.y", so watch out for the
> existence of these variables.

--- End Message ---
--- Begin Message ---
You can always use:

<img src="image.gif" alt="Submit" onClick=document.entry.submit()>

Try it and enjoy
Nitin

--- End Message ---
--- Begin Message ---
On Sun, Sep 28, 2003 at 01:20:32PM +0200, Karina S wrote:
: 
: I have changed the code, but it doesn't work.
: 
:  if (!(isset($_Post['SubmitForm_x'])))
:   {
:     .......
:     .....
:      <input name="SubmitForm" type="image" src="image.gif" alt="SubmitForm">
:     }
: else
: {
:     .....
: }

1. The superglobal array is $_POST (all caps), not $_Post.

2. Make sure the URL path to your image file is correct, i.e. change
"image.gif" to the relative or absolute URL.

3. The "alt" attribute is technically unneeded.

4. When in doubt:

        print_r($_POST);

--- End Message ---
--- Begin Message ---
--- Nitin <[EMAIL PROTECTED]> wrote:
> <img src="image.gif" alt="Submit" onClick=document.entry.submit()>

This is a great example of what not to do.

Use <input type="image"...

Chris

--- End Message ---
--- Begin Message ---
$file = "/home/xxxx/openssh-3.6.1p1.tar.gz";
$mb = filesize($file);
$download = "openssh-3.6.1p1.tar.gz";

$fp = fopen($file, "r");

         Header ( "HTTP/1.1 206 One resume, coming up!" );
         Header ( "Pragma: no-cache" );
         Header ( "Content-Type: application/octet-stream" );
         Header ( "Content-Length: ".filesize("$file") );
         Header ( "Content-Disposition: attachment; filename=$download" )$

         readfile("/home/xxxx/openssh-3.6.1p1.tar.gz");
         exit;




THis start a download but give me a corrupted downloaded file... Any help out here......

_________________________________________________________________
Lättare att hitta drömresan med MSN Resor http://www.msn.se/resor/

--- End Message ---
--- Begin Message ---
Try this :

How to let a user download a picture by clicking on it instead of needing to right 
click and Save-As.
http://www.weberdev.com/get_example.php3?count=1562

How to force the user to download a file instead of opening it up in an controlled 
environment within the browser (i.e. MS Word/Adobe Acrobat)
http://www.weberdev.com/get_example.php3?count=1627

Sincerely
 
berber
 
Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.
Share your code : http://addexample.weberdev.com
Search for PHP Code from your browser http://toolbar.weberdev.com


-----Original Message-----
From: Ms Carlsson [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 28, 2003 1:13 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Dwonload with PHP do not work..


$file = "/home/xxxx/openssh-3.6.1p1.tar.gz";
$mb = filesize($file);
$download = "openssh-3.6.1p1.tar.gz";

$fp = fopen($file, "r");

          Header ( "HTTP/1.1 206 One resume, coming up!" );
          Header ( "Pragma: no-cache" );
          Header ( "Content-Type: application/octet-stream" );
          Header ( "Content-Length: ".filesize("$file") );
          Header ( "Content-Disposition: attachment; filename=$download" )$

          readfile("/home/xxxx/openssh-3.6.1p1.tar.gz");
          exit;




THis start a download but give me a corrupted downloaded file... Any help out 
here......

_________________________________________________________________
Lättare att hitta drömresan med MSN Resor http://www.msn.se/resor/

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

 


--- End Message ---
--- Begin Message --- Jon Kriek wrote:
The point is get a "good" firewall, doesn't matter which one.

Personally I prefer Sygate Personal Firewall PRO
http://smb.sygate.com/products/pspf/pspf_ov.htm


Enabling ICF will probably help.




--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com

--- End Message ---
--- Begin Message ---
Hi
I have this form:

 <form action="modify.php" method="POST" enctype="multipart/form-data">
<?
$sql = "SELECT * FROM table Where id_cat=".$_POST['id_cat']; 
$result = mysql_query($sql); 
while ($row=mysql_fetch_array($result))
{

print 'Category<input type="text" name="nume_categorie" 
value="'.$row['category_name'].'"><br>Picture
<input name="modify_picture" type="checkbox" id="modify_picture" value="check">';
}
?>
<input name="submit" type="submit" value="Modify">
</form>


All i wanna do is to modify picture only if the modify_picture checkbox is checked. 
How can i do that?

thanks

--- End Message ---
--- Begin Message ---
It's working..
Thanks a lot

----- Original Message -----
From: "Jason Sheets" <[EMAIL PROTECTED]>
To: "phpu" <[EMAIL PROTECTED]>
Sent: Sunday, September 28, 2003 6:55 PM
Subject: Re: [PHP] checked / unchecked


> With a conditional, note that if you have more than one picture your
> current setup is not going to work.
>
> if ($_REQUEST['modify_picture'] == 'check') {
>     // do update code here
> }
>
> If you will ever have more than one picture at a time you should
> probably use an array instead of just one variable for modify_picture.
>
> Jason
>
> phpu wrote:
>
> >Hi
> >I have this form:
> >
> > <form action="modify.php" method="POST" enctype="multipart/form-data">
> ><?
> >$sql = "SELECT * FROM table Where id_cat=".$_POST['id_cat'];
> >$result = mysql_query($sql);
> >while ($row=mysql_fetch_array($result))
> >{
> >
> >print 'Category<input type="text" name="nume_categorie"
value="'.$row['category_name'].'"><br>Picture
> ><input name="modify_picture" type="checkbox" id="modify_picture"
value="check">';
> >}
> >?>
> ><input name="submit" type="submit" value="Modify">
> ></form>
> >
> >
> >All i wanna do is to modify picture only if the modify_picture checkbox
is checked. How can i do that?
> >
> >thanks
> >
> >
> >
>
>

--- End Message ---
--- Begin Message --- Curt Zirzow wrote:
* Thus wrote Dan J. Rychlik ([EMAIL PROTECTED]):

Well,  we have a word for myself that over looks things and takes things
literal.  Its called "pencil smoke"  It means dump, dunce, and lost.

Jennifer was right, their was an error in my SQL query.


technically it was an error in the code not the query.


SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y')
as timestamp FROM custlogon;

not as formatted_ts.....

It worked fine even on zeus it tested fine.


Glad to hear it worked.  For future reference, however, it can be a lot
easier to help you if you could provided some essential information
about your problem, some things to keep in mind:

  - What is the error message.
  - Show some code that surrounds the line number in the error.
  - If a variable is causing  the problem, explain how that variable
    gets assigned.


So, If you would have posted a message something like:


---
  I get this error in my php script:

  Notice: Undefined index: timestamp in C:\Program Files\Apache
  Group\Apache2\htdocs\Ameriforms\admintool\includes\getlogonhist.php on line
  44

  My line 44 looks like this:
    <?php echo $row['timestamp'];?></font></td>

  The variable $row is filled in from a mysql_fetch_assoc() call And the query
  I'm executing is like this:

SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') FROM custlogon
---


So instead of 21 emails sent back and forth with trial and errors.
The problem would have been easily solved.

HTH,

Curt

--- End Message ---
--- Begin Message ---
ok, heres the thing

short version;
array_multisort works on localhost but when i upload it, ceases to work (array is left 
unsorted)

long version;
i have array_multisort sorting a multi dimensional array with sort_asc. i understand 
that it sorts by the first index by default. on my localhost (iis on xp, php4.3.3) it 
works perfectly sorting the whole array based on the first row, but when i upload the 
code to the online webserver the array_multisort does nothing. no sorting is taking 
place, its as though the line is being skipped, but its not in the middle of an if 
statement or any other possible means of being skipped logically. ive tried uploading 
this on a both a 4.3.3 server and a 4.3.2 with the same result.

i started off with just listing the parts of the array, eg array(something, something 
else, blah) so it assigns index numbers. then as part of updating various things i 
changed that to set the indexes myself, eg array(indexname => something, index2 
=>somethingelse) etc. it was working online before so ive tried putting just the first 
row as non-assigned index, and going back to number indexes for the whole lot, and no 
dice.

can anyone suggest why this would work fine on my machine and yet cease to function on 
another server of the same version? im completely at a loss and p***ed off.

tia
john

--- End Message ---
--- Begin Message ---
On Monday 29 September 2003 00:12, john wrote:

> short version;
> array_multisort works on localhost but when i upload it, ceases to work
> (array is left unsorted)

[snip]

Could you post a concise example which illustrates your problem?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
You can fool all the people all of the time if the advertising is right
and the budget is big enough.
                -- Joseph E. Levine
*/

--- End Message ---
--- Begin Message ---
umm.. yeah. i wrote out this example below to paraphrase my code and it
worked perfectly both localhost and online. so then i got really p***ed =)

i did some more looking and i realised its actually caused by a session
interference... panic over =) ive been wondering wtf was the deal was with
this for days! it seems the servers online handle sessions differently from
my localhost, i only thought to look for session related issues because its
been causing odd results elsewhere too. i guess that will teach me to be lax
with sessions. unsetting the session before redefining them them cured the
other one, and cured this too. thanks for prompting me to find it,
indirectly =)


$i = array(3, 2, 5, 1, 4);
$hate = array(stuff3, stuff2, stuff5, stuff1, stuff4);
$dodgy = array(blah3, blah2, blah5, blah1, blah4);
$problems = array(meh3, meh2, meh5, meh1, meh4);

for ( $tick = 1; $tick < 4; $tick++ ) {

 $i_each = $i[$tick];
 $hate_each = $hate[$tick];
 $dodgy_each = $dodgy[$tick];
 $problems_each = $problems[$tick];

 $slack[] = array(i => $i_each, hate => $hate_each, dodgy => $dodgy_each,
problems => $problems_each);

}

array_multisort($slack, SORT_ASC);

echo $slack[0][i]."<br>";
echo $slack[0][hate]."<br>";
echo $slack[0][dodgy]."<br>";
echo $slack[0][problems]."<br>";

result;
1
stuff1
blah1
meh1





----- Original Message ----- 
From: "Jason Wong" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, 29 September, 2003 2:17 AM
Subject: Re: [PHP] array_multisort ... unsupported in different builds?


> On Monday 29 September 2003 00:12, john wrote:
>
> > short version;
> > array_multisort works on localhost but when i upload it, ceases to work
> > (array is left unsorted)
>
> [snip]
>
> Could you post a concise example which illustrates your problem?
>
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> You can fool all the people all of the time if the advertising is right
> and the budget is big enough.
> -- Joseph E. Levine
> */
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message --- Hello this does not work with apache + suexec and php running like cgi

#!/usr/local/bin/php

# in top of all php scripts
<?
   header("Content-Disposition: attachment; filename=$filename");
   header("Content-Type: application/octet-stream");
   header("Content-Length: ".filesize("$path/$filename"));
     header("Pragma: no-cache");
     header("Expires: 0");
   $fp=fopen("$path/$filename","r");
   print fread($fp, filesize("$path/$filename"));
   fclose($fp);
   exit();

?>

the file downloads but when open i get an error but when i try the same script on a machine with apache + php as a built in module it works, why does this ot work when access the script as cgi with apache + suxex ??

_________________________________________________________________
Hitta rätt på nätet med MSN Sök http://search.msn.se/

--- End Message ---
--- Begin Message --- Open the file in a text editor and check if there is any php warning/error showing up.

Ms Carlsson wrote:
Hello this does not work with apache + suexec and php running like cgi

#!/usr/local/bin/php

# in top of all php scripts
<?
   header("Content-Disposition: attachment; filename=$filename");
   header("Content-Type: application/octet-stream");
   header("Content-Length: ".filesize("$path/$filename"));
     header("Pragma: no-cache");
     header("Expires: 0");
   $fp=fopen("$path/$filename","r");
   print fread($fp, filesize("$path/$filename"));
   fclose($fp);
   exit();

?>

the file downloads but when open i get an error but when i try the same script on a machine with apache + php as a built in module it works, why does this ot work when access the script as cgi with apache + suxex ??

_________________________________________________________________
Hitta rätt på nätet med MSN Sök http://search.msn.se/


--- End Message ---
--- Begin Message ---
Hello php-general,

I init gettext with
   putenv('LANGUAGE='.$language);
   putenv('LANG='.$language);
   // Specify location of translation tables 
   bindtextdomain ("messages", "./locale"); 
   // Choose domain 
   textdomain ("messages");
where $language is either "de" or "en".

This works good, but if the .mo file gets changed the old content is
returned by calls to gettext, until I restart Apache.
This is with my local server.

On the remote server, where I upload the files there is even no
translation ATM, although there already has been some.

my local server is:
   Apache 1.3.27
   PHP 4.3.3
   LoadModule php4_module c:/www/php/sapi/php4apache.dll

remote server is also Apache/1.3.27 (Linux/SuSE) PHP/4.3.3
mod_perl/1.27

Any solutions?


-- 
shinE!
http://www.thequod.de ICQ#152282665
Dj Sosse - Summerscream II rocks. 

--- End Message ---
--- Begin Message ---
H!

I have this segment of script...

...
$resp = fgets( $sock, 512 );
echo $resp;
...

the output must be:
[EMAIL PROTECTED]

but here came php and take the 3 "#" and convert
they in only one "#", and the output currently is:

[EMAIL PROTECTED]

How I say to php: "STOP", leave my "#" in peace?
--
____
mArk

--- End Message ---
--- Begin Message ---
Sorry about that, the URL is: http://www.submitsend.com

"Mek2600-Php" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
>
>
> First suggestion- include the URL.  :)
>
> Michael Kennedy
>
> -----Original Message-----
> From: Erich Kolb [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 26, 2003 10:55 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Search Submission Tool
>
>
> Im putting together a free web based tool available to anyone who wants
> to automatically submit their website to multiple search engines at the
> same time.  I know this has been done before, but I haven't done it and
> its pretty much a learning experience for me.  It is currently
> functioning, and I will be adding some additional search engines, but I
> was wondering if anyone would be willing to take a look and offer any
> suggestions for improvement.
>
> I apoligize if this is in the incorrect forum, but im looking for as
> much feedback as possible.
>
> Thanks,
> Erich Kolb
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---

Reply via email to