php-general Digest 30 Dec 2003 11:32:19 -0000 Issue 2502

Topics (messages 173454 through 173477):

Re: Selecting between using letters
        173454 by: Vail, Warren

Has anyone installed AWF 1.10??  I need some help
        173455 by: Student

HTML via echo or not
        173456 by: Robin Kopetzky
        173457 by: Larry Brown
        173458 by: Jordan S. Jones
        173459 by: Robert Cummings
        173460 by: Robert Cummings
        173466 by: David T-G

Re: PHP and SSL Path Reference
        173461 by: Manuel Lemos

Re: Can't upload files > then 400K to MySQL
        173462 by: Jeremy Johnstone

Re: Migrating from SSI and Perl
        173463 by: Philip Pawley

Re: Can somebody convert this short Perl Script to PHP?
        173464 by: Tom Rogers

PHP cart & Credit Card processing
        173465 by: Cesar Aracena

Re: Can't upload file greater than 11kb
        173467 by: David T-G

curl tutorial
        173468 by: Binay
        173469 by: Manuel Lemos

Problem with INSERT Query
        173470 by: irinchiang.justeducation.com
        173475 by: Marek Kilimajer

Re: [PHP-DB] Selecting between using letters
        173471 by: Henrik Hornemann

Is a while loop the most efficient way to send out multiple emails?
        173472 by: Dave G
        173473 by: Miles Thompson
        173474 by: Marek Kilimajer
        173477 by: David T-G

Testing for Well-Formed XML
        173476 by: Ian Williams

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 ---
If the database is really large, some databases will attempt to use an index
if you use "between" as in 

select * from table where lastname between "A" and "F"

or > and < compares.

not sure about MySQL, and notice I had to use the letter "F" to get all
names beginning with "E"

I seem to recall Sybase would use a table scan (read every row in the table)
if an imbedded function was used in the where clause, and it would use an
index with between.  Haven't done any internals work with MySQL so not sure
if this would speed things up or not.

Warren Vail


-----Original Message-----
From: Lowell Allen [mailto:[EMAIL PROTECTED]
Sent: Monday, December 29, 2003 2:25 PM
To: PHP
Subject: Re: [PHP] Selecting between using letters


> How would I create a select statement in MySQL that would return a range
of
> records from the LastName field where the value starts with a designated
> letter - for example, returning the range where the first letter of
LastName
> is between A and E...
> 
> Any help would be greatly appreciated.

$sql = "SELECT * FROM table WHERE LastName REGEXP '^[A-E]'";

HTH

--
Lowell Allen

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

--- End Message ---
--- Begin Message ---
Has anyone installed AWF 1.10??  I need some help...


-- 

--- End Message ---
--- Begin Message ---
Good evening.

        I'm probably going to stir up a hornet's nest but have a question.

        Does using echo for ALL html pages mean I have a sick mind? Example:

        echo CR, '<HTML>',
           CR, '  <BODY>',
             CR, ' etc...';

        I like the look. It's more readable, gives me a better view of variables as
they are all single-quoted and stand out nicely in my editor. No messy
jumping into and out of php. I have looked at a bunch of php code written by
others and HEREDOC looks stupid with everything jammed against the left side
of the screen, php tags within HTML breaks up the flow of properly formatted
HTML, which I firmly require for all of my code, and just doesn't look
right. 'print' makes you add \" to all of the HTML attributes but the 'echo'
method makes everything look like php! Since all your doing is dumping text
to the output subsystem, there shouldn't be any speed decrease in the code.

        Yes, I know, there are advocates for every kind of method to display HTML
code but just wanting to get others opinions on the subject. If you wish,
email me off-list @ sparkyk-AT-blackmesa-isp.net.

        Cheers!

Robin 'Sparky' Kopetzky
Black Mesa Computers/Internet Service
Grants, NM 87020

--- End Message ---
--- Begin Message ---
I agree.  I think embedding the <?php ?> tags is messy and harder to follow.
I do however, treat echo like print. ie echo "The thought would \"have\" to
be clear.";  I've not use CR,.  I'll have to look at that.  Thanks

-----Original Message-----
From: Robin Kopetzky [mailto:[EMAIL PROTECTED]
Sent: Monday, December 29, 2003 8:02 PM
To: PHP General
Subject: [PHP] HTML via echo or not


Good evening.

        I'm probably going to stir up a hornet's nest but have a question.

        Does using echo for ALL html pages mean I have a sick mind? Example:

        echo CR, '<HTML>',
           CR, '  <BODY>',
             CR, ' etc...';

        I like the look. It's more readable, gives me a better view of variables as
they are all single-quoted and stand out nicely in my editor. No messy
jumping into and out of php. I have looked at a bunch of php code written by
others and HEREDOC looks stupid with everything jammed against the left side
of the screen, php tags within HTML breaks up the flow of properly formatted
HTML, which I firmly require for all of my code, and just doesn't look
right. 'print' makes you add \" to all of the HTML attributes but the 'echo'
method makes everything look like php! Since all your doing is dumping text
to the output subsystem, there shouldn't be any speed decrease in the code.

        Yes, I know, there are advocates for every kind of method to display HTML
code but just wanting to get others opinions on the subject. If you wish,
email me off-list @ sparkyk-AT-blackmesa-isp.net.

        Cheers!

Robin 'Sparky' Kopetzky
Black Mesa Computers/Internet Service
Grants, NM 87020

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

--- End Message ---
--- Begin Message --- Why make PHP work harder than it needs to?

Jordan

Robin Kopetzky wrote:

Good evening.

I'm probably going to stir up a hornet's nest but have a question.

Does using echo for ALL html pages mean I have a sick mind? Example:

        echo CR, '<HTML>',
          CR, '  <BODY>',
             CR, ' etc...';

        I like the look. It's more readable, gives me a better view of variables as
they are all single-quoted and stand out nicely in my editor. No messy
jumping into and out of php. I have looked at a bunch of php code written by
others and HEREDOC looks stupid with everything jammed against the left side
of the screen, php tags within HTML breaks up the flow of properly formatted
HTML, which I firmly require for all of my code, and just doesn't look
right. 'print' makes you add \" to all of the HTML attributes but the 'echo'
method makes everything look like php! Since all your doing is dumping text
to the output subsystem, there shouldn't be any speed decrease in the code.

        Yes, I know, there are advocates for every kind of method to display HTML
code but just wanting to get others opinions on the subject. If you wish,
email me off-list @ sparkyk-AT-blackmesa-isp.net.

Cheers!

Robin 'Sparky' Kopetzky
Black Mesa Computers/Internet Service
Grants, NM 87020




-- I am nothing but a poor boy. Please Donate.. https://www.paypal.com/xclick/business=list%40racistnames.com&item_name=Jordan+S.+Jones

--- End Message ---
--- Begin Message ---
I use a templating framework in which I put all of my HTML. However,
when I create components that need to output HTML to render themselves
then I use the echo and single quote style also. I find heredoc and
breaking in and out of PHP to be extremely messy looking, not to mention
horribly maintainable. Double quotes versus single quotes is more a
matter of preference, for instance when doing SQL queries I like to use
double quotes instead since I quote my SQL strings in single quotes.

Cheers,
Rob.


On Mon, 2003-12-29 at 20:03, Larry Brown wrote:
> I agree.  I think embedding the <?php ?> tags is messy and harder to follow.
> I do however, treat echo like print. ie echo "The thought would \"have\" to
> be clear.";  I've not use CR,.  I'll have to look at that.  Thanks
> 
> -----Original Message-----
> From: Robin Kopetzky [mailto:[EMAIL PROTECTED]
> Sent: Monday, December 29, 2003 8:02 PM
> To: PHP General
> Subject: [PHP] HTML via echo or not
> 
> 
> Good evening.
> 
>       I'm probably going to stir up a hornet's nest but have a question.
> 
>       Does using echo for ALL html pages mean I have a sick mind? Example:
> 
>       echo CR, '<HTML>',
>            CR, '  <BODY>',
>            CR, ' etc...';
> 
>       I like the look. It's more readable, gives me a better view of variables as
> they are all single-quoted and stand out nicely in my editor. No messy
> jumping into and out of php. I have looked at a bunch of php code written by
> others and HEREDOC looks stupid with everything jammed against the left side
> of the screen, php tags within HTML breaks up the flow of properly formatted
> HTML, which I firmly require for all of my code, and just doesn't look
> right. 'print' makes you add \" to all of the HTML attributes but the 'echo'
> method makes everything look like php! Since all your doing is dumping text
> to the output subsystem, there shouldn't be any speed decrease in the code.
> 
>       Yes, I know, there are advocates for every kind of method to display HTML
> code but just wanting to get others opinions on the subject. If you wish,
> email me off-list @ sparkyk-AT-blackmesa-isp.net.

-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
On Mon, 2003-12-29 at 20:34, Jordan S. Jones wrote:
> Why make PHP work harder than it needs to?

A decent compile cache will optimize literal concatenation so that only
variables are concatenated at run time.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Robin --

...and then Robin Kopetzky said...
% 
% Good evening.

Hiya!


% 
%       I'm probably going to stir up a hornet's nest but have a question.

Probably so :_0


% 
%       Does using echo for ALL html pages mean I have a sick mind? Example:

I don't think so.


% 
%       echo CR, '<HTML>',
%            CR, '  <BODY>',
%            CR, ' etc...';

OK, that does look a bit sick :-)  If nothing else, you end up with a
blank line before your first tag, which is technically a no-no.

I personally terribly dislike the jump-in-and-out bit, so only when I
have to use javascript and have to quote it do I even think about that.
I should also get around to using templates, but I haven't yet, so my
answer might be different later.  I have a vague grasp of the nirvana of
separating the presentation formatting from the actual work and would
like to get there someday.  In my copious time between midnight and 4am,
I suppose.  Oh, wait; I'm in that now.  I may have to sleep in 'til 4:30
to make up for it *yawn*

I also use print for everything rather than echo; I use '' on my HTML
attributes within my print ""s and so I don't look like a B movie (that's
B for backslasher :-)

When printing large chunks I don't bother with HEREDOCs but have been
known to

  print
    "
      <table>
        <tr>
          <td>cell</td>
          <td>cell</td>
        </tr>
      </table>

      There was a table.
    " ;

or so.  It's easier to write than all of the quoting on and off that you
describe (plus I use \n rather than CR, not having seen it before and
thus not knowing if it's a predefined constant or one you did).  I tend
to get a bit lazy with my HTML and often don't sweat the formatting for
the sake of the browser, though I do use newlines for at least a token
consideration of anyone reading the output :-)  The php is much more
important to me than the resultant HTML.

Good luck coming to a sane final decision :-)


HTH & HAND & Happy Holidays

:-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://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00000.pgp
Description: PGP signature


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

On 12/29/2003 06:37 PM, D.H. wrote:
PROBLEM 1
I am trying to implement SSL with PHP.  When trying to use the include()
function
to insert an external PHP file, I am only able to make it work in the local
directory
and without SSL.

I believe the following calls to external files should be correct;
however, the include function is not successfull with the complete
URL.

Example
                "include ('test.php');" works fine
                "include ('http://www.myURL.com/mySubdirectory/test.php');
does not work.

I am not sure why you want to do this because it is very slow. Anyway, if you do not allow to open remote URL files in your configuration file php.ini, that may be the reason.

You may also want to this HTTP client class that can work if you have configuration restrictons. It lets you retrieve pages with either http or https URLs.

http://www.phpclasses.org/httpclient


RELATED PROBLEM 2
When emplementing the SSL I am using my IP's certificate.  Using their
certificate, I can
establish an SSL connection directly...ie.
https://www.myIPDomain.com/myLoginID/mySubdirectories/test.php
inserted into my browser establishes an SSL connection and the php test
script works fine.

When I reference this test script from another PHP script using the
include() or require() function, the
script does display the contents of the reference.  The code is as follows:


File 1 with external reference: https://www.myIPDomain.com/myLoginID/mySubdirectories/testinclude.php

File 1 Contents:
<?PHP
        echo "Following should be the display of the Test File";
        include
'https://wwwmyIPDomain.com/myLoginID/mySubdirectories/testinclude.php";;
?>

File2 (file I am trying to include):
https://www.myIPDomain.com/myLoginID/mySubdirectories/test.php

Contents:
<?PHP
        echo "<b><br><br>This is the contents of the Test PHP File<b>";
?>

When I call File 1, I can only get the following output:

"Following should be the display of the Test File"

I think it is a matter of relative vs absolute references...but not sure.

I think you are confused. When you ask for remote data that way, you will get the contents of the page that is generated by that script, not the script itself. If you could do what you want that way, anybody could steal the PHP source code of all sites.

OTOH, if you have PHP script source code retrieval support enabled, you can try what you want asking for this url (notice phps extension), but you have to enable support in your server.

https://www.myIPDomain.com/myLoginID/mySubdirectories/test.phps



--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
Might want to check the MySQL configuration. The max allowed packet size
might be set extremely low.

-Jeremy

On Mon, 2003-12-29 at 15:25, Chris wrote:
> Have you taken a look at the post below: Can't upload files Greater than
> 11KB?
> We may have the same problem.
> 
> 
> "Ahmetax" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi,
> >
> > I have the following PHP code to upload files to a MySQL table.
> >
> > It works fine, but, I can't upload any files greater then 400K.
> >
> > What might be the problem?
> >
> > TIA
> >
> > ahmet
> >
> > <?
> > if (isset($_POST["submit"]))
> > {
> > $fname= $_FILES["user_file"]["name"];
> > $tmp= addslashes($_FILES["user_file"]["tmp_name"]);
> > $size= $_FILES["user_file"]["size"];
> > $type=$_FILES["user_file"]["type"];
> > $tanim=$_FILES["user_file"]["file_desc"];
> > $fd=fopen($tmp,"r") or die("Can't open file!");
> > $fdata=urlencode(fread($fd,filesize($tmp)));
> > $size=filesize($tmp);
> > $tanim=$descript;
> > include("baglan.inc");
> >
> > mysql_select_db("dosyalar");
> > $sql="INSERT INTO files (name,file_type,file_desc,file_data,file_size)".
> > " VALUES('$fname','$type','$descr','$fdata','$size')";
> > mysql_query($sql);
> > }
> > ?>
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> > <html>
> > <head>
> > <title>AxTelSoft-Uploading a file </title>
> > <meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
> > <meta http-equiv="Content-Language" content="tr">
> > <meta http-equiv="description" content="axtelsoft, indir, download,
> delphi,
> > source code, kaynak kod">
> > <meta http-equiv="Pragma" content="no-cache">
> > <meta name="Generator" content="Ahmet Aksoy">
> > </head>
> > <body>
> >
> > <form enctype="multipart/form-data" action="<?php echo
> > $SERVER["PHP_SELF"];?>" method="post">
> > <input type="hidden" name="MAX_FILE_SIZE" value="16777215">
> >
> > Send this file: <input name="user_file" type="file">
> > Explanations : <TEXTAREA NAME="descript" ROWS=10 COLS=45 WRAP><?php
> > echo($descr);
> > ?></TEXTAREA>
> > <P><input type="submit" value="Send File" name="submit">
> > </form>
> >
> > </body>
> > </html>

--- End Message ---
--- Begin Message ---
Right, I used 

        $output = shell_exec("perl browser.pl");
        echo "output";

as Radek suggested. To call my browser-sniffing perl script and read back what the 
script prints.
My trouble now is that the perl script, being called by the php script rather than by 
SSI, no longer seems to have the cgi environment variables to call on.

I can get the variable using
        
        $BRPHP = $_SERVER['HTTP_USER_AGENT'];

How do I pass this to the perl script? I've followed all the avenues suggested in the 
newbie guide.

The best I can seem to manage is to use exec() like so:

        $BRPHP = $_SERVER['HTTP_USER_AGENT'];
        $arr = array (1 => "$BRPHP" );
        exec (' ../cgi-bin/browser.pl', $arr );
        echo $arr[2];
        echo $arr[3];
        echo $arr[4];
        echo $arr[5];
        echo $arr[6];

The echo commands get me back the script's output, but am I passing $BRPHP to the perl 
script this way? (If the answer is "yes" then I can ask the folks at perl.org how to 
pick it up in the perl script).

Thanks,

Philip Pawley


At 26/12/03 12:29 -0500, you wrote:
>Check out shell_exec() and its siblings. I'd likely use it like so $output =
>shell_exec("perl myscript.pl"); and then do something with the $output
>variable
>
>R>
>
>> -----Original Message-----
>> From: Philip Pawley [mailto:[EMAIL PROTECTED]
>> Sent: December 26, 2003 12:07 PM
>> To: php-general
>> Subject: [PHP] Migrating from SSI and Perl
>>
>>
>> I am new to php.
>>
>> My site, at the moment, uses SSI to call a Perl browser-sniffing script.
>>
>> I would like to:
>> 1. use php to call the Perl script.
>> 2. then save the values the Perl script outputs as php variables.
>>
>> Can this be done? If so, how?
>>
>> Thanks,
>>
>> Philip Pawley

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

Tuesday, December 30, 2003, 2:50:17 AM, you wrote:
DM> Hi, I am trying to make a log rotator and found a great perl script to do it
DM> but, would really like it in PHP (one less langauge to maintain).

DM> I know the system has "things" in place to do this but, I don't have access
DM> to the system /etc/log/ folder or the system log rotation scripts. I figured
DM> a simple php command line script would be a good alternative to maintain my
DM> own logs.

DM> Here's the perl script:

DM> #!/usr/bin/perl
DM>  $LOGPATH='/Users/cv_admin/mylogs';
DM> 
DM> @LOGNAMES=('housekeeper_log_deleter.log','mysqlbackups_deleter.log','webbac
DM> kups_deleter.log');
DM>  $MAXCYCLE = 4;

DM>  chdir $LOGPATH;  # Change to the log directory
DM>  foreach $filename (@LOGNAMES) {
DM>     for (my $s=$MAXCYCLE; $s >= 0; $s-- ) {
DM>         $oldname = $s ? "$filename.$s" : $filename;
DM>         $newname = join(".",$filename,$s+1);
DM>         rename $oldname,$newname if -e $oldname;
DM>     }
DM>  } 

DM> Don Myers


Here is an untested version you can start with

#!/usr/bin/php
<?
 $LOGPATH='/Users/cv_admin/mylogs';
 $LOGNAMES= 
array('housekeeper_log_deleter.log','mysqlbackups_deleter.log','webbackups_deleter.log');
 $MAXCYCLE = 4;

 chdir($LOGPATH);  # Change to the log directory
 foreach ($LOGNAMES as $filename ) {
    for ($s=$MAXCYCLE; $s >= 0; $s-- ) {
        $oldname = ($s > 0)? $filename.$s : $filename;
        $newname = $filename.($s+1);
        if(file_exists($oldname)){
            rename($oldname,$newname);
        }
    }
 } 


-- 
regards,
Tom

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

I am building a cart of my own for a site I'm making and would like to know
if doing it like this (instead of using a known cart script), I will be able
to use any of the Credit Card processing systems there are. If so, which
Credit Card processing company has given you the best experience?

Thanks all,

Cesar Aracena

--- End Message ---
--- Begin Message ---
Chris, et al --

...and then Chris said...
% 
% complaint to the hosting provider about this issue the did something that
% increased the upload file size to several hundred kilobytes. They claimed it
% has something to do with the temp dir where the file is being uploaded to.

Hah!  I called it six days ago :-)

Glad to see you're up and running, and good luck beating this problem
with your customers.


HTH & HAND & Happy Holidays

:-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://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00001.pgp
Description: PGP signature


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

can any body point me the direction where i can find curl tutorials. I was going 
through the curl concept from php manual but couldn't quench my thirst as this section 
is not very clear. I also searched in the archive but couldn't find any.

if any of u know the resource point(curl tutorial) plz let me know.

Thanks
Binay

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

On 12/30/2003 04:39 AM, Binay wrote:
can any body point me the direction where i can find curl tutorials. I was going through the curl concept from php manual but couldn't quench my thirst as this section is not very clear. I also searched in the archive but couldn't find any.

if any of u know the resource point(curl tutorial) plz let me know.

You are right, curl API is a bit messy.

I think that if you ask Google, you may find some curl tutorials.

You may also want to take a look at this HTTP client class that provides a simpler interface and uses CURL mostly for accessing SSL pages (https):

http://www.phpclasses.org/httpclient

--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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

Hi all:

Well, when i bring out the page with the drop down list it was able to display 
all tutors' names from "tutor_name" column. Anyway here's a review of my code
(snip) again before i continue:
-------------------------------------------------------------------------------
<snip> 
$sql = "INSERT INTO class (class_code, tutor_name, edu_level, timetable_day,   
timetable_time)
        VALUES
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time')";


<?//retrieve data from DB & display in dynamic drop down ?> 

<SELECT class="textarea" name="tutor_name" /> 
<?


$sql = mysql_query("SELECT DISTINCT tutor_name FROM tutor ");
while ($row = mysql_fetch_array($sql))
{
 print "<OPTION VALUE=\"$tutor_name\" SELECTED> " .$row
["tutor_name"]. "</option> ";
 }
 $result = $db-> query($sql);

?> 
</select> 

<?

while($selected_tutor_name == $tutor_name)
echo $_POST["tutor_name"];

?> 

</snip> 

-------------------------------------------------------------------------------

so when i submit the form, i am suppose to echo the values i have entered into 
the field and then INSERT the values into DB (Queries stated above). However i 
was able to echo all other values eg. class_code, edu_level, etc...but 
not "tutor_name"....same thing happen when i do an INSERT, all other values 
are inserted into DB but not $tutor_name....why is this so???Really need some 
help here...Anyway i have already specify a name to be reference :

<SELECT class="textarea" name="tutor_name" > 

and then I also did an echo of "tutor_name" being selected:

while($selected_tutor_name == $tutor_name)
echo $_POST["tutor_name"];

All help are greatly appreciated =)

Irin.

--- End Message ---
--- Begin Message --- Do you understand the request - response process? User requests a page, php buids the page and sends it to the user, user's browser displays the page, users views it and takes some action (follows a link, submits a form) and the whole process repeats.

[EMAIL PROTECTED] wrote:

Hi all:

Well, when i bring out the page with the drop down list it was able to display all tutors' names from "tutor_name" column. Anyway here's a review of my code
(snip) again before i continue:
-------------------------------------------------------------------------------
<snip> $sql = "INSERT INTO class (class_code, tutor_name, edu_level, timetable_day, timetable_time)
VALUES
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time')";


Where are the variables coming from?


<?//retrieve data from DB & display in dynamic drop down ?>

<SELECT class="textarea" name="tutor_name" />
                                             |
This is illegal -----------------------------+

<?


$sql = mysql_query("SELECT DISTINCT tutor_name FROM tutor "); while ($row = mysql_fetch_array($sql)) { print "<OPTION VALUE=\"$tutor_name\" SELECTED> " .$row ["tutor_name"]. "</option> ";

Only one option can be selected unless the <select> is multiple

 }
 $result = $db-> query($sql);

?> </select>

<?

while($selected_tutor_name == $tutor_name)
echo $_POST["tutor_name"];

$_POST["tutor_name"] is printed out only if $selected_tutor_name == $tutor_name, in that case the while loop would be infinite however.


?>

</snip>

-------------------------------------------------------------------------------

so when i submit the form, i am suppose to echo the values i have entered into the field and then INSERT the values into DB (Queries stated above). However i was able to echo all other values eg. class_code, edu_level, etc...but not "tutor_name"....same thing happen when i do an INSERT, all other values are inserted into DB but not $tutor_name....why is this so???Really need some help here...Anyway i have already specify a name to be reference :

<SELECT class="textarea" name="tutor_name" >

and then I also did an echo of "tutor_name" being selected:

while($selected_tutor_name == $tutor_name)
echo $_POST["tutor_name"];

All help are greatly appreciated =)

Irin.


--- End Message ---
--- Begin Message ---
How about

Select LastName from sometable where LastName >= 'A' and LastName <'F'

Hth Henrik Hornemann

-----Oprindelig meddelelse-----
Fra: Doug Parker [mailto:[EMAIL PROTECTED] 
Sendt: 29. december 2003 23:18
Til: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Emne: [PHP-DB] Selecting between using letters


How would I create a select statement in MySQL that would return a range
of records from the LastName field where the value starts with a
designated letter - for example, returning the range where the first
letter of LastName is between A and E...

Any help would be greatly appreciated.



------------------------------------------------------------
http://www.phreshdesign.com

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

--- End Message ---
--- Begin Message ---
PHP Gurus,
        I currently run a few newsletters that go out to small groups of
50 to 100 people. I use a while loop to send out the emails. I chose a
while loop as opposed to just taking all the emails and putting them in
the CC field because I wanted to personalize each email with a greeting
that included the recipients name and other personalized information. It
looks like:
while ($member = mysql_fetch_array($sqlQueryResult)
{
        $content = "Hi, {$member[name]}. Your email address is
{$member[email]}";
        mail ($member[email], $subject, $content)
}
        When I execute my script, it takes a little time to go through
about 50 people. I'm not sure exactly, but maybe ten seconds, possibly
as high as twenty.
        Soon I will be creating a script to send out an email to 500
people, with the possibility that it will grow to 1000. I'm concerned
that the while loop will take ten times as long, and not only be a drain
on the server, but also run the risk of my browser timing out waiting
for a response to confirm all mails were sent.
        So my question is, is there a way more efficient than while
loops to send out multiple emails with personalized information? Is it
the mail() command that takes time, or the mysql_fetch_array(), or both?
        Any suggestions would be greatly appreciated.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message --- At 05:37 PM 12/30/2003 +0900, Dave G wrote:
PHP Gurus,
        I currently run a few newsletters that go out to small groups of
50 to 100 people. I use a while loop to send out the emails. I chose a
while loop as opposed to just taking all the emails and putting them in
the CC field because I wanted to personalize each email with a greeting
that included the recipients name and other personalized information. It
looks like:
while ($member = mysql_fetch_array($sqlQueryResult)
{
        $content = "Hi, {$member[name]}. Your email address is
{$member[email]}";
        mail ($member[email], $subject, $content)
}
        When I execute my script, it takes a little time to go through
about 50 people. I'm not sure exactly, but maybe ten seconds, possibly
as high as twenty.
        Soon I will be creating a script to send out an email to 500
people, with the possibility that it will grow to 1000. I'm concerned
that the while loop will take ten times as long, and not only be a drain
on the server, but also run the risk of my browser timing out waiting
for a response to confirm all mails were sent.
        So my question is, is there a way more efficient than while
loops to send out multiple emails with personalized information? Is it
the mail() command that takes time, or the mysql_fetch_array(), or both?
        Any suggestions would be greatly appreciated.

--
Yoroshiku!
Dave G
[EMAIL PROTECTED]


Dave,

This goes out to 900 people every night, I just bought myself some time by adding this at the bottom of the while loop:
// give ourselves more time
set_time_limit( 20 );

I also echo the recipient's email & an OK/Fail, depending on what mail() returns, to the browser so that I can see the progress.

HTH - Miles
--- End Message ---
--- Begin Message --- Dave G wrote:
        So my question is, is there a way more efficient than while
loops to send out multiple emails with personalized information? Is it
the mail() command that takes time, or the mysql_fetch_array(), or both?
        Any suggestions would be greatly appreciated.


It's the mail() function. I've seen a class that connects to smtp server and sends all emails in one connection, author claimed it was faster than the built-in mail() function.
--- End Message ---
--- Begin Message ---
Dave --

...and then Dave G said...
% 
% PHP Gurus,
%       I currently run a few newsletters that go out to small groups of
% 50 to 100 people. I use a while loop to send out the emails. I chose a
...
% about 50 people. I'm not sure exactly, but maybe ten seconds, possibly
% as high as twenty.
%       Soon I will be creating a script to send out an email to 500
...
%       So my question is, is there a way more efficient than while
% loops to send out multiple emails with personalized information? Is it
% the mail() command that takes time, or the mysql_fetch_array(), or both?
%       Any suggestions would be greatly appreciated.

0) That really should be $member['name'] and $member['email'] instead of
bare indices, you know :-)

1) It's definitely the mail() command, and that's dependent on the
underlying mail system.

2) Driving this from the browser is probably a bad way to go because you
will always be fighting timeout issues *and* what about a broken connection
not because of a timeout?

3) If you want full personalization, you're stuck with individual emails,
but lots of mailing list software out there can handle VERPing and, say,
footers and save you a whopping lot of work.

4) I did some work this summer on a mass mail script; with a little script
tweaking and some (but not onerous) qmail tweaking, I got our times down
to around 100ms per email.  That puts us sending about 30k [personalized]
emails per hour, which is an order of magnitude faster than the speed of
the guys who lost the contract to us :-)  It's discussed on the list a
bit; check the archives.


HTH & HAND & Happy Holidays

:-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://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00002.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
Hi
I'm trying to build a validator in PHP, to check that XML documents are
well-formed.
Does anyone have an algorithm for doing this?

KR
ian

--- End Message ---

Reply via email to