php-general Digest 22 Dec 2010 17:48:53 -0000 Issue 7099

Topics (messages 310211 through 310226):

Warning when calling session_start()
        310211 by: webdev.blaettner.com
        310212 by: Michael Shadle
        310213 by: webdev.blaettner.com
        310222 by: Ravi Gehlot

Re: goto - My comments
        310214 by: Jim Lucas

Re: Is there a simple way to enforce a private method in a subclass?
        310215 by: Richard Quadling

accessing magic parent set
        310216 by: Alexandru Patranescu
        310225 by: Ravi Gehlot

MP3 Player and PHP
        310217 by: Don Wieland
        310219 by: a...@ashleysheridan.co.uk
        310221 by: Richard Quadling

Server response very poor again
        310218 by: Al
        310220 by: Steve Staples
        310224 by: Nicholas Kell
        310226 by: Daniel P. Brown

Re: empty() in email message
        310223 by: Ravi Gehlot

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hi, folks,
good morning !

Since I'm a newbie with respect of sessions & cookies
I'm quite lost here getting always a warning when
calling session_start();

I developed and tested some php code using a session
to pass some values betwen different scripts on my
local machine.  All went O.K.

But when I transferred the code to my provider's
server where my website is hosted, I constantly get
this warning when calling session_start():

   Warning: session_start() [function.session-start]:
   Cannot send session cache limiter - headers already
   sent (output started at /...../sess.php:3) in
   /...../sess.php on line 5

In line 5 is session_start();
I dotted-out the path prefices in this warning.

Lines 1-5 of my script "sess.php" are as follows:

1 <!-- ---- PHP CODE ------------------------- ->
2
3 <?php
4
5  session_start ();

In my browser (firefox) I've enabled cookies.

There were some differences between my local machine
and my provider's server in respect to session related
PHP flags/variables.  I adapted those by adding
following lines in .htaccess on the webserver:

php_flag session.bug_compat_42 off    # Was On
php_value session.bug_compat_42 off   # Was On

php_flag session.cookie_httponly on   # Was off
php_value session.cookie_httponly on  # Was off

php_flag session.use_only_cookies On  # Was off
php_value session.use_only_cookies On # Was off

Can anybody give me some hints for resolving this
issue and/or pointers where to dig further ?!?

Thanks in advance !

Rolf
-- 
Dipl.phys. Rudolf Otto Blättner,
D 91074 Herzogenaurach, Germany.

--- End Message ---
--- Begin Message ---
On Tue, Dec 21, 2010 at 9:27 PM,  <web...@blaettner.com> wrote:

>   Warning: session_start() [function.session-start]:
>   Cannot send session cache limiter - headers already
>   sent (output started at /...../sess.php:3) in
>   /...../sess.php on line 5

first - this is probably your culprit:
don't output empty lines before you do anything (just a general good practice)

also i'd turn on output buffering.

--- End Message ---
--- Begin Message ---
Hi, folks,

On Tue, 21 Dec 2010 21:35:17 -0800 [06:35:17 AM CET],
Michael Shadle <mike...@gmail.com> wrote:

> first - this is probably your culprit:
> don't output empty lines before you do
> anything (just a general good practice)

Whow! This did the trick !

Warning vanished when I changed beginning of
script to:

1 <?php session_start ();
2

I wasn't aware that the HTML comment and the
following empty line are in fact written to
output.  But that's clear now  :-)

So I suppose my local PHP setup supressed this
warning or is more compliant ...

> also i'd turn on output buffering.

Since it worked without warning at 1st try,
I haven't changed output buffering (yet).

Mike, many thanks for Your PROMPT and HELPFUL
answer! Have a nice day!

Rolf
-- 
Dipl.phys. Rudolf Otto Blättner,
D 91074 Herzogenaurach, Germany.

--- End Message ---
--- Begin Message ---
session_start (); should be before everything...first thing in the page.

Ravi.


On Wed, Dec 22, 2010 at 12:51 AM, <web...@blaettner.com> wrote:

> Hi, folks,
>
> On Tue, 21 Dec 2010 21:35:17 -0800 [06:35:17 AM CET],
> Michael Shadle <mike...@gmail.com> wrote:
>
> > first - this is probably your culprit:
> > don't output empty lines before you do
> > anything (just a general good practice)
>
> Whow! This did the trick !
>
> Warning vanished when I changed beginning of
> script to:
>
> 1 <?php session_start ();
> 2
>
> I wasn't aware that the HTML comment and the
> following empty line are in fact written to
> output.  But that's clear now  :-)
>
> So I suppose my local PHP setup supressed this
> warning or is more compliant ...
>
> > also i'd turn on output buffering.
>
> Since it worked without warning at 1st try,
> I haven't changed output buffering (yet).
>
> Mike, many thanks for Your PROMPT and HELPFUL
> answer! Have a nice day!
>
> Rolf
> --
> Dipl.phys. Rudolf Otto Blättner,
> D 91074 Herzogenaurach, Germany.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On 12/18/2010 9:17 PM, Ethan Rosenberg wrote:
Dear List -

Thanks to all for your EXCELLENT comments. I definitly agree that goto
is a command to be avoided at all costs. In this case, I could not
figure out how to acheive the desired result without the goto. So....
being a newbie, I humbly request that you show [and at the same time
teach] me how to rewrite the code to eleiminate the goto.

Additionally, would you please do the same for the code I list below.
This code runs perfectly.
==============
This is the form:

<form action="srchrhsptl2.php" method="post">
<center>Site: <input type="text" name="Site" value="AA" />
Record Number: <input type="text" name="MedRec" />
First Name: <input type="text" name="Fname" />
Last Name: <input type="text" name="Lname" /><br /><br />
Phone: <input type="text" name="Phone" />
Height: <input type="decimal" name="Height" /></input><br /><br />
Male<input type="radio" name="Sex" value = "0"></input>
Female<input type="radio" name="Sex" value = "1"></input><br /><br /><br />
<input type="submit" /><br /><br />
<input type="reset" value = "Clear Form" /></center>
</form>


Not sure if you can change the values for the Sex field to 'Male' & 'Female' respectively, but it would simplify the following example.


Here is my rendition of how I would do it.

<?php

...

$query = "select * from Intake3 where 1 ";

$allowed_fields = array('Site', 'MedRe', 'Fname', 'Lname',
                        'Phone', 'Sex', 'Height');

# deal with the special case first
# Normally you do not want to modify the _POST/_GET/_REQUEST array, but
# in this case, it is used as an quick example of how to get the data
# passed along. if you can change the field values to Male/Female you
# could remove the following section and have just the foreach() loop.
if ( ! empty($_POST['Sex']) )
{
        if ( $_POST['Sex'] === '1' )
                $_POST['Sex'] = 'Female';
        else
                $_POST['Sex'] = 'Male';
}

# Now deal with the rest...
foreach ( $allowed_fields AS $field )
{
        if ( ! empty( $_POST[$field] ) )
        {
                $value = mysql_real_escape_string( $_POST[$field] );
                $query .= " AND `{$field}` = '{$value}' ";
        }
}

in the end, you will end up with a nicely formatted SQL query to execute.

I would suggest cleaning up the output code some and use *_assoc() instead of the *_array() function call. It gives you back the array version of the output. This way instead of calling $row[0], $row[...] you would call $row['Fname'] or $row['Lname'] instead.

Get rid of all those commented out sections and you will have a good script to play with.

Let us know what comes of it...


==============
THANK YOU EVER SO MUCH FOR YOUR HELP.

Ethan




--- End Message ---
--- Begin Message ---
On 21 December 2010 19:12, Carlos Medina <i...@simply-networks.de> wrote:
> Am 21.12.2010 17:36, schrieb Richard Quadling:
>>
>> Hi.
>>
>> If I have an abstract class of Task and I want all subclasses of Task
>> to have a private method _runTask, is there a way to enforce this?
>>
>> Currently an abstract private function in an abstract class isn't allowed.
>>
>> Fatal error: Abstract function Task::_runTask() cannot be declared
>> private in D:\PHP\Includes\Task.php on line 91
>>
>> Now I'm pretty sure there are valid reasons for this, but, for me, the
>> key part here is the "abstract" modifier.
>>
>> This should be read first and foremost and simply say that somewhere
>> in the subclasses, this method must defined. And if it must be defined
>> as private, then so be it.
>>
>> Richard.
>>
>
>
> Hi Richard,
> okay you want to use an abstract class (not instantiable) with a private
> abstract method. I think this doesnt make sense. And i think, PHP does not
> allow this because the inheritance constraint will be failed (you can use
> only in the class itself).
>
> Regards
>
> Carlos

Thanks for that. Things were getting too complicated because I had 2
significantly different features in 1 class. Now I've got 2 interfaces
(TaskInterface and TaskControllerInterface), things make more sense to
me.

Richard.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
Is this the only way to access the magic __set from the parent class:

    public function __set($columnName, $value)
    {
        if ($value !== $this->$columnName) {
            parent::__set($columnName, $value);
        }
    }


I would have liked to work this way:

    public function __set($columnName, $value)
    {
        if ($value !== $this->$columnName) {
            parent::$columnName = $value;
        }
    }


And another question.
There is a self, a static and a parent
Why is it only $this and not a $parent too?

--- End Message ---
--- Begin Message ---
Hello,

$this only calls variables inside of a method. In your function, you are
calling a variable that was defined inside of your function called
$columnName. You should past the whole class. Not just the methods.

"The pseudo-variable $this is available when a method is called from within
an object context. $this is a reference to the calling object (usually the
object to which the method belongs, but possibly another object, if the
method is called statically from the context of a secondary object). " taken
from http://www.php.net/manual/en/language.oop5.basic.php

The parent keyword indicates that this is an extended class. You are
referring back to the master class.

Ravi.


On Wed, Dec 22, 2010 at 9:35 AM, Alexandru Patranescu <dreal...@gmail.com>wrote:

> Is this the only way to access the magic __set from the parent class:
>
>    public function __set($columnName, $value)
>    {
>        if ($value !== $this->$columnName) {
>            parent::__set($columnName, $value);
>        }
>    }
>
>
> I would have liked to work this way:
>
>    public function __set($columnName, $value)
>    {
>        if ($value !== $this->$columnName) {
>            parent::$columnName = $value;
>        }
>    }
>
>
> And another question.
> There is a self, a static and a parent
> Why is it only $this and not a $parent too?
>

--- End Message ---
--- Begin Message ---
Hello,

Can someone recommend a web MP3 player? I need the following options:

1) Location and Duration of mp3 display (seconds)
2) The ability to pass a start and end parameter and play a part of the song
3) Loop parameter
4) Call to the player to grab the mp3 Location and set it to a field so i can insert it via PHP to mySQL
5) Work is most popular browsers

Free would be nice but I am will to pay a bit if it offers everything I need.

Any suggestions would be appreciated.

Don

--- End Message ---
--- Begin Message ---
You've missed a crucial part of php; its not a client-side language, its all 
run on the server. So you can't have a music player built in it running in a 
web browser. For that you need something like flash or java.

There is a way potentially with html5, but not all support the <audio> tag 
(internet explorer for example) and not all support the same codecs.

Thanks,
Ash
http://www.ashleysheridan.co.uk

----- Reply message -----
From: "Don Wieland" <d...@dwdataconcepts.com>
Date: Wed, Dec 22, 2010 15:06
Subject: [PHP] MP3 Player and PHP
To: <php-gene...@lists.php.net>

Hello,

Can someone recommend a web MP3 player? I need the following options:

1) Location and Duration of mp3 display (seconds)
2) The ability to pass a start and end parameter and play a part of  
the song
3) Loop parameter
4) Call to the player to grab the mp3 Location and set it to a field  
so i can insert it via PHP to mySQL
5) Work is most popular browsers

Free would be nice but I am will to pay a bit if it offers everything  
I need.

Any suggestions would be appreciated.

Don

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


--- End Message ---
--- Begin Message ---
On 22 December 2010 15:06, Don Wieland <d...@dwdataconcepts.com> wrote:
> Hello,
>
> Can someone recommend a web MP3 player? I need the following options:
>
> 1) Location and Duration of mp3 display (seconds)
> 2) The ability to pass a start and end parameter and play a part of the song
> 3) Loop parameter
> 4) Call to the player to grab the mp3 Location and set it to a field so i
> can insert it via PHP to mySQL
> 5) Work is most popular browsers
>
> Free would be nice but I am will to pay a bit if it offers everything I
> need.
>
> Any suggestions would be appreciated.
>
> Don
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

For playing MP3s (I have an alert system running in our call centre),
I use SoundManager2. It's a JS library which allows me to play mp3
files. They are controlled by an AJAX orientated request to PHP which
gathers the data and determines what alert needs to be played.

Was first running on IE6.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message --- It was fixed about 3 or 4 weeks ago; but, has reverted to poor again. Many times outs etc.

Took me 4 tries to post this.

Al...........

--- End Message ---
--- Begin Message ---
On Wed, 2010-12-22 at 10:19 -0500, Al wrote:
> It was fixed about 3 or 4 weeks ago; but, has reverted to poor again.  Many 
> times outs etc.
> 
> Took me 4 tries to post this.
> 
> Al...........
> 

Not trying to sound rude or prickish... but is it your ISP or connection
to the intertubes?   Or could it be an issue with your computer?

I've never had any problems posting, or retrieving mail from this list,
so I can't say/speak to a related issue.

Steve




--- End Message ---
--- Begin Message ---
On Dec 22, 2010, at 10:09 AM, Steve Staples wrote:

> On Wed, 2010-12-22 at 10:19 -0500, Al wrote:
>> It was fixed about 3 or 4 weeks ago; but, has reverted to poor again.  Many 
>> times outs etc.
>> 
>> Took me 4 tries to post this.
>> 
>> Al...........
>> 
> 
> Not trying to sound rude or prickish... but is it your ISP or connection
> to the intertubes?   Or could it be an issue with your computer?
> 
> I've never had any problems posting, or retrieving mail from this list,
> so I can't say/speak to a related issue.
> 
> Steve
> 

I am with Steve. Well, what I mean is, on this topic I am in agreement with 
Steve. My connection, etc. seems to be quite responsive.

--- End Message ---
--- Begin Message ---
On Wed, Dec 22, 2010 at 10:19, Al <n...@ridersite.org> wrote:
> It was fixed about 3 or 4 weeks ago; but, has reverted to poor again.  Many
> times outs etc.
>
> Took me 4 tries to post this.

    Al, are you using NNTP?

-- 
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

--- End Message ---
--- Begin Message ---
Hello Gary,

Please research the difference between a single quote and a double quote.
Also, you can use the operator .=(dot + equal) in this manner:

            if(!empty($_POST['fname'])) {
                $msg .= "$lname\n";
            } else if(!empty($_POST['lname'])) {
                $msg .= "$lname\n";
}



On Tue, Dec 14, 2010 at 12:04 AM, Gary <gp...@paulgdesigns.com> wrote:

>
> ""Daevid Vincent"" <dae...@daevid.com> wrote in message
> news:7d7c84d94dd24035a620e68b5b937...@mascorp.com...
> >> ----- Original message -----
> >> From: Gary <gp...@paulgdesigns.com>
> >> To: php-gene...@lists.php.net <php-gene...@lists.php.net>
> >> Date: Monday, December 13, 2010, 7:47:49 PM
> >> Subject: [PHP] empty() in email message
> >>
> >> I have an email message
> >>
> >> $msg =  'Name: $fname ' . ' $lname\n'
> >> . "Phone: $phone\n"
> >> . "Email: $email\n"
> >>
> >> and it works fine, however in this message there are about 30
> >> variables that
> >> are being called...as such
> >>
> >> . "Order: beefschnitzel $beefschnitzel\n"
> >> . "Order: beefstrips $beefstrips\n"
> >> . "Order: cheesesausage $cheesesausage\n"
> >> . "Order: crumbedsausage $crumbedsausage\n"
> >> . "Order: chucksteak $chucksteak\n"
> >> . "Order: cornedbeef $cornedbeef\n"
> >> . "Order: dicedsteak $dicedsteak\n"
> >> . "Order: filletmignon $filletmignon\n"
> >>
> >> I want to only send the message if the submitter enters an
> >> amount in the
> >> form for the corresponding variable, instead of having a
> >> bunch of empty
> >> messages.  So I have been trying to use the empty() function as such:
> >>
> >> . if empty($beefolives){''} elseif (isset($beefolives)) {
> >> 'Order: beefolives
> >> $beefolives\n'}
> >
> > You are setting this up fundamentally wrong.
> >
> > You should be using an array and looping through it.
> >
> > Something like:
> >
> > $myorder['cowface'] = 1;
> > $myorder['beefenweiner'] = 2;
> > $myorder['chucksteak']   = 1;
> >
> > foreach ($myorder as $item => $quantity)
> > {
> >     echo "Order: $item x $quantity\n";
> > }
> >
> > Then your array only contains the items someone actually puchased and how
> > many.
> >
> > d
> >
>
> Daevid
>
> I knew someone was going to point out this was a convoluted method, and I
> agree.  This was sent to me by someone that needed to make the mail form
> work.  My suggestion was to look into a pre-made shopping cart, however
> that
> was not going to work for them, so I made the mail() work for them.
>
> I had thought about putting it into an array, but had not gotten that far
> into it.  I will look over the code to see how it works.
>
> Thank you for your help.
>
> gary
>
>
>
>
> __________ Information from ESET Smart Security, version of virus signature
> database 5700 (20101213) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---

Reply via email to