php-general Digest 17 Dec 2002 11:06:18 -0000 Issue 1768

Topics (messages 128489 through 128532):

Re: can I mail unlimited in one click?
        128489 by: Kyle Gibson
        128514 by: Greg Donald
        128515 by: Chris Kay

Re: Array
        128490 by: Philip Olson

Put text matching regex into array?
        128491 by: Leif K-Brooks
        128519 by: Jason Wong

undefined index....property.
        128492 by: Bruce Levick
        128495 by: Bruce Levick
        128500 by: Martin Towell

Re: php --with-gd support
        128493 by: Bogdan Stancescu
        128494 by: Bogdan Stancescu

Updating GD
        128496 by: Noodle Snacks
        128518 by: Jason Wong
        128522 by: Noodle Snacks

Re: Divide into words
        128497 by: John W. Holmes

MySQL select a field's first X bytes
        128498 by: Micah Bushouse
        128499 by: Quentin Bennett
        128503 by: Micah Bushouse

Re: Undefined variable
        128501 by: New B
        128509 by: John W. Holmes

Help for Undefined variable
        128502 by: New B

Re: php setup
        128504 by: Justin French

invoking the PHP engine on a single .html file
        128505 by: Krzysztof Wozniak
        128507 by: Justin French

Re: PGP/PHP
        128506 by: Jason Sheets

selecting img file extension.
        128508 by: Bruce Levick
        128510 by: Justin French

Plz help to solve my problem.
        128511 by: Elaine Kwek
        128512 by: Martin Towell
        128513 by: Peter Houchin
        128525 by: Tros

Per instance disable_functions in CGI "mode"
        128516 by: Lic. Rodolfo Gonzalez Gonzalez

[php] INSERT INTO
        128517 by: John Taylor-Johnston
        128521 by: Jason Wong

Number of sessions
        128520 by: fragmonster

Re: XML + XSL
        128523 by: Hristina
        128524 by: Bogomil Shopov

"Use of undefined constant" error
        128526 by: fragmonster
        128527 by: fragmonster
        128529 by: Jon Haworth
        128530 by: Tim Ward

Showing 10 record items per page...?
        128528 by: DavÝ­ Írn Jˇhannsson
        128531 by: Jon Haworth

PHP with GD Support
        128532 by: info.t-host.com

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 wonder if I can mail 300 customers in one click?

part of script:

while($listrow = mysql_fetch_array($listresult))  {

    $recipient = $listrow[epost];
    $subject = "$subj";
    $message = "$mess";
    $headers .= "From: $admail\n";
    $headers .= "Reply-To: $admail\n";
    $headers .= "X-Mailer: PHP\n";
    mail($recipient, $subject, $message, $headers);
}

or is there a limit?

Thanks for any help
Jan Grafstrom

Why not just put all the email address into the BCC header field?


$headers .= "Bcc: $email[0], $email[1],....,$email[n]\n";


Of course the BCC list could be filled programmatically...

--
Kyle Gibson
admin(at)frozenonline.com
http://www.frozenonline.com/

--- End Message ---
--- Begin Message ---
On Mon, 16 Dec 2002,  wrote:
>I wonder if I can mail 300 customers in one click?
>
>part of script:
>
>while($listrow = mysql_fetch_array($listresult))  {
>
>    $recipient = $listrow[epost];
>    $subject = "$subj";
>    $message = "$mess";
>    $headers .= "From: $admail\n";
>    $headers .= "Reply-To: $admail\n";
>    $headers .= "X-Mailer: PHP\n";
>    mail($recipient, $subject, $message, $headers);
>}
>
>or is there a limit?

You may need to increase your max_execution_time, the default seems to be 
30 seconds, pretty low for 300 emails:

>cat `locate php.ini`|grep max_execution_time
max_execution_time = 30     ; Maximum execution time of each script, in 
seconds


--
Greg Donald
http://destiney.com/


--- End Message ---
--- Begin Message ---
I am emailing 150 or so....

--------------------------------------------------------- 
Chris Kay (Systems Development) 
Techex Communications 
Website: www.techex.com.au Email: [EMAIL PROTECTED] 
Telephone: 1300 88 111 2 - Fax: (02) 9970 5788 
---------------------------------------------------------  

-----Original Message-----
From: Greg Donald [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, 17 December 2002 11:40 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] can I mail unlimited in one click?

On Mon, 16 Dec 2002,  wrote:
>I wonder if I can mail 300 customers in one click?
>
>part of script:
>
>while($listrow = mysql_fetch_array($listresult))  {
>
>    $recipient = $listrow[epost];
>    $subject = "$subj";
>    $message = "$mess";
>    $headers .= "From: $admail\n";
>    $headers .= "Reply-To: $admail\n";
>    $headers .= "X-Mailer: PHP\n";
>    mail($recipient, $subject, $message, $headers);
>}
>
>or is there a limit?

You may need to increase your max_execution_time, the default seems to
be 
30 seconds, pretty low for 300 emails:

>cat `locate php.ini`|grep max_execution_time
max_execution_time = 30     ; Maximum execution time of each script, in 
seconds


--
Greg Donald
http://destiney.com/



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

--- End Message ---
--- Begin Message ---
I'm not sure what is meant in this thread but arrays
are pretty simple.  PHP allows both numerical and
associative arrays (although in all reality they all 
are associative) but anyway:

 $arr1 = array('a','b','c', 42 => 'yep');
 print $arr1[0];  // a
 print $arr1[1];  // b
 print $arr1[2];  // c
 print $arr1[42]; // yep

 $arr1[] = 'd';
 print $arr1[43]; // d


 $arr2 = array('a' => 'apple', 'blah');
 print $arr2['a']; // apple
 print $arr2[0];   // blah

Anyway the best way to see what values an array
actually has is with print_r() or var_dump()

 print_r($arr2);

That code quoted from "PHP Bible" has many issues,
it isn't generic at all.  Please ignore it or at
least keep in mind the context of it.  A more
generic form of it:

 function print_keys_and_values($arr) {
     foreach ($arr as $key => $value) {
         print "Key: $key - Value: $value<br>\n";
     }
 }

Please read the following manual entries on arrays:

 http://www.php.net/types.array
 http://www.php.net/foreach

Play around with them for awhile and they'll
eventually make sense.  Regarding the original
question of this thread, see print_r() as I
blame a typo or something... or maybe it's a
variable scope issue.  Your example looks fine.

Regards,
Philip Olson

P.s: Essentially
       numerical   == numbered keys
       associative == worded keys


On Mon, 16 Dec 2002, Andy Turegano wrote:

> I see. Well, in that case I don't really know what to do. Sorry.
> 
> 
> On Tue, 17 Dec 2002, Quentin Bennett wrote:
> 
> > Hi,
> >
> > No I don't think that is right.
> >
> > $monthschedule["Jun"] is not what is being looked for, but 
>$monthschedule[something]="Jun";
> >
> > Try doing a loop to see what is in the array.
> >
> > Example, from PHP Bible,
> >
> > function print_keys_and_values_each($arr)
> > {
> >    reset($arr);
> >    while ($cell = each($arr))
> >    {
> >       $c = $cell['value'];
> >       $k = $cell['key'];
> >       print ("Key: $k; Value: $c<BR>");
> >    }
> > }
> >
> >
> > Quentin
> >
> > -----Original Message-----
> > From: Andy Turegano [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, 17 December 2002 10:25 a.m.
> > To: Mako Shark
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: [PHP] Array
> >
> >
> > What you have to do, at least I think, is you have to type:
> > $r = $monthschedule["Jun"];
> >
> > That is what I think you have to do. The other way you did it was when you
> > have a value-only array.
> >
> >
> > On Mon, 16 Dec 2002, Mako Shark wrote:
> >
> > > I have an array I set up like this:
> > >
> > > $monthschedule = array(1 => "Jan", 2 => "Feb", 3 =>
> > > "Mar", 6 => "Jun");
> > >
> > > When I try to access them, doing this:
> > > $r = $monthschedule[6];
> > >
> > > nothing comes up ($r is blank). Any thoughts? There
> > > are missing elements (4,5,7-12) in $monthschedule.
> > >
> > > __________________________________________________
> > > Do you Yahoo!?
> > > Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> > > http://mailplus.yahoo.com
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> > The information contained in this email is privileged and confidential and
> > intended for the addressee only. If you are not the intended recipient, you
> > are asked to respect that confidentiality and not disclose, copy or make use
> > of its contents. If received in error you are asked to destroy this email
> > and contact the sender immediately. Your assistance is appreciated.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 




--- End Message ---
--- Begin Message --- Is there a way to put each part of a string matching a regex into an array? Example:
$string = "-----_-_--- --_-_-- random text here-_";
$array = regextoarray($string,"[-_]{1,}");
//Produces array of "-----_-_---","--_-_--","-_"

--
The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.


--- End Message ---
--- Begin Message ---
On Tuesday 17 December 2002 09:05, Leif K-Brooks wrote:
> Is there a way to put each part of a string matching a regex into an
> array?  Example:
> $string = "-----_-_--- --_-_-- random text here-_";
> $array = regextoarray($string,"[-_]{1,}");
> //Produces array of "-----_-_---","--_-_--","-_"

preg_match()

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
America may be unique in being a country which has leapt from barbarism
to decadence without touching civilization.
                -- John O'Hara
*/

--- End Message ---
--- Begin Message ---
I have just setup my localmachine to see how our site runs on php 4.2.
It currently runs on 4.1 on the server. I am only fairly new to this so
I have come across a slight hurdle.

At first logging in as a user to the database was giving "undefined
variable" error. Have read up on this and fixed it by turning on
register_globals. So that's sweet. Although my other form page is for
joining up, which sends variables to another page and then in turn sends
the info to the database. The info that the user fills out gets passed
ok cept  I get two errors output to the page.

//////////filled out info and clicked send.

Notice: Undefined index: license in c:\inetpub\wwwroot\php\config.php on
line 51

Notice: Undefined property: num_rows in
c:\inetpub\wwwroot\php\adcjoin.php on line 67


//////////////////////////////////////////

////This is my action on the submit page

<FORM action="php/adcjoin.php" method=post>

////////////////////////////////////////


////////////////////////////////The undefined property is in the
adcjoinpage.php

$db->query("SELECT Username FROM global WHERE
(Username='".$Username."')");

        if ($db->num_rows>0){

                array_push($error,"Choose another <b>username</b>, this
name is reserved<br>\n");

                $flag = 1;

        }


///////////////////////attatched to adcjoin.php

require("connect.php");


//////////////////////////////////////////
Config file called on by connect.php contains a license variable.
//////////////////////////////////////////

I Am not quite sure why it is outputting these two errors. I have not
changed anything from downloading it off the server....apart from
targeting the database on my local machine now. Is it possibly a session
error??

If anybody has any thoughts please pass them on.

Cheers Bruce
--- End Message ---
--- Begin Message ---
Sorry I did not mention.
My local machine is WinXP pro, running php 4.2 and mysql 3.23.
--- End Message ---
--- Begin Message ---
you didn't send the code snippet for "Undefined index"
however, I think the reason you're getting these errors at home is because
you have a different error_reporting level.

HTH a bit
Martin

[snip]

//////////filled out info and clicked send.

Notice: Undefined index: license in c:\inetpub\wwwroot\php\config.php on
line 51

Notice: Undefined property: num_rows in
c:\inetpub\wwwroot\php\adcjoin.php on line 67


//////////////////////////////////////////

[snip]
--- End Message ---
--- Begin Message ---
ok

[EMAIL PROTECTED] wrote:
Hello List,

I want to know all about copiling, installing and configuring php with gd-support.

Anybody knows a good site or book to read about?
Oliver Etzel


--- End Message ---
--- Begin Message --- Sorry, I only saw the first line in your message ("I want to know all about...") - somehow assumed the 2nd to be part of the sig on first reading - and hurried to be cynical.

Can't help you with a good site/book. Why don't you RTFM instead? :)

Bogdan

[EMAIL PROTECTED] wrote:
Hello List,

I want to know all about copiling, installing and configuring php with gd-support.

Anybody knows a good site or book to read about?
Oliver Etzel


--- End Message ---
--- Begin Message ---
PHP is telling me that I need GD 2.0 or later. This is on a newly installed
mandrake 9 distro. Could this be a configuration issue? or do I need to
figure out how to update GD?



I get these errors:

Warning: imagecreatetruecolor(): requires GD 2.0 or later in
/var/www/html/golgo13/includes/img.class.php on line 55

Warning: imagecopyresampled(): requires GD 2.0 or later in
/var/www/html/golgo13/includes/img.class.php on line 56

Warning: imagedestroy(): supplied argument is not a valid Image resource in
/var/www/html/golgo13/includes/img.class.php on line 73

Warning: imagedestroy(): supplied argument is not a valid Image resource in
/var/www/html/golgo13/includes/img.class.php on line 74

When I run this script:

 $image = new image;
 $image->max_size = 300;
 $image->upload($data, $data_type);

Here are the relevent class functions:

function load_gd()
  {// Checks to see if GD has been loaded. If not it loads the dll/so file
     if (!extension_loaded('gd'))
   {
         if (!dl('gd.so'))
     {
             if (!dl('gd.dll'))
         {
                exit;
             }
         }
      }

  }

  function resize()
  {// Resizes Image to be within maximum size, could be expanded to have
seperate width and height values.
     $this->load_gd();// Check that gd is loaded and availible.
    $size = GetImageSize($this->temp_loc);
     $width = $size[0];
   $height = $size[1];

   if(($width > $this->max_size) || ($height > $this->max_size))
   {
      switch ($pictype)
         {
            case "image/gif";
               $this->src_img = ImageCreateFromGif($picdata);
            break;
            case "image/jpeg";
               $this->src_img = ImageCreateFromJpeg($picdata);
            break;
            case "image/png";
               $this->src_img = ImageCreateFromPng($picdata);
            break;
            default:
                $mimeName = "Unknown image type, failed";
         }
         $orig_x = $width;
         $orig_y = $height;

         $new_y = $this->max_size;
         $new_x = $orig_x/($orig_y/$this->max_size);

      $dst_img = ImageCreateTrueColor($new_x,$new_y);
         ImageCopyResampled($dst_img, $this->temp_loc, 0, 0, 0, 0, $new_x,
$new_y, $orig_x, $orig_y);

     switch ($pictype)
       {
          case "image/gif";
         $this->src_img = imagepng ($dst_img);
             break;
          case "image/jpeg";
             $this->src_img = imagejpeg($dst_img);
             break;
          case "image/png";
             $this->src_img = imagepng ($dst_img);
             break;
          default:
             $mimeName = "Unknown image type, failed";
          }
         $this->picdata = $dst_img;
         ImageDestroy($src_img);
         ImageDestroy($dst_img);
       }
  }


--- End Message ---
--- Begin Message ---
On Tuesday 17 December 2002 10:19, Noodle Snacks wrote:
> PHP is telling me that I need GD 2.0 or later. This is on a newly installed
> mandrake 9 distro. Could this be a configuration issue? or do I need to
> figure out how to update GD?

If you want to use those functions, then yes, you need to figure out a way to 
update GD.

> I get these errors:
>
> Warning: imagecreatetruecolor(): requires GD 2.0 or later in
> /var/www/html/golgo13/includes/img.class.php on line 55
>
> Warning: imagecopyresampled(): requires GD 2.0 or later in
> /var/www/html/golgo13/includes/img.class.php on line 56


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
What you don't know can hurt you, only you won't know it.
*/

--- End Message ---
--- Begin Message ---
Cool,

Just thought it might be a config / code issue or something.



"Jason Wong" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Tuesday 17 December 2002 10:19, Noodle Snacks wrote:
> > PHP is telling me that I need GD 2.0 or later. This is on a newly
installed
> > mandrake 9 distro. Could this be a configuration issue? or do I need to
> > figure out how to update GD?
>
> If you want to use those functions, then yes, you need to figure out a way
to
> update GD.
>
> > I get these errors:
> >
> > Warning: imagecreatetruecolor(): requires GD 2.0 or later in
> > /var/www/html/golgo13/includes/img.class.php on line 55
> >
> > Warning: imagecopyresampled(): requires GD 2.0 or later in
> > /var/www/html/golgo13/includes/img.class.php on line 56
>
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> What you don't know can hurt you, only you won't know it.
> */
>


--- End Message ---
--- Begin Message ---
> > For example i have some words:
> >
> > Today is very beautiful day and sun is shining
> >
> > What i want to get from this is array
> >
> > words
> >  [Today] => 0
> >  [Is] => 6,30
> >  [Very] => 8
> >  [beautiful] => 12
> >  ......
> >
> > Can somebody please help me with this. Those nubers are
> > position of special word in above sentence. If word repeates
> > i want to have both positions saved in same row like word is.
> >
> > I tried something but i think it's to lame.
> >
> >
> 
> how about ...
> 
> <?
> 
> $sentance = "Today is   a beautiful day. ";
> $temp = preg_replace("/[^a-zA-Z]+/", " ", $sentance);
> $temp = explode(' ', $temp);
> $words = array_count_values($temp);
> 
> print_r($words);

Nope. The question was the position of the words, not how many times
they appear. 

---John Holmes...


--- End Message ---
--- Begin Message ---
Is there a way in MySQL to select a fields first X bytes?

I have a field of type text.  I would like to print the first 500 or so
bytes of its contents as a summary of the entire field, then having the user
click "read more..." or something of that sort for the whole document.

I read up on select in the MySQL manual and didn't see much, does anyone out
there know of such a feature?  Should I just take the whole field into php
and do it that way?

thanks,
Micah Bushouse


--- End Message ---
--- Begin Message ---
What's wrong with 

select left(myfield, 500) from mytable;

?

Quentin

-----Original Message-----
From: Micah Bushouse [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 17 December 2002 3:22 p.m.
To: [EMAIL PROTECTED]
Subject: [PHP] MySQL select a field's first X bytes


Is there a way in MySQL to select a fields first X bytes?

I have a field of type text.  I would like to print the first 500 or so
bytes of its contents as a summary of the entire field, then having the user
click "read more..." or something of that sort for the whole document.

I read up on select in the MySQL manual and didn't see much, does anyone out
there know of such a feature?  Should I just take the whole field into php
and do it that way?

thanks,
Micah Bushouse



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

The information contained in this email is privileged and confidential and
intended for the addressee only. If you are not the intended recipient, you 
are asked to respect that confidentiality and not disclose, copy or make use 
of its contents. If received in error you are asked to destroy this email 
and contact the sender immediately. Your assistance is appreciated.
--- End Message ---
--- Begin Message ---
Thanks a lot!

I'm just blind!

"Quentin Bennett" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
o.nz...
What's wrong with

select left(myfield, 500) from mytable;

?

Quentin

-----Original Message-----
From: Micah Bushouse [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 17 December 2002 3:22 p.m.
To: [EMAIL PROTECTED]
Subject: [PHP] MySQL select a field's first X bytes


Is there a way in MySQL to select a fields first X bytes?

I have a field of type text.  I would like to print the first 500 or so
bytes of its contents as a summary of the entire field, then having the user
click "read more..." or something of that sort for the whole document.

I read up on select in the MySQL manual and didn't see much, does anyone out
there know of such a feature?  Should I just take the whole field into php
and do it that way?

thanks,
Micah Bushouse



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

The information contained in this email is privileged and confidential and
intended for the addressee only. If you are not the intended recipient, you
are asked to respect that confidentiality and not disclose, copy or make use
of its contents. If received in error you are asked to destroy this email
and contact the sender immediately. Your assistance is appreciated.


--- End Message ---
--- Begin Message ---
Please help!  I am a beginner of php, I got an error from my own webpage:

Notice: Undefined variable: Array in C:\Inetpub\wwwroot\php\HandleForm.php
on line 23
Please enter a valid Web address!

Below is my code:

<?
function WriteToFile ($URL, $Description) {
 /* Function WriteToFile takes two arguments--URL and Description--Which
will be written to an external file. */
  $TheFile = "C:\Inetpub\wwwroot\php\data.txt";
  $Open = fopen ($TheFile, "a");
  if ($Open) {
   fwrite ($Open,"$URL\t$Description\n");
   fclose ($Open);
   $Worked = TRUE;
 } else {
   $Worked = FALSE;
 }
 return $Worked;
}// End of WriteToFile Function.
?>
<HTML>
<HEAD>
<TITLE>Using Files</Title>
<BODY>
<?php
/* This page receives and handles the data generated by "form.html". */
$Pattern = "(http://)?([^[:space:]]+)([[:alnum:]\.,-_?/&=])";
if (eregi($Pattern, $Array["URL"])) {
<---------------------------------------------------------That is line 23
 $Replace = "<a href=\"http://\\2\\3\"target=\"_new\";>\\2\\3</a>";
 $Array["URL"] = eregi_replace($Pattern, $Replace, $Array["URL"]);
 $CallFunction = WriteToFile ($Array["URL"], $Array["Description"]);
 if ($CallFunction) {
  print("Your submision--$Array[URL]--has been received!<BR>\n");
 } else {
   print ("Your submission was not processed due to a system error!<BR>\n");
  }
 } else {
   print ("Please enter a valid Web address!\n");
}
?>
</BODY>
</HTML>



--- End Message ---
--- Begin Message ---
Don't double post and do a little thinking for yourself. The error is
undefined variable: Array. That means that where you are using
$Array["URL"], it doesn't have a value, it's, "undefined". Where is
$Array coming from, or where do you think it's coming from?

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

> -----Original Message-----
> From: New B [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 16, 2002 9:44 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Help: Undefined variable
> 
> Please help!  I am a beginner of php, I got an error from my own
webpage:
> 
> Notice: Undefined variable: Array in
C:\Inetpub\wwwroot\php\HandleForm.php
> on line 23
> Please enter a valid Web address!
> 
> Below is my code:
> 
> <?
> function WriteToFile ($URL, $Description) {
>  /* Function WriteToFile takes two arguments--URL and
Description--Which
> will be written to an external file. */
>   $TheFile = "C:\Inetpub\wwwroot\php\data.txt";
>   $Open = fopen ($TheFile, "a");
>   if ($Open) {
>    fwrite ($Open,"$URL\t$Description\n");
>    fclose ($Open);
>    $Worked = TRUE;
>  } else {
>    $Worked = FALSE;
>  }
>  return $Worked;
> }// End of WriteToFile Function.
> ?>
> <HTML>
> <HEAD>
> <TITLE>Using Files</Title>
> <BODY>
> <?php
> /* This page receives and handles the data generated by "form.html".
*/
> $Pattern = "(http://)?([^[:space:]]+)([[:alnum:]\.,-_?/&=])";
> if (eregi($Pattern, $Array["URL"])) {
> <---------------------------------------------------------That is line
23
>  $Replace = "<a href=\"http://\\2\\3\"target=\"_new\";>\\2\\3</a>";
>  $Array["URL"] = eregi_replace($Pattern, $Replace, $Array["URL"]);
>  $CallFunction = WriteToFile ($Array["URL"], $Array["Description"]);
>  if ($CallFunction) {
>   print("Your submision--$Array[URL]--has been received!<BR>\n");
>  } else {
>    print ("Your submission was not processed due to a system
> error!<BR>\n");
>   }
>  } else {
>    print ("Please enter a valid Web address!\n");
> }
> ?>
> </BODY>
> </HTML>
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Please help!  I am a beginner of php, I got an error from my own webpage:

Notice: Undefined variable: Array in C:\Inetpub\wwwroot\php\HandleForm.php
on line 23
Please enter a valid Web address!

Below is my code:

<?
function WriteToFile ($URL, $Description) {
 /* Function WriteToFile takes two arguments--URL and Description--Which
will be written to an external file. */
  $TheFile = "C:\Inetpub\wwwroot\php\data.txt";
  $Open = fopen ($TheFile, "a");
  if ($Open) {
   fwrite ($Open,"$URL\t$Description\n");
   fclose ($Open);
   $Worked = TRUE;
 } else {
   $Worked = FALSE;
 }
 return $Worked;
}// End of WriteToFile Function.
?>
<HTML>
<HEAD>
<TITLE>Using Files</Title>
<BODY>
<?php
/* This page receives and handles the data generated by "form.html". */
$Pattern = "(http://)?([^[:space:]]+)([[:alnum:]\.,-_?/&=])";
if (eregi($Pattern, $Array["URL"])) {
<---------------------------------------------------------That is line 23
 $Replace = "<a href=\"http://\\2\\3\"target=\"_new\";>\\2\\3</a>";
 $Array["URL"] = eregi_replace($Pattern, $Replace, $Array["URL"]);
 $CallFunction = WriteToFile ($Array["URL"], $Array["Description"]);
 if ($CallFunction) {
  print("Your submision--$Array[URL]--has been received!<BR>\n");
 } else {
   print ("Your submission was not processed due to a system error!<BR>\n");
  }
 } else {
   print ("Please enter a valid Web address!\n");
}
?>
</BODY>
</HTML>



Thanks,

New B


--- End Message ---
--- Begin Message ---
Check phpinfo() on both the new and old server -- i think the var not
defined stuff is related to a different (higher) error reporting directive
on the laptop.

As for the images, view the actual SOURCE of the resultant HTML page
(browser > view source) and see how the image src's are being written, then
check for the files directly -- my guess is you're dynamically writing the
image URLs, and something is breaking (possibly needs register globals ON in
php.ini).



on 17/12/02 6:29 AM, Edward Peloke ([EMAIL PROTECTED]) wrote:

> I recently got a laptop and was in the process this weekend of installing,
> php, apache, mysql etc.  One thing I noticed is when I ran the code (that
> works fine everywhere else) on the laptop, I got errors of 'Variable not
> defined' and I have pictures that just won't show.  I am not sure if this is
> the problem but most of the scripts giving the 'Variable not defined problem
> and the images where in other folders and referenced in the php page like
> /images/picture.gif and /includes/template1.inc.  Is there something I need
> to look at in my config file?
> 
> Thanks,
> Eddie
> 

Justin French
--------------------
http://Indent.com.au
Web Development & 
Graphic Design
--------------------

--- End Message ---
--- Begin Message ---
Is there any possibility to invoke the PHP engine on a single, specific
file? I mean, I know I can ask PHP politely to treat every .html file as
a PHP file, but it will slow down the whole server. Can the PHP engine
be invoked locally (by folder) or preferably on a single file? 
 
Thanks,
 
Krzysztof
 
--- End Message ---
--- Begin Message ---
a .htaccess file in your document tree, anywhere above the file in question

<Files name-of-your-html-page.html>
    ForceType application/x-httpd-php
</Files>

(assuming apache server)


on 17/12/02 2:38 PM, Krzysztof Wozniak ([EMAIL PROTECTED]) wrote:

> Is there any possibility to invoke the PHP engine on a single, specific
> file? I mean, I know I can ask PHP politely to treat every .html file as
> a PHP file, but it will slow down the whole server. Can the PHP engine
> be invoked locally (by folder) or preferably on a single file?
> 
> Thanks,
> 
> Krzysztof
> 
> 

Justin French
--------------------
http://Indent.com.au
Web Development & 
Graphic Design
--------------------

--- End Message ---
--- Begin Message ---
There is actually a gpg PHP module available that makes gpg easy
functions available to PHP so you do not need to execute command line
programs on plain text files.

Remember if you write your data to a plain text file it will temporarily
be vunerable to interception by anyone with read access to the file on
your web server. With PHP that means at least: the administrators of the
machine and any other user on the web server or PHP script being run.

There module is available at http://sourceforge.net/projects/gpgext/,
here is the description:

GPGext is a extension (module) for PHP, written in C, to support GPG
manipulation. It use the GPG Made Easy library, and ports all of its
functions to PHP, including generating, listing, exporting, and
importing of keys, and encrypting and decrypting data. An GUI created
with PHP-Gtk is also included to show how this extension works. PHP
examples and documentation are also included. 

Of course a plain text command line solution may be easier to implement
however I would avoid implementing that one myself unless you have a
high trust level of the server and know the time between writing the
file out, encrypting it and wiping it will be small.

Jason


On Mon, 2002-12-16 at 03:57, David T-G wrote:
> Jonathan --
> 
> ...and then Jonathan said...
> % 
> % I have necessary PGP client software on my machine and have tested the
> % functionality of PGP from my site, however, I want to know how to use
> % PHP to send a PGP email.
> 
> 1) Do you know how to use pgp to encrypt and decrypt a file?
> 
> 2) Do you know how pgp is used by a mail user agent to encrypt a mail
> message?
> 
> 
> % 
> % This is the scenario, 
> % 
> % I have a shopping cart which directs to SSL, then while in SSL, the
> % customer will input their information, including credit card info. 
> 
> OK.
> 
> In general, you send a mail message to someone with the mail() function,
> and many people choose to predefine their headers, recipient, and content.
> To wit:
> 
> [From the manual:]
>   mail
>      (PHP 3, PHP 4 )
>      mail -- send mail
>   Description
>      bool mail ( string to, string subject, string message [, string
>      additional_headers [, string additional_parameters]])
> 
> and
> 
>   <?php
>     $to = "[EMAIL PROTECTED]" ;
>     $subject = "this is a message" ;
>     $headers = "From: [EMAIL PROTECTED]\nX-Stuff: another header\n" ;
>     $body = "This is my message body.\n\nThere; that was fun.\n" ;
>     mail($to,$subject,$message,$headers) ;
>   ?>
> 
> All you have to do is encrypt your message body and then paste that into
> this example as $body.  You could do it either by capturing $body or just
> doing an inline replacement.  To wit:
> 
>   bash-2.05a$ echo "this is text" \
>     | gpg --encrypt --armor --recipient 7B9F4700 \
>     | gpg --armor --decrypt
>   
>   You need a passphrase to unlock the secret key for
>   user: "David T-G <[EMAIL PROTECTED]>"
>   2048-bit ELG-E key, ID 1AEFE05A, created 2001-12-16 (main key ID
>   7B9F4700)
>   
>   gpg: encrypted with 2048-bit ELG-E key, ID 1AEFE05A, created 2001-12-16
>         "David T-G <[EMAIL PROTECTED]>"
>   this is text
> 
> Of course, leaving off the decrypt side will spit out a lovely encrypted
> text block -- but that takes up more lines to demo :-)
> 
> 
> % 
> % I want to show a receipt, (no cc #'s of course) and send the order to an
> % administrator of the site using PGP after all the information has been
> % gathered and send it from SSL. The site's admin will be able decrypt the
> % information using the client software.
> 
> So the site's admin will get a encrypted mail message, right?  What's
> this about no cc number -- you won't print one on the receipt, or you
> won't give one to the admin, or the receipt without the number is what
> the admin gets?
> 
> 
> % 
> % 
> % Thanks in advance.
> 
> HTH & HAND
> 
> 
> :-D
> -- 
> David T-G                      * There is too much animal courage in 
> (play) [EMAIL PROTECTED] * society and not sufficient moral courage.
> (work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
> http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
> 

--- End Message ---
--- Begin Message ---
Sorry for the newbie question.
I am an artist and entering my pieces into a database....basically all
that will be displaying will be

Title:
Medium:
Date Created:
and an image (.gif, .jpg, .swf)

I want to know what is the best way to call a specific image type.???
Should I give each image file extension a column |.gif | .jpg | .swf |
and set that all these columns to only display when asked??

So for an example case. I have a piece of artwork Called Cheetah.

Title: Cheetah
Medium: Water Color
Date Created: 1998
cheetah.jpg

How do I set up my table so when I add this piece to my databse I can
select .jpeg extension to true.....so to speak, and leave gif and swf
false.

My image source might be (i know the coding will be wrong) <img
src="images/?title? . ?ext?"> (cheetah.jpg).

Cheers 
  
--- End Message ---
--- Begin Message ---
I would definitely store the file type (either extension or mime-type) of
the files.

Justin

on 17/12/02 3:27 PM, Bruce Levick ([EMAIL PROTECTED]) wrote:

> 
> Sorry for the newbie question.
> I am an artist and entering my pieces into a database....basically all
> that will be displaying will be
> 
> Title:
> Medium:
> Date Created:
> and an image (.gif, .jpg, .swf)
> 
> I want to know what is the best way to call a specific image type.???
> Should I give each image file extension a column |.gif | .jpg | .swf |
> and set that all these columns to only display when asked??
> 
> So for an example case. I have a piece of artwork Called Cheetah.
> 
> Title: Cheetah
> Medium: Water Color
> Date Created: 1998
> cheetah.jpg
> 
> How do I set up my table so when I add this piece to my databse I can
> select .jpeg extension to true.....so to speak, and leave gif and swf
> false.
> 
> My image source might be (i know the coding will be wrong) <img
> src="images/?title? . ?ext?"> (cheetah.jpg).
> 
> Cheers 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

Justin French
--------------------
http://Indent.com.au
Web Development & 
Graphic Design
--------------------

--- End Message ---
--- Begin Message ---
I am now trying to use php session control in my web application. i try to
copy a coding an test it...but it come out error. i not sure how to solve
it. Plz help me...I using Apache server.

the code sample is like this:

<?

  session_start();
  session_register("sess_var");

  $sess_var = "Hello world!";

  echo "The content of \$sess_var is $sess_var<br>";

?>


And this is the result of the page:

Warning: open(/tmp\sess_c0fe7c6a4524488a979e20d90b2eebb2, O_RDWR) failed: No
such file or directory (2) in c:\Program Files\Apache
Group\Apache\htdocs\Office_Management_System\tmp\page1.php on line 3

The content of $sess_var is Hello world!

Warning: open(/tmp\sess_c0fe7c6a4524488a979e20d90b2eebb2, O_RDWR) failed: No
such file or directory (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the
current setting of session.save_path is correct (/tmp) in Unknown on line 0


thanx to whom reply to me...

Elaine Kwek

--- End Message ---
--- Begin Message ---
>From this error

Warning: Failed to write session data (files). Please verify that the
current setting of session.save_path is correct (/tmp) in Unknown on line 0

It looks like you'll have to change php.ini to have session.save_path point
to a valid path. Maybe \temp\  ?

HTH
Martin

-----Original Message-----
From: Elaine Kwek [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 17, 2002 4:08 PM
To: PHP
Subject: [PHP] Plz help to solve my problem.


I am now trying to use php session control in my web application. i try to
copy a coding an test it...but it come out error. i not sure how to solve
it. Plz help me...I using Apache server.

the code sample is like this:

<?

  session_start();
  session_register("sess_var");

  $sess_var = "Hello world!";

  echo "The content of \$sess_var is $sess_var<br>";

?>


And this is the result of the page:

Warning: open(/tmp\sess_c0fe7c6a4524488a979e20d90b2eebb2, O_RDWR) failed: No
such file or directory (2) in c:\Program Files\Apache
Group\Apache\htdocs\Office_Management_System\tmp\page1.php on line 3

The content of $sess_var is Hello world!

Warning: open(/tmp\sess_c0fe7c6a4524488a979e20d90b2eebb2, O_RDWR) failed: No
such file or directory (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the
current setting of session.save_path is correct (/tmp) in Unknown on line 0


thanx to whom reply to me...

Elaine Kwek


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
you will need to say what drive the temp folder is on so c:\temp\ in the
php.ini

> -----Original Message-----
> From: Martin Towell [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, 17 December 2002 4:11 PM
> To: 'Elaine Kwek'; PHP
> Subject: RE: [PHP] Plz help to solve my problem.
>
>
> From this error
>
> Warning: Failed to write session data (files). Please verify that the
> current setting of session.save_path is correct (/tmp) in Unknown
> on line 0
>
> It looks like you'll have to change php.ini to have
> session.save_path point
> to a valid path. Maybe \temp\  ?
>
> HTH
> Martin
>
> -----Original Message-----
> From: Elaine Kwek [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 17, 2002 4:08 PM
> To: PHP
> Subject: [PHP] Plz help to solve my problem.
>
>
> I am now trying to use php session control in my web application. i try to
> copy a coding an test it...but it come out error. i not sure how to solve
> it. Plz help me...I using Apache server.
>
> the code sample is like this:
>
> <?
>
>   session_start();
>   session_register("sess_var");
>
>   $sess_var = "Hello world!";
>
>   echo "The content of \$sess_var is $sess_var<br>";
>
> ?>
>
>
> And this is the result of the page:
>
> Warning: open(/tmp\sess_c0fe7c6a4524488a979e20d90b2eebb2, O_RDWR)
> failed: No
> such file or directory (2) in c:\Program Files\Apache
> Group\Apache\htdocs\Office_Management_System\tmp\page1.php on line 3
>
> The content of $sess_var is Hello world!
>
> Warning: open(/tmp\sess_c0fe7c6a4524488a979e20d90b2eebb2, O_RDWR)
> failed: No
> such file or directory (2) in Unknown on line 0
>
> Warning: Failed to write session data (files). Please verify that the
> current setting of session.save_path is correct (/tmp) in Unknown
> on line 0
>
>
> thanx to whom reply to me...
>
> Elaine Kwek
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--- End Message ---
--- Begin Message ---
Please verify that the current setting ( in php.ini ) of session.save_path
is correct (/tmp):

You must have a folder as indicated in php.ini.

Tros

"Elaine Kwek" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I am now trying to use php session control in my web application. i try to
> copy a coding an test it...but it come out error. i not sure how to solve
> it. Plz help me...I using Apache server.
>
> the code sample is like this:
>
> <?
>
>   session_start();
>   session_register("sess_var");
>
>   $sess_var = "Hello world!";
>
>   echo "The content of \$sess_var is $sess_var<br>";
>
> ?>
>
>
> And this is the result of the page:
>
> Warning: open(/tmp\sess_c0fe7c6a4524488a979e20d90b2eebb2, O_RDWR) failed:
No
> such file or directory (2) in c:\Program Files\Apache
> Group\Apache\htdocs\Office_Management_System\tmp\page1.php on line 3
>
> The content of $sess_var is Hello world!
>
> Warning: open(/tmp\sess_c0fe7c6a4524488a979e20d90b2eebb2, O_RDWR) failed:
No
> such file or directory (2) in Unknown on line 0
>
> Warning: Failed to write session data (files). Please verify that the
> current setting of session.save_path is correct (/tmp) in Unknown on line
0
>
>
> thanx to whom reply to me...
>
> Elaine Kwek
>


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

some weeks ago I asked if it was possible to have a per apache-virtualhost
disable_functions list. Rasmus answered that this is not possible since
the interpreter is initialized once, and it'd be too expensive to reload
the config.

But, what about PHP as CGI?. I guess the disable_functions parameter still
applies for the php.ini only, but what if I create several php binaries,
each one with a different path to php.ini (kind of a mess if I have
several virtual hosts, I know, but I only wanna know if this setup is
possible :-) ). I guess that I could have then one disable_functions list
per CGI binarie, right?. I know that I'd need to prepend the #!/.../php
line to every script, but only once (I would not run /cgi-bin/php.cgi).

Regards.


--- End Message ---
--- Begin Message ---
Yes I'm reading the FM :) http://www.php.net/manual/en/ref.mysql.php

I should know this. How will I PHP this SQL into my MySQL table?

INSERT INTO testals VALUES ($part1, $part2, $part3, $part4);

I'm particularily concerned aboute single quotes. How do I escape them? Should I?

Here is what I think is right.

----------snip----------
$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);

$query = "INSERT INTO testals VALUES (addslashes($part1), addslashes($part2), 
addslashes($part3), addslashes($part4));";

mysql_query($query);

mysql_close($myconnection);
----------snip----------

That's it, right? I have about 40 variables. I wanted to run the code through here 
before I start.

Thanks,
John

--- End Message ---
--- Begin Message ---
On Tuesday 17 December 2002 15:12, John Taylor-Johnston wrote:

> I'm particularily concerned aboute single quotes. How do I escape them?
> Should I?
>
> Here is what I think is right.
>
> ----------snip----------
> $myconnection = mysql_connect($server,$user,$pass);
> mysql_select_db($db,$myconnection);
>
> $query = "INSERT INTO testals VALUES (addslashes($part1),
> addslashes($part2), addslashes($part3), addslashes($part4));";

Functions inside a string would have no effect. Do this instead:

  $part1 = addslashes($part1); 
  ...
  ...
  $query = "INSERT INTO testals VALUES ($part1,...

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
I'm sitting on my SPEED QUEEN ... To me, it's ENJOYABLE ... I'm WARM
... I'm VIBRATORY ...
*/

--- End Message ---
--- Begin Message ---
Hello,
Is there a way to count how many sessions are opened on a PHP web site?

--- End Message ---
--- Begin Message ---
Hello falks!
I could not enter javascript into my xsl file.
Does anyone know how to do it?

Thanks a lot


--- End Message ---
--- Begin Message ---
<xsl:script language="javascript">
<![CDATA[
pos = 0;
function getpos(spos){
        epos = spos + 4;
        pos = pos + 1;
        if(pos >= spos && pos <= epos){
                return true;
        }else{
                return false;
        }
}
]]>
        </xsl:script>





--- End Message ---
--- Begin Message --- Hello,
I've got a strange pb. Here's my code

<?
if(isset($_GET[id])){
do something...
else
do something else
}
?>

When I call myfile.php I've got the "somthing else" with no error.
When I call myfile.php?id=1 I've got the "something" but with an error message "Notice: Use of undefined constant id - assumed 'id' in ..."

Please help

--- End Message ---
--- Begin Message --- Hello,
I've got a strange pb. Here's my code

<?
if(isset($_GET[id])){
do something...
else
do something else
}
?>

When I call myfile.php or myfile.php?id=1 I've got an error message "Notice: Use of undefined constant id - assumed 'id' in ..."

Please help

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

> "Notice: Use of undefined constant id - assumed 'id' in ..."

Try changing this:

> if(isset($_GET[id])){

to this:
  if(isset($_GET['id'])) { 
                 ^^^^
              note quotes

PHP thinks you're trying to use a constant called "id", which you haven't
defined - hence the "undefined constant" error ;-)

Note how the message says "assumed 'id'", which is what you should change it
to - this shouldn't stop your script from running, as the parser can work
out what you meant, but your error reporting is set sufficiently high that
PHP lets you know about it.

Cheers
Jon

--- End Message ---
--- Begin Message ---
you've got error reporting set pretty high to get that.
The correct way to reference an array element in this case
is $_GET["id"], if you do $_GET[id] you are telling PHP
to look for a constant called id. If it doesn't find one then
it assumes you meant "id" onstead of id and proceeds 
accordingly. Thats why you can get away with not using the 
quote marks (as long as there's no white space in the string).

On a live site (and, I'd have thought, most default set-ups) 
you'd expect error reporting to be set all off and you'd 
never see the message.

Tim Ward
http://www.chessish.com
mailto:[EMAIL PROTECTED]
----- Original Message ----- 
From: fragmonster <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 17, 2002 10:49 AM
Subject: [PHP] "Use of undefined constant" error


> Hello,
> I've got a strange pb. Here's my code
> 
> <?
> if(isset($_GET[id])){
>      do something...
> else
>      do something else
> }
> ?>
> 
> When I call myfile.php or myfile.php?id=1 I've got an error message 
> "Notice: Use of undefined constant id - assumed 'id' in ..."
> 
> Please help
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
I need to be able to show maybe 10 items that I query from a mysql
database on each page and Iĺm not really sure how I can do this.
 
If I have lets say 30 items that match the query, I would like the page
to display this at the bottom 
 
Previous 10  page 1 2 3  Next 10 of 30
 
 
Can any one direct me in the right direction to make this possable?
 
Regards, David
--- End Message ---
--- Begin Message ---
Hi David,

> If I have lets say 30 items that match the query, 
> I would like the page to display this at the bottom 
>  
> Previous 10  page 1 2 3  Next 10 of 30

To get the 20 results starting at #100, your query will be something like
"SELECT foo FROM bar LIMIT 100, 20"

To do paged results with MySQL, have a variable (called $start or something)
that keeps track of how many pages into the results you are, and increment
or decrement it in the next and previous page links:

<a href="results.php?start=<?=($start-1)?>">previous</a>
<a href="results.php?start=<?=($start+1)?>">next</a>

And construct your query along these lines:
  SELECT foo FROM bar LIMIT ($start * 20), 20

Hope this gets you started. 

Cheers
Jon


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

ich want to install php.4.2.3 with gd-suport. Any hints are welcome.

Oliver Etzel
--- End Message ---

Reply via email to