php-general Digest 30 Jul 2003 10:22:15 -0000 Issue 2206

Topics (messages 157459 through 157503):

Re: Rounding issue
        157459 by: Kevin Ison

Re: session_set_cookie_params
        157460 by: John W. Holmes
        157462 by: Curt Zirzow

Re: learning php - problem already
        157461 by: John W. Holmes
        157500 by: Ivo Fokkema

Re: Simple Array question
        157463 by: Ryan A
        157467 by: John W. Holmes

Re: Simple Array question (conclusion)
        157464 by: Ryan A
        157469 by: John W. Holmes

problems with vAuthenticate 3.0
        157465 by: Kim Eichen

help with php
        157466 by: Billy
        157468 by: Chris W. Parker
        157470 by: DvDmanDT
        157472 by: Chris W. Parker

Re: Apache logs to keep $_POST values
        157471 by: Sek-Mun Wong

John->Re: [PHP] Re: Simple Array question (conclusion)
        157473 by: Ryan A

Re: uploading a file from a form
        157474 by: Tom Rogers

Parsing a local file
        157475 by: Jason D. Williard
        157476 by: Jason D. Williard
        157477 by: John W. Holmes
        157478 by: DvDmanDT
        157479 by: Curt Zirzow
        157481 by: DvDmanDT

tags to lowercase
        157480 by: Justin French
        157483 by: Curt Zirzow
        157484 by: Jeff Harris

Re: Mail funtion question
        157482 by: Bobby Patel

The return of mysql_fetch_assoc()
        157485 by: Ney André de Mello Zunino
        157486 by: Ray Hunter
        157487 by: Ney André de Mello Zunino
        157492 by: Curt Zirzow
        157501 by: Ivo Fokkema

Strip Numbers
        157488 by: Joe Harman
        157490 by: Martin Towell
        157495 by: Jeff Harris

Why wouldn't a simple script work on my server that works on other servers?
        157489 by: Dan Anderson
        157491 by: Petre Agenbag
        157493 by: Dan Anderson
        157494 by: Curt Zirzow

Re: debuging and getting mor information about failures
        157496 by: Ivo Fokkema

THX Strip Numbers
        157497 by: Joe Harman

Re: PHP suexec: html files as PHP.
        157498 by: Joan McGalliard

Re: include and imagejpg() weird behavior - maybe header?
        157499 by: Oli

Search in PhP
        157502 by: khuram noman
        157503 by: Nadim Attari

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 ---
ahhh ok thanks guys!! That worked ... I knew it was something but I could
not remember which function...

thanks again!

"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> * Thus wrote Kevin Ison ([EMAIL PROTECTED]):
> > I need to know if there is a work around for the following scenerio...
> >
> > $x = 4.5012412;
> > echo round($x, 2);     // results in 4.5 ---  however I want 4.50!  I
want 2
> > decimal places!
>
>
> >
> >
> > Is there a way to keep the zero from being dropped?  I have not been
able to
> > get the zero to stay there ... I realize this is the interpreters
problem
> > but I need the zero.
>
> number_format(round($x, 2),2);
>
> you can always control with printf functions, but number format is
> designed specifically for that.
>
>
> Curt
> --
> "I used to think I was indecisive, but now I'm not so sure."



--- End Message ---
--- Begin Message --- Hank TT wrote:

I've read the official manual on session handling, as well as the section in
"PHP Developer's Cookbook" (2/e, Hughes & Zmievski).  But I still cannot
make a cookie persist across browser sessions -- very frustrating.

I use PHP 4.1.1 running as a CGI in Win32.

Here is a snippet:

======================
$lifetime =  time() + 8600;

session_name('app');
session_start();
....
session_set_cookie_params ($lifetime, '', '.site.com');
    // session_get_cookie_params returns the expected values
....
$_SESSION['userdata'] = $data;
    // Browser, however, says the cookie is due to expire at the end of
session (and it does).
======================

What am I missing here? Thanks.

Call session_set_cookie_params() before you call session_start().


You could also use:

ini_set('session.cookie_lifetime',$lifetime);

(before session_start() of course)

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--- End Message ---
--- Begin Message ---
* Thus wrote Hank TT ([EMAIL PROTECTED]):
> Hi,
> 
> I've read the official manual on session handling, as well as the section in
> "PHP Developer's Cookbook" (2/e, Hughes & Zmievski).  But I still cannot
> make a cookie persist across browser sessions -- very frustrating.
> 
> I use PHP 4.1.1 running as a CGI in Win32.
> 
> Here is a snippet:
> 
> ======================
> $lifetime =  time() + 8600;
> 
> session_name('app');
> session_start();
> ....
> session_set_cookie_params ($lifetime, '', '.site.com');
>     // session_get_cookie_params returns the expected values

If possible try setting the cookie params before session start.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message --- Curt Zirzow wrote:

* Thus wrote Curt Zirzow ([EMAIL PROTECTED]):


think it was made to be  intentionally confusing.  For what reason, I
don't but all that matters to most is: it works..  and foreach has


I cant type nor proof read today... at least before hitting send.

I think I understood you. ;) I agree.


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--- End Message ---
--- Begin Message ---
"Curt Zirzow" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> * Thus wrote John W. Holmes ([EMAIL PROTECTED]):
> >

[snip]

> don't but all that matters to most is: it works..  and foreach has
> taken over its job anyway.
Just a small comment... foreach() is not equal to a while/each loop. Foreach
uses a copy of the array, and not the array itself. This might not sound
important, but it was for me when I tried to add new elements to the array
in the middle of a foreach() loop. They didn't show up until after the loop,
which was a bit confusing for me at first. So occasionally when I need to
add elements during a loop, I still use while(list(..) = each(...)).

--
Ivo



--- End Message ---
--- Begin Message ---
Hi,
Thanks for replying.
I tried that and have 2 numbers like so:

<input name="id[sh123]" type="hidden" value="32">
<input name="id[sh1sd]" type="hidden" value="563">

and tried to echo it like so:
<?php
$id=$_POST['id'];
foreach($_POST['id'] AS $row)
echo $row;
?>
Echo of one is <?php echo $row[0]; ?> and echo of two is:<b> <?php echo
$row[1]; ?></b><br><br>
Echo of one is <?php echo $id[0]; ?> and echo of two is:<b> <?php echo
$id[1]; ?></b>

the output i got was:
******************
32563Echo of one is 5 and echo of two is: 6

Echo of one is and echo of two is:
*****************


AS you can see its totally wrong.Any other ideas?

cheers,
-Ryan


> Normally array values start at 0 (zero), but let's say sh1=1 and sh2=2.
then
> you could echo the values out like this: echo "ID 1: $id[1]<br>ID 2:
> $id[2]<br>";
>
> Irvin.





> > Hi,
> > If i am posting something like this from a form:
> >  <input type=checkbox name='id[sh1]' value=3>
> >  <input type=checkbox name='id[sh2]' value=4>
> >
> > How do i get the value of id[]?
> > eg:
> > I dont want the "sh1" and "sh2", i just want the "3" and "4"
> >
> > The reason i dont wan the sh1 and sh2 is those are dynamic and will be
> > changing, I just need the values (in this case 3 and 4) to do some
> > comparasion and assignment operations
> >
> > Kindly reply.
> >
> > Thank,
> > -Ryan
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


--- End Message ---
--- Begin Message --- Ryan A wrote:
Hi,
Thanks for replying.
I tried that and have 2 numbers like so:

<input name="id[sh123]" type="hidden" value="32">
<input name="id[sh1sd]" type="hidden" value="563">

and tried to echo it like so:
<?php
$id=$_POST['id'];
foreach($_POST['id'] AS $row)
echo $row;
?>
Echo of one is <?php echo $row[0]; ?> and echo of two is:<b> <?php echo
$row[1]; ?></b><br><br>
Echo of one is <?php echo $id[0]; ?> and echo of two is:<b> <?php echo
$id[1]; ?></b>

the output i got was:
******************
32563Echo of one is 5 and echo of two is: 6

Echo of one is and echo of two is:
*****************


AS you can see its totally wrong.Any other ideas?

No... you're getting exactly what you ask for. You rely on this list to much.


1. You have no braces so your foreach() is taking the next line as the part that should be executed on each loop.

2. Loop 1 sets $row = 32. Then it's displayed

3. Loop 2 sets $row = 563. Then it's displayed

4. So now $row = 563. When you display $row[0], you're asking for the first character of $row, so 5 is displayed. $row[1] displays 6.

5. Now you go back to $id. Well, $id = array('sh123' => 32, 'sh1sd' => 563). So, when you try to display $id[0] and $id[1], there are no cooresponding values, so nothing is displayed.

Now, how do you do this correctly?

foreach($_POST['id'] as $key => $value)
{ echo "The random key is $key, the value is $value.<br />"; }

which will give you:

The random key is sh123, the value is 32.
The random key is sh1sd, the value is 563.

What do you want, besides that?

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--- End Message ---
--- Begin Message ---
I GOT IT!!!!

this is where the data was coming from:
 <input name="id[sh123]" type="hidden" id="id[sh123]" value="32">
  <input name="id[sh1sd]" type="hidden" id="id[sh1sd]" value="563">

and this is where i take the values and dump it into an array/variables that
i can call when and where i please:

<?php
$nn=0;
foreach($id as $nname => $pppno)
{$asdf[$nn]=$pppno;
 $nn++;  }
?>
<br><br><?php echo $asdf[0]; ?><br>
<?php echo $asdf[1]; ?>


I just took out some of the breaks so it will take less space but you get
the idea.

Thank you to everyone who tried to help, but maybe i didnt explain the
problem well enough that you didnt get the answer or just didnt want to :-D

Cheers,
-Ryan



----- Original Message -----
From: "Irvin Amoraal" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 29, 2003 11:59 PM
Subject: [PHP] Re: Simple Array question


> Normally array values start at 0 (zero), but let's say sh1=1 and sh2=2.
then
> you could echo the values out like this: echo "ID 1: $id[1]<br>ID 2:
> $id[2]<br>";
>
> Irvin.
> _____________________________________
>
> "Ryan A" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi,
> > If i am posting something like this from a form:
> >  <input type=checkbox name='id[sh1]' value=3>
> >  <input type=checkbox name='id[sh2]' value=4>
> >
> > How do i get the value of id[]?
> > eg:
> > I dont want the "sh1" and "sh2", i just want the "3" and "4"
> >
> > The reason i dont wan the sh1 and sh2 is those are dynamic and will be
> > changing, I just need the values (in this case 3 and 4) to do some
> > comparasion and assignment operations
> >
> > Kindly reply.
> >
> > Thank,
> > -Ryan
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


--- End Message ---
--- Begin Message --- Ryan A wrote:

I GOT IT!!!!

this is where the data was coming from:
 <input name="id[sh123]" type="hidden" id="id[sh123]" value="32">
  <input name="id[sh1sd]" type="hidden" id="id[sh1sd]" value="563">

and this is where i take the values and dump it into an array/variables that
i can call when and where i please:

<?php
$nn=0;
foreach($id as $nname => $pppno)
{$asdf[$nn]=$pppno;
 $nn++;  }
?>
<br><br><?php echo $asdf[0]; ?><br>
<?php echo $asdf[1]; ?>


I just took out some of the breaks so it will take less space but you get the idea.

Thank you to everyone who tried to help, but maybe i didnt explain the
problem well enough that you didnt get the answer or just didnt want to :-D

Seriously?


You could just replace the above with:

$asdf = array_values($_POST['id']);

I think you need to be cut off from the list for a while. Trial by fire, I say!!

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--- End Message ---
--- Begin Message ---
Hello group

This question is only relevant to those of you who know vAuthenticate.

I have without luck tried to make vAuthenticate 3.0 
(http://www.beanbug.net/vScripts.php) work.

The funny thing is that vSignup 2.1 works flawlessly and it is based on vAuthenticate. 
En difference
though is that vAuthenticate uses encrypted passwords in contradiction to vSignup.

Do any of you have a clue about how I solve the problem?



Kind regards Kim Eichen



--- End Message ---
--- Begin Message ---
hi im new to php. but i need help with a form. ive made an html form but the
thing is i needed it to send all the info from the boxes above to an e-mail.
this is my first time with this type of web design could someone help me
out. thanks



--- End Message ---
--- Begin Message ---
Billy <mailto:[EMAIL PROTECTED]>
    on Tuesday, July 29, 2003 4:25 PM said:

> hi im new to php. but i need help with a form. ive made an html form
> but the thing is i needed it to send all the info from the boxes
> above to an e-mail. this is my first time with this type of web
> design could someone help me out. thanks

1. Above?

2. What type of "web design"* are you familiar with?

3. Having a form send data somewhere has nothing to do with php but
rather HTML. You should learn to use HTML before you learn PHP.

4. Be a lot more specific** with your question and maybe someone can
help you.


hth,
chris.

* PHP is not web design.

** You can be more specific by showing some code and detailing what
you've tried and what is happening.

--- End Message ---
--- Begin Message ---
I agree to Parker's post, but I think I understand you...
thescript.php:
    <?
    mail($_POST["to"],$_POST["subject"],
    $_POST["message"],"From: ".$_POST["from"]);
    ?>

That script or command  requires the following form:
    <form method="post" action="thescript.php">
    Send to this email: <input type="text" name="to"><br>
    Your email: <input type="text" name="from"><br>
    Subject: <input type="text" name="subject"><br>
    Message: <textarea name="message"></textarea>
    <p></p>
    <input type="submit" value="send">
    </form>

Maybe this what you wanted, maybe not.. :p
-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
"Billy" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> hi im new to php. but i need help with a form. ive made an html form but
the
> thing is i needed it to send all the info from the boxes above to an
e-mail.
> this is my first time with this type of web design could someone help me
> out. thanks
>
>



--- End Message ---
--- Begin Message ---
DvDmanDT <mailto:[EMAIL PROTECTED]>
    on Tuesday, July 29, 2003 5:06 PM said:

> I agree to Parker's post, but I think I understand you...

Whoops... I should apologize. I missed the keyword "email" and read it
as "another page". Sorry Billy.


Chris.

--- End Message ---
--- Begin Message ---
no, that's (partially) the idea of a POST.

Eg, if a login script was done under SSL using a http GET, even if you were
using 1 way crypt on the password, the cleartext would still be logged,
which is undesirable.

besides, how would you log a multi-part mime upload file in POST?

The only way I can think of is if you write your own/find an apache mod.
(which ignores multi-part mimes)


"Bogdan Albei" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Is there any way to log the $_POST values passed to the PHP scripts in
> Apache's access log?
>


--- End Message ---
--- Begin Message ---
Hey John,
I guess you are right, I do rely on this list quite a bit but am not the
only one.
Am learning by my mistakes though and finding solutions...they may not be
the best solutions but they still work, everyone has to learn.
Thanks for replying to the question though. And i didnt know about the
"array_values" thing....see? the more you reply to me the more i learn :-D
Cheers,
-Ryan



> Ryan A wrote:
>
> > I GOT IT!!!!
> >
> > this is where the data was coming from:
> >  <input name="id[sh123]" type="hidden" id="id[sh123]" value="32">
> >   <input name="id[sh1sd]" type="hidden" id="id[sh1sd]" value="563">
> >
> > and this is where i take the values and dump it into an array/variables
that
> > i can call when and where i please:
> >
> > <?php
> > $nn=0;
> > foreach($id as $nname => $pppno)
> > {$asdf[$nn]=$pppno;
> >  $nn++;  }
> > ?>
> > <br><br><?php echo $asdf[0]; ?><br>
> > <?php echo $asdf[1]; ?>
> >
> >
> > I just took out some of the breaks so it will take less space but you
get
> > the idea.
> >
> > Thank you to everyone who tried to help, but maybe i didnt explain the
> > problem well enough that you didnt get the answer or just didnt want to
:-D
>
> Seriously?
>
> You could just replace the above with:
>
> $asdf = array_values($_POST['id']);
>
> I think you need to be cut off from the list for a while. Trial by fire,
> I say!!
>
> --
> ---John Holmes...
>
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
>
> PHP|Architect: A magazine for PHP Professionals – www.phparch.com
>
>
>
>


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

Wednesday, July 30, 2003, 12:09:44 AM, you wrote:
AM> The version is PHP Version 4.2.3.

AM> On Tue, 29 Jul 2003, Tom Rogers wrote:

Then you can use the $_FILES array like this:

if($_FILES["photo"]["error"]==0){   //make sure no errors on upload
    if(!empty($_FILES["photo"]["name"])){   //do we have a file name
        $tempname = $_FILES["photo"]["tmp_name"]; //this is how php has it
        $file = trim($_FILES["photo"]["name"]); //this is what it was called
        //clean up the file name
        //we don't want something like "this is mac's image.jpg"
        $file = ereg_replace("'","",$file);
        $file = ereg_replace("%20","_",$file);
        $file = ereg_replace(" ","_",$file);
        $path = '/home/vencel/www/images/apt';  //this is where we want to store
        //make sure that apt has permissions set to 777 so web user
        //can write to it
        move_uploaded_file($tempname,$file);
    }
}

-- 
regards,
Tom


--- End Message ---
--- Begin Message ---
I am trying to build script that will parse a file on the user's computer.
There are 2 things that I am not quite sure about.

1) How to read a file on the user's computer, and not on the server.

2) How to parse a line similar to the one below:

"7/29/2003" , "Report Title" , "Page" , "Agent Name" , "5200" , "30" ,
"3:30" , "" , "" , ""

Now, in this line, there are items that I would like to discard.  As well,
there are items between the "s that I would like the parse further.  Below
is how I would like it parsed

"$month/$day/$year" , "DISCARD" , "DISCARD" , "DISCARD" , "$agentid" ,
"$calls_taken" , "$avg_call_time" , "DISCARD" , "DISCARD" , "DISCARD"


Any help would be appreciated.

Thanks,
Jason







--- End Message ---
--- Begin Message ---
I am trying to build script that will parse a file on the user's computer.
There are 2 things that I am not quite sure about.

1) How to read a file on the user's computer, and not on the server.

2) How to parse a line similar to the one below:

"7/29/2003" , "Report Title" , "Page" , "Agent Name" , "5200" , "30" ,
"3:30" , "" , "" , ""

Now, in this line, there are items that I would like to discard.  As well,
there are items between the "s that I would like the parse further.  Below
is how I would like it parsed

"$month/$day/$year" , "DISCARD" , "DISCARD" , "DISCARD" , "$agentid" ,
"$calls_taken" , "$avg_call_time" , "DISCARD" , "DISCARD" , "DISCARD"


Any help would be appreciated.

Thanks,
Jason





--- End Message ---
--- Begin Message --- Jason D. Williard wrote:
I am trying to build script that will parse a file on the user's computer.
There are 2 things that I am not quite sure about.

1) How to read a file on the user's computer, and not on the server.

http://us2.php.net/manual/en/features.file-upload.php


2) How to parse a line similar to the one below:
>
"7/29/2003" , "Report Title" , "Page" , "Agent Name" , "5200" , "30" ,
"3:30" , "" , "" , ""

http://us2.php.net/manual/en/function.fgetcsv.php


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--- End Message ---
--- Begin Message ---
Also, it's a remote file you are trying to parse, not  a local...
local=server, remote=user... Like John linked, you must upload it... Can't
do it other ways...

-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
"Jason D. Williard" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> I am trying to build script that will parse a file on the user's computer.
> There are 2 things that I am not quite sure about.
>
> 1) How to read a file on the user's computer, and not on the server.
>
> 2) How to parse a line similar to the one below:
>
> "7/29/2003" , "Report Title" , "Page" , "Agent Name" , "5200" , "30" ,
> "3:30" , "" , "" , ""
>
> Now, in this line, there are items that I would like to discard.  As well,
> there are items between the "s that I would like the parse further.  Below
> is how I would like it parsed
>
> "$month/$day/$year" , "DISCARD" , "DISCARD" , "DISCARD" , "$agentid" ,
> "$calls_taken" , "$avg_call_time" , "DISCARD" , "DISCARD" , "DISCARD"
>
>
> Any help would be appreciated.
>
> Thanks,
> Jason
>
>
>
>
>
>



--- End Message ---
--- Begin Message ---
* Thus wrote DvDmanDT ([EMAIL PROTECTED]):
> Also, it's a remote file you are trying to parse, not  a local...
> local=server, remote=user... Like John linked, you must upload it... Can't
> do it other ways...

I suppose in this case with local and remote defined this way it
should be download instead of upload :)

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
lol, yeah, guess so... Although, when you talk about these things, do you
say you must download a file from the client? Or that you must open the
remote logfile in your script? Damn, this is getting screwy...

-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
"Curt Zirzow" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> * Thus wrote DvDmanDT ([EMAIL PROTECTED]):
> > Also, it's a remote file you are trying to parse, not  a local...
> > local=server, remote=user... Like John linked, you must upload it...
Can't
> > do it other ways...
>
> I suppose in this case with local and remote defined this way it
> should be download instead of upload :)
>
> Curt
> -- 
> "I used to think I was indecisive, but now I'm not so sure."



--- End Message ---
--- Begin Message --- Hi all,

has anyone developed or know of a function to convert all tags to lowercase, but still preserves the contents of the tags and the content of the attributes of the tags?

eg:

<BR />
becomes
<br />


<A HREF='aaaBBB.html>SomeThing</A> becomes <a href='aaaBBB.html>SomeThing</a>


Seems like it's going to be needed more and more in order to comply with XHTML strict.



Justin French



--- End Message ---
--- Begin Message ---
* Thus wrote Justin French ([EMAIL PROTECTED]):
> Hi all,

hello.

> 
> has anyone developed or know of a function to convert all tags to 
> lowercase, but still preserves the contents of the tags and the content 
> of the attributes of the tags?

nice little tool:
http://tidy.sourceforge.net/

Some one built a function that uses that tool to filter, you'll
have to search the archives, cause I dont know of it off hand.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
On Jul 30, 2003, "Curt Zirzow" claimed that:

|* Thus wrote Justin French ([EMAIL PROTECTED]):
|> Hi all,
|
|hello.
|
|>
|> has anyone developed or know of a function to convert all tags to
|> lowercase, but still preserves the contents of the tags and the content
|> of the attributes of the tags?
|
|nice little tool:
|http://tidy.sourceforge.net/
|
|Some one built a function that uses that tool to filter, you'll
|have to search the archives, cause I dont know of it off hand.
|
|
|Curt


I use tidy built into my scripts. In your tidy config file you can set
covert to lower case, indent, output XHTML or whatever. Curt refers to
phpTidyHt which basically does the same thing but with a function call.
Most pages come out crisp and clean. The others are inherently wacked and
need fixing anyway.

<?php
ob_start();
// process stuff
print("</body></html>");
$str = addslashes(ob_get_contents());
$fp = popen("echo \"" . $str .
      "\" | /path/to/tidy -config /path/tidy/config", "r");
$newstr = "";
do {
    $data = fread($fp, 999999);
    if (strlen($data) == 0) {
        break;
    }
    $newstr .= $data;
}
while(true);
pclose($fp);
ob_end_clean();
$modtime = filemtime($_SERVER['PATH_TRANSLATED']);
$gmt_modtime = gmdate('D, d M Y H:i:s', $modtime). ' GMT';
header("Last-Modified: " . $gmt_modtime);
header("Content-length: " . strlen(stripslashes($newstr ) ) );
echo stripslashes($newstr);
?>

-- 
Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



--- End Message ---
--- Begin Message ---
I haven't worked with PHP mail for a while, but since no one has responded
I'll give you something to consider:

1. Why don't you try error suppression , @ ? or you can set error_reporting
down or you can capture all output by using output buffering.
2. You can trap the invalid email, but it may be *more* complex and result
in a slower script. You will have to evaluate this for yourself,

$emails = array (); #array of email info
# In the form
# $emails[0] = array (email => mailto:'[EMAIL PROTECTED]' , name => 'Reciever
Name');
# $emails[1] = array (email => mailto:'[EMAIL PROTECTED]' , name => 'Reciever Name
2');

$invalid_emails = array();
foreach ($emails as $index => $info){

    $result = @mail ($info['email'], 'Bulk Newsletter Subject', 'email
messafge') ;
    if (!$result) {
        $invalid_emails [] = $info['email']; // capture invalid email
    }
}

Please note, that the code above will call mail once for each email, so if
you have 100 emails this will run 100 times, where as if you stacked all the
emails into one mail call. But then you may not be able to find the invalid
emails.




"Irvin Amoraal" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am using the PHP mail() function to send subscribed-to bulk email. It
> successfully sends emails to the valid email addresses, but I get a series
> of error messages at the top of the PHP page like:
> /home/[my folder]/dead.letter... Saved message in
> /home/[my folder]/dead.letter 123... User unknown
>
> I'm almost positive the error msgs are caused by invalid email addresses
> that are stored in the database.
>
> I have two questions:
> 1. How can I suppress the error msg's? @mail....?
> 2. Can the error be trapped and the invalid email address captured to be
> spit out in code?
>
> Thanks for your help.
>
> Irvin.
>
>



--- End Message ---
--- Begin Message --- Hello.

I wonder why the following code is not accepted by the PHP interpreter

$fooVar = mysql_fetch_assoc($result)["barColumn"];

I am forced to create an intermediary variable for the array returned from mysql_fetch_assoc(), like this:

$record = mysql_fetch_assoc($result);
$fooVar = $record["barColumn"];

Why is that? It doesn't seem logical. Could it be a bug?

Thank you,

--
Ney André de Mello Zunino


--- End Message ---
--- Begin Message ---
> $fooVar = mysql_fetch_assoc($result)["barColumn"];

No bug here...mysql_fetch_assoc($result) is a function that takes a
result set as an argument and returns only one row as an associated
array...that is why you need to do 

> $record = mysql_fetch_assoc($result);
> $fooVar = $record["barColumn"];

That is logic when it comes from the database...database results are
returned as rows with various column(s).

This allows you to go through each row and pull out all the columns for
that row.


HTH,

BigDog



--- End Message ---
--- Begin Message --- Ray Hunter wrote:

$fooVar = mysql_fetch_assoc($result)["barColumn"];

No bug here...mysql_fetch_assoc($result) is a function that takes a
result set as an argument and returns only one row as an associated
array...that is why you need to do

Thanks for the quick response, but I am not sure I understand your argument. Yes, I am aware that the function returns an array corresponding to a single row/record; what I don't understand is why I am not able to apply a key directly to that "temporary" return value. In other words, it is necessary to "copy" the resulting row into a new variable so that it is then possible to use the column name (key) to retrieve the desired value.


$record = mysql_fetch_assoc($result);
$fooVar = $record["barColumn"];

That is logic when it comes from the database...database results are returned as rows with various column(s).

This allows you to go through each row and pull out all the columns for
that row.

Several queries are guaranteed to return a single row, e.g. when using the primary key as a limiting criteria for the 'where' clause. That is the very case I am talking about, since it doesn't make sense to have to create a variable to store the returning array when you won't need it any longer.


The documentation states on the function signature that mysql_fetch_assoc() returns an array, so I fail to see why I cannot apply the subscript operator to that returned value, which *is* an array.

Regards,

--
Ney André de Mello Zunino


--- End Message ---
--- Begin Message ---
* Thus wrote Ney André de Mello Zunino ([EMAIL PROTECTED]):
> Hello.
> 
> I wonder why the following code is not accepted by the PHP interpreter
> 
> $fooVar = mysql_fetch_assoc($result)["barColumn"];

Because that is not an acceptable way to assign a variable.

> 
> I am forced to create an intermediary variable for the array returned 
> from mysql_fetch_assoc(), like this:
> 
> $record = mysql_fetch_assoc($result);
> $fooVar = $record["barColumn"];
> 
> Why is that? It doesn't seem logical. Could it be a bug?

Because that is how php works. If you are having that much trouble
being able to deal with its rules of coding syntax then I would suggest
to go back to your other language and discontinue gripping about
it.

By comparing php to another language and observing that php is not
capable of what the other one can do, does not make it a bug.

If you so desire to have this capability in php, you should submit
a feature request to the php-development team.  And probably
explain your reasoning more thoroughly than just 'It is logical to
do so.'  You might get a positive result back.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
""Ney andré de mello zunino"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thanks for the quick response, but I am not sure I understand your
> argument. Yes, I am aware that the function returns an array
> corresponding to a single row/record; what I don't understand is why I
> am not able to apply a key directly to that "temporary" return value. In
> other words, it is necessary to "copy" the resulting row into a new
> variable so that it is then possible to use the column name (key) to
> retrieve the desired value.
Why don't you use :

<?php
list ($fooVar) = mysql_fetch_row(mysql_query("SELECT barColumn FROM
table_name WHERE id = 1"));
?>

This will do exactly what you need, if I understand you correctly.

HTH,

--
Ivo Fokkema
PHP & MySQL programmer
Leiden University Medical Centre
Netherlands



--- End Message ---
--- Begin Message ---
Hey could someone help me out here....
 
I need to strip numbers from a passed variable
 
ex. 3899007
 
all the numbers will have 990 (so that is the 4th, 5th & sixth
numbers... from the right...) I want to keep everything to the left of
the two 9s... is there an easy way to do that????
 
Joe Harman

http://www.HarmanMedia.com

This `telephone' has too many shortcomings to be seriously considered as
a means of communication. The device is inherently of no value to us. -
Western Union internal memo, 1876 
 

--- End Message ---
--- Begin Message ---
You could use two substr()s or an ereg_replace()

        $result = substr($str, 0, 2) . substr($str, 5);
or
        $result = ereg_replace("([0-9][0-9])990([0-9][0-9])", "\\1\\2",
$str);

Both are not tested, but should work

Martin


-----Original Message-----
From: Joe Harman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 30 July 2003 4:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Strip Numbers


Hey could someone help me out here....
 
I need to strip numbers from a passed variable
 
ex. 3899007
 
all the numbers will have 990 (so that is the 4th, 5th & sixth
numbers... from the right...) I want to keep everything to the left of
the two 9s... is there an easy way to do that????
 
Joe Harman

http://www.HarmanMedia.com

This `telephone' has too many shortcomings to be seriously considered as
a means of communication. The device is inherently of no value to us. -
Western Union internal memo, 1876 
 
__________ Information from NOD32 1.468 (20030725) __________

This message was checked by NOD32 for Exchange e-mail monitor.
http://www.nod32.com




--- End Message ---
--- Begin Message ---
On Jul 30, 2003, "Joe Harman" claimed that:

|Hey could someone help me out here....
|
|I need to strip numbers from a passed variable
|
|ex. 3899007
|
|all the numbers will have 990 (so that is the 4th, 5th & sixth
|numbers... from the right...) I want to keep everything to the left of
|the two 9s... is there an easy way to do that????
|
|Joe Harman
|
|http://www.HarmanMedia.com
|
Since a problem should be stated in its basic and simplest terms, it
appears that you want to simply divide the
number by 10000 and take the integer portion:
$number=floor($passed/10000);

Jeff
-- 
Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



--- End Message ---
--- Begin Message ---
I have a client who had me upload a relatively simple script to his
server.  Oddly, it does not work there but works every where else I test
it.  AND he has other PHP scripts running on his server.

So I checked out his server and all scripts are of the form:

<? start_session() ?>

// HTML HERE

<?
// some functionality

?>

versus my scripts as

<?php

?>

Why would this affect things?

-Dan


--- End Message ---
--- Begin Message ---
Look;s like he has short_open_tags = on in php.ini, BUT, as I understand
it, this is a supplemental setting, meaning that it does not disable the
use of the (proper) <?php tags, it simply ADDS the use of <? to your
options.
Thus, I don't think it's because of the tags that the script won't run
on your server, it must be something else.

Have you checked that the xxx.php file has execute permissions on your
server?

Also, what (if any) errors does PHP/Browser report?
 
On Wed, 2003-07-30 at 08:45, Dan Anderson wrote:
> I have a client who had me upload a relatively simple script to his
> server.  Oddly, it does not work there but works every where else I test
> it.  AND he has other PHP scripts running on his server.
> 
> So I checked out his server and all scripts are of the form:
> 
> <? start_session() ?>
> 
> // HTML HERE
> 
> <?
> // some functionality
> 
> ?>
> 
> versus my scripts as
> 
> <?php
> 
> ?>
> 
> Why would this affect things?
> 
> -Dan
> 


--- End Message ---
--- Begin Message ---
> Also, what (if any) errors does PHP/Browser report?

That's the really bizarre thing.  It spits out the entire PHP code as
the web page.  The browser then tries to render it and can produce some
really humourous results.

And execute permissions shouldn't matter, right?

-Dan


--- End Message ---
--- Begin Message ---
* Thus wrote Dan Anderson ([EMAIL PROTECTED]):
> > Also, what (if any) errors does PHP/Browser report?
> 
> That's the really bizarre thing.  It spits out the entire PHP code as
> the web page.  The browser then tries to render it and can produce some
> really humourous results.

That is a sign that php isn't parsing them, so I would first make
sure that my file extenstions are the same as the ones that are
currently working.


> 
> And execute permissions shouldn't matter, right?

Correct. Unless your running them as a cgi.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
"Chrstian Brensteiner" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> whats the best option to get more information about a failure in your
sorce
> code ?
>
> whenever i get failures that are situated at the very end of my script how
> do i get to know wherer they start?
>
> now i have get from apache + php  this return
>
> Parse error: parse error, unexpected $ in
> c:\programme\easyphp\www\cms\procede_presse.php on line 268
>
> 268 is the last line of my script how to deal with those failures in an
> intelligent way?
Getting these errors at the last line in your script generally means that
you omitted a closing '}'.

So when you would do :

<?php
function something () {
  print ("done");
?>

You will get a similar error. Check all of your functions and
if/else/foreach/ etc. structures for an omitted '}' to fix your script.\

Good luck!

--
Ivo Fokkema
PHP & MySQL programmer
Leiden University Medical Centre
Netherlands



--- End Message ---
--- Begin Message ---
Hey Thanks you guys... I appreciate your help!
 
Cheers
 
Joe Harman

http://www.HarmanMedia.com

This `telephone' has too many shortcomings to be seriously considered as
a means of communication. The device is inherently of no value to us. -
Western Union internal memo, 1876 
 

--- End Message ---
--- Begin Message ---
On Tuesday, July 29, 2003, at 01:43 PM, erythros wrote:


it depends on what webserver your provider is running. all they have to do
is add .html to the list of files parsed by php.

Thanks! this was enough to get them to fix the problem.


Just to explain the back story. I had a website, that was all in html, and heavily indexed by google. It was generated from templates by python, but then I discovered php, and rebuilt my site with the same URLs but using PHP. Then without notice, my host changed to PHP Suexec, which broke a working site.

On Tuesday, July 29, 2003, at 07:06 PM, Curt Zirzow wrote:

In that case I don't understand why you have two versions of the
same file.  I would suggest to dump the .html files and use only
.php.

I copied the html file to index.php, to make sure the problem was file type, not something more subtle.


thanks again everyone.

joan

--
Joan McGalliard, UK http://www.mcgalliard.org



--- End Message ---
--- Begin Message ---
Nobe, the image.php script starts with <? as the absolute first characters.
Also if I comment out the header function I don't get the header error but I
get the gobbledygook (the picture data I guess). Combine the code in one
script and all is fine, with or without the header function.

Oli


"Rob Adams" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Oli" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I have a function that resizes images. If I put it in the same php file
> that
> > calles it it workes fine. Gives a nice thumbnail or whatever size I
choose
> > to display. If I however put it in a seperate file and include it and
call
> > it I get garbage and the following error:
> >
> > Warning: Cannot modify header information - headers already sent by
> (output
> > started at /home/edal/public_html/album/image.php
> >
> > Here is the resize function (in file image.php):
> > <?
> >   function resize($filepath,$nw = 50,$string = '')
> >     {
> >     header("Content-type: image/jpeg");
>
> The above line is causing your error.  According to the error, it's
> something in your image.php file.  Is there a space or carriage return
> before your opening php tag in image.php?
>
>   -- Rob
>
>
>
> >     $im     = imagecreatefromjpeg($filepath);
> >     $w      = imagesx ($im);
> >     $h      = imagesy ($im);
> >     $nh     = round($h*$nw/$w,0);
> >     $newim  = imagecreatetruecolor($nw,$nh);
> >     $black  = imagecolorallocate($newim, 0, 0, 0);
> >     imagecopyresampled($newim,$im,0,0,0,0,$nw,$nh,$w,$h);
> >     imagestring($newim, 2, 5, 5, $string, $black);
> >     imagedestroy($im);
> >     return $newim;
> >     } ?>
> >
> > and the calling script:
> > <?php
> >   include 'image.php';
> >   $image = resize('Capri.jpg',200,'Capri');
> >   imagejpeg($image);
> >   imagedestroy($image);
> > ?>
> >
> > Any ideas?
> >
> > Oli
> >
> >
>
>



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

i have a site in php but not using database i want to
add the search facilty in that site means user can
search into the contents of the site .so how can i do
that in php without using database.waiting for ur soon
reply

thanks
khuram noman

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

--- End Message ---
--- Begin Message ---
> i have a site in php but not using database i want to
> add the search facilty in that site means user can
> search into the contents of the site .so how can i do
> that in php without using database.waiting for ur soon
> reply

Hello,

- First of all try to get a list of all files (php, html, etc)
- for each file,
    -- get the contents, and then strip_tags($theContentOfOneFile);
    -- try to find whether the keyword to be found is in the contents,
        e.g. use substr_count() store the number of occurences in an array
        $searchArray = array('fileName' => 'number_of_occurences')
- sort the array, e.g. arsort($searchArray)
- display the results
        foreach($searchArray as $fileName => $occurences)
        {
            if ($occurences == 0) break;
            // display as you wish
            echo "Found in $fileName $occurences times<br>";
        }

Hope it helps,
Nadim Attari



--- End Message ---

Reply via email to