php-general Digest 3 Mar 2002 21:33:10 -0000 Issue 1205

Topics (messages 86965 through 87004):

Re: Bizarre mail() problem
        86965 by: andy thomas

Re: Ok Gurus Shake your nudels !!!
        86966 by: Jon Feldhammer

header generation problem
        86967 by: Jon Feldhammer
        86982 by: Greg Donald
        86988 by: Jon Feldhammer

comparing string values, etc
        86968 by: Tim Martens
        86969 by: DL Neil

Apache+PHP 4.1.2+mod_ssl segfaults on HTTPS protocol
        86970 by: Noor Dawod

levenshtein
        86971 by: adder.null.net

Re: Sending a file with fpassthru() or readfile(), causes IE to hang.
        86972 by: John Chronakis
        86973 by: John Chronakis

exit status
        86974 by: David Apthorpe
        86996 by: Lars Torben Wilson

Re: cursor focus
        86975 by: Ralph Jarvis
        86976 by: Thomas Seifert
        86979 by: Gaylen Fraley
        86997 by: Markas

Re: Web Cam Support
        86977 by: karthikeyan

Form value retrieval
        86978 by: karthikeyan
        86980 by: karthikeyan

Re: Apache & PHPMyAdmin
        86981 by: Greg Donald

Re: CheckBoxes....
        86983 by: bvr

ignore_user_abort
        86984 by: Paul Roberts
        86989 by: Rasmus Lerdorf

Re:Re:Re:[PHP] compile php with GD2
        86985 by: Hendrik

Re: inspiration needed on problem s
        86986 by: Nick Wilson
        86991 by: Steven Walker

Translation help needed...
        86987 by: Nick Wilson

Sessions Help
        86990 by: Ramesh Nagendra Pillai
        86992 by: Greg Donald
        86993 by: Nick Wilson

Re: Hosts with PHP support
        86994 by: Tom

Re: Non printable page
        86995 by: Lars Torben Wilson
        87001 by: Michael Kimsal

Re: Checking how many users are logged in?
        86998 by: Markas

CURL and multiple sites at once
        86999 by: Stefan Rusterholz

Re: A Small Bug Giving Me A Big Headache
        87000 by: Markas

Changing file permissions - Help!
        87002 by: mojo jojo

phpAdsNew
        87003 by: Georgie Casey

Radio Button
        87004 by: Chiew, Richard

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


On Sun, 3 Mar 2002, andy thomas wrote:

>
>
> On Sat, 2 Mar 2002, Andrey Hristov wrote:
>
> > check you php.ini if you need to change sendmail -t -i to something other.
>
> We are still having problems with this. Doing another mailshot, the script
> crawled at 1 message every 75 seconds. After starting 10 more scripts,
> each script was putting out one message every 75 seconds. Suddenly, after
> about 40 minutes of this, all 11 scripts suddenly accelerated up to full
> speed, load av hit 8+ and the mailshot completed in less than 1 hour!
>
> I'm now doing another mail blast using just 5 parallel scripts - it's
> crawling at the moment but it will be interesting to see what happens in
> about half an hour's time.

As an update to this, after 90 minutes the first script, which processed
about 600 addresses, completed. After that the remaining four scripts,
mailing 2000 addresses each, ran at full speed.

Now what is going on? It seems the completion of the first script is some
sort of trigger for sendmail to run quicker.

Andy

> > ----- Original Message -----
> > From: "andy thomas" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Saturday, March 02, 2002 11:04 AM
> > Subject: [PHP] Bizarre mail() problem
> >
> >
> > > I have written a script to do some massmailing - it extracts an email
> > > address from a MySQL database and uses it to send a text file as a mail
> > > message. It works but there is a 75 second delay between each message
> > > being sent out!
> > >
> > > This is baffling - there are no delays built into the script and nothing
> > > obvious in our sendmail configuration. As I've got over 38000 addresses to
> > > mail out to, this is a problem - I've got round it for now by running 10
> > > scripts simultaneously, each handling 1000 addresses and this has got mail
> > > moving.
> > >
> > > The mail() function seems to call sendmail -t -i. This just sits there for
> > > 75 seconds, then sends a message and then waits for another 75 seconds.
> > > Surely this should not happen?
> > >
> > > Here's the relevant parts of the script - the email address is in column
> > > 15 of the MySQL table, so it just extracts field 14 for the email address
> > > data:
> > >
> > > $msg_txt="message.txt";
> > >
> > > mysql_connect("localhost",$mysql_user,$mysql_pwd);
> > > $query="select * from $table";
> > > $result=mysql($dbname, $query);
> > > $rows=mysql_numrows($result);
> > >
> > > $r=0;
> > > $f=14;
> > > while ($r < $rows ) {
> > >         $address=mysql_result($result,$r,$f);
> > >         mail("$address","$subject","$message","From:$MailFromAddress");
> > >         $r++;
> > >         }
> > >
> > >
> > > Any suggestions or pointers to where I'm going wrong will be warmly
> > > received.
> > >
> > > Andy
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>

--- End Message ---
--- Begin Message ---
Olev Rumm wrote:
> Mime problem.
> I have my web form here www.toolmecindustries.com/submform.php
> 
> Now my email recieves all the contens thruogh [EMAIL PROTECTED] (fields
> what customer filles out)
> but attachment (picture fail) is shown like encrypted
> here:
> 
> rewfg/wr;tlkmbwsl/kw;relktnh;wlkfdvbs.kdfnghb/asdfmgbn/.slfg
> rewfg/wr;tlkmbwsl/kw;relktnh;wlkfdvbs.kdfnghb/asdfmgbn/.slfg
> 
> all like that.
> 
> Now I did an account with hotmail, yahoo and some other mail services
> and sended this stuff through them - it works I recieve everything !!
> 
> Asked my ISP - they told  that it is 100% my script's problem.
> How is it possible?
> Olev
> 
> 
> 

My guess would be that the email header isn't specifying a multi input 
type email (with attachments) properly.  Or that your email client 
doesn't support the image type.  Hotmail and yahoo probably take some 
liberties and try things out to get the email to work properly, where 
"pine" or a basic email client like that won't.

Jon

--- End Message ---
--- Begin Message ---
I'm trying to create a single dynamic header for a wide range of web 
pages which I'll just include as I need it.  There are a few things that 
change per web page in the header, but I've settled all the issues 
except a good way of how to modify a single image that changes based on 
the web page being displayed.

For example:
I'm displaying index.php, which includes 'header.php', the variable 
$wpid indicates that the current web page is index.php.  Now index.php 
needs to display: (changing index_off.gif to index_on.gif)
index_on.gif anotherpage_off.gif yetanotherpage_off.gif

(the tricky part is that each image will change to on depending on what 
page is being displayed)

I really haven't come up with an adequate solution.  Ideas?  Thanks.

Jon

--- End Message ---
--- Begin Message ---
On Sun, 3 Mar 2002, Jon Feldhammer wrote:

>I'm trying to create a single dynamic header for a wide range of web
>pages which I'll just include as I need it.  There are a few things that
>change per web page in the header, but I've settled all the issues
>except a good way of how to modify a single image that changes based on
>the web page being displayed.
>
>For example:
>I'm displaying index.php, which includes 'header.php', the variable
>$wpid indicates that the current web page is index.php.  Now index.php
>needs to display: (changing index_off.gif to index_on.gif)
>index_on.gif anotherpage_off.gif yetanotherpage_off.gif
>
>(the tricky part is that each image will change to on depending on what
>page is being displayed)
>
>I really haven't come up with an adequate solution.  Ideas?  Thanks.

I usually program dynamic image names when I encounter this.

<?
$image = "banner";
if(isset($xmas_var)){
        $image .= "_xmas";
}
$image .= ".gif";
?>
<img src="<?=$image?>">

-- 
-----------------------------------------------------------------------
Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/
-----------------------------------------------------------------------


--- End Message ---
--- Begin Message ---
Greg Donald wrote:
> On Sun, 3 Mar 2002, Jon Feldhammer wrote:
> 
> 
>>I'm trying to create a single dynamic header for a wide range of web
>>pages which I'll just include as I need it.  There are a few things that
>>change per web page in the header, but I've settled all the issues
>>except a good way of how to modify a single image that changes based on
>>the web page being displayed.
>>
>>For example:
>>I'm displaying index.php, which includes 'header.php', the variable
>>$wpid indicates that the current web page is index.php.  Now index.php
>>needs to display: (changing index_off.gif to index_on.gif)
>>index_on.gif anotherpage_off.gif yetanotherpage_off.gif
>>
>>(the tricky part is that each image will change to on depending on what
>>page is being displayed)
>>
>>I really haven't come up with an adequate solution.  Ideas?  Thanks.
>>
> 
> I usually program dynamic image names when I encounter this.
> 
> <?
> $image = "banner";
> if(isset($xmas_var)){
>       $image .= "_xmas";
> }
> $image .= ".gif";
> ?>
> <img src="<?=$image?>">
> 

Well this is a solution I thought of, but then aren't you stuck doing 
this for every image that can change?  (like 20 of them in my case?)  I 
didn't think there was a better way, I was just hoping there was.

Jon

--- End Message ---
--- Begin Message ---
Hi - I'm a major newbie.

 - I have a file that pulls an include into a <textarea> for a user to edit
 - before pulling the include, I'd like to open it and check it's value
 - if the include's value is exactly equal to the string:
<div style='color: #eee; font: bold 80px Georgia, serif'>Hello World</div>
then I want to overwrite that string with nothing; close the include; and
then load it (now null) into the textarea
 - else, if the include's value is not equal to the above string, just load
it into the <textarea>

However embarrassing, I'll give what I have which hasn't been working

$noting = "";
$checkval = "<div style='color: #F00; font: bold 80px Georgia, serif'>Hello
World</div>";
$filename = "thefile.inc";

$fd = fopen ($filename, "w");
$contents = fread ($fd, filesize ($filename));
if ($contents == fread ($checkval)) {
    fwrite ($filename, $nothing);
    fclose ($fd);
    include($filename);
     } else {
     fclose ($fd);
     include($filename);
}
clearstatcache();    //for the next time around?

Also - does thefile.inc have to be CHMOD 666?
BTW - the server is running PHP4/Apache.

thx    //t


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

> I'm a major newbie.

I was in the navy so never made it to major!?
I'm only going to comment on your syntax and ignore the
wide/Unix-related issues:

> $noting = "";
> $checkval = "<div style='color: #F00; font: bold 80px Georgia,
serif'>Hello
> World</div>";
> $filename = "thefile.inc";
>
> $fd = fopen ($filename, "w");
> $contents = fread ($fd, filesize ($filename));
> if ($contents == fread ($checkval)) {
    fwrite ($filename, $nothing);
...

$noting and $nothing
- typo?

if ($contents == $checkval ) {
- you don't want to read $checkval from the input file
- this comparison will be absolutely precise with no allowance for case
sensitivity, extra spaces, double instead of single quotes etc. Hope
that's ok with you!?

fwrite ($filename, $nothing);
- I've not tried this, but after reading to the end of the existing
contents will the 'new data' be added to the end of the existing
contents, or overwrite them? Please check.

Hope this gets you started,
=dn

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

I'm contacting you because I'm encountering a bug in recent Apache
1.3.23 and relevant mod_ssl version when compiled with PHP 4.1.2. This
might be connected directly to PHP (or to MySQL too), but maybe it is.

I've compiled Apache, mod_ssl and PHP 4.1.2 two days ago, and since then
the error log is filling with Segmentation faults whenever I try to
fetch a page using HTTPS protocol. Same page loads well with no
segmentation faults if using the HTTP protocol. Page uses PHP, but as
you can see next, it is not PHP-specific.

It is worth noting that I'm experiencing the same problem when trying to
load server-status for the server too. I don't know what's the
connection.

My server's details is:

FreeBSD 4.5-STABLE (2 weeks ago)
Apache 1.3.23
mod_ssl-2.8.6-1.3.23
PHP 4.1.2
MySQL 3.23.39 (used for PHP)

If you need further information, please let me know.

Thanks for the help.

Noor

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

is it possible to use levenshtein as part of a mysql select ?
i have been experimenting but seem to return no results
I would like to be able to select a row based on how near my search 
text is to the contents
i.e if the table is mysql_mail and it's fields are 'to' 'sender' 
'subject' and 'body' ( an email structure )
i would like to be able to
select sender from mysql_mail where "subject is not too different 
from what i specify"
i thought the following might work but doesn't seem to
$result = mysql_query("select sender from mysql_mail where 
levenshtein(subject,'dear john') <=2");
$echo "The number of Dear John letters is".mysql_affected_rows();


hope i am asking at the correct place

BA

-- 
--- End Message ---
--- Begin Message ---
After your reply I did some more tests with the following conclusions.

1. I was wrong about perl. IE behaves the same with the perl equivalent
script,
but requires the user to cancel 2 times. After the second time, you cannot
try anymore.

2. The source of the problem seems to be Internet Explorer and not the
server nor the
scripting language.
I have tested the same script under win2k with both IIs and apache
and both perl and php with the same results.
I have also tested both php and perl scripts on a linux running apache
1.3.14. Still the same problem.
After two attempts to download, then hit ok and at the "save as" dialog, hit
cancel, IE becomes useles.

I haven't tried asp, but something tells me it will make no difference.

Thanks.


John Chronakis


"Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> I don't see how this can be a PHP problem.  If you say that a similar
> script written in Perl doesn't cause this, then simply compare the output
> of the Perl one to the PHP one and make sure they are sending the same
> thing.  If your IE browser gets confused with the PHP version then it must
> be sending something different from the Perl version.  There is no way for
> IE to tell that the image came from PHP and not something else.
>
> -Rasmus
>
> On Sat, 2 Mar 2002, John Chronakis wrote:
>
> > Hello,
> >
> > I have posted the following message to php-windows but i got no answer.
> >
> > I am using IIs 5 on windows 2k sp2 with php 4.1.1.
> > There is a problem with the sctipt that follows and MSIE versions 5 to
6.
> >
> > A script sends a jpeg image to the client. It goes like this:
> >
> > ------------------------------------------------------
> > $imgsrc = 'full path of the image file';
> > ....
> > header ("Content-type: some/image");
> > header ("Content-disposition: attachment; filename=myimage.jpg");
> > header ("Content-length: ".filesize($imgsrc) );
> >
> > $fp = fopen( $imgsrc, "rb" );
> > if (!$fp) {
> >     ..... Log the error .....
> >     exit;
> > }
> >
> > fpassthru ($fp);
> >
> > exit;
> > ------------------------------------------------------
> >
> > It works fine if the user desides to save or open the image.
> > But if the user cancels the download, Internet Explorer stops
> > receiving anything from the site. Any click on a link hangs
> > (IE displays in the status bar "Web site found. Waiting for reply")
> > Links to static html files on my web server work
> > and you can also browse any other sites, but nothing on my site that is
> > parsed by php works.
> >
> > After some attemts (clicks and reloads), IIs reports the following
message:
> > "HTTP 403.9 - Access Forbidden: Too many users are connected
> > Internet Information Services"
> > Increasing the user limit on IIS, just requires a few more atemts to
show
> > this message.
> > After I close all IE instances or restart IIS, everything works fine
again.
> >
> > I have tried ignore_user_abort(1), sending expire headers, readfile()
> > instead of
> > fpassthru() etc but the problem persists.
> > Nothing changes with older versions of php or IE.
> >
> > This problem does not happen when using Netscape (any version)
> > or download managers.
> > Similar script written in perl does not have the same problem.
> >
> > Please help. It is a very-very late to switch to another scripting
language
> > for this project (even using perl or asp for the download part requires
a
> > great
> > deal of work).
> >
> > John Chronakis
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>


--- End Message ---
--- Begin Message ---
And the answer came from Mircrosoft which describes this situation as a bug
in the article

Q266305 - BUG: Canceling Multiple File Downloads on Large File Causes
Internet Explorer to Stop Responding.

John Chronakis




--- End Message ---
--- Begin Message ---
I'm using PHP on the command line.  Is there any way to exit, whilst setting
the exit status, without having it print out?  For example, exit(2) will
print "2".

Thanks in advance,

David Apthorpe


--- End Message ---
--- Begin Message ---
On Sun, 2002-03-03 at 04:16, David Apthorpe wrote:
> I'm using PHP on the command line.  Is there any way to exit, whilst setting
> the exit status, without having it print out?  For example, exit(2) will
> print "2".
> 
> Thanks in advance,
> 
> David Apthorpe

This will be in PHP 4.2.0.


-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506

--- End Message ---
--- Begin Message ---
I am not running Javascript, just PHP/HTML...
THe particular script I am having problems with has several decision points
and includes which I think is confusing the placement of the cursor


"Gaylen Fraley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> This is not a php question. It is a JavaScript issue.  You need to add
this
> code to the bottom of your page:
>
> <script>
>     document.forms[0].text_box_name.focus();
> </script>
>
> --
> Gaylen
> PHP KISGB v4.0.1 Guest Book http://www.gaylenandmargie.com/phpwebsite/
>
> "Ralph Jarvis" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED].;
> > This is really a newbie question, but here goes.....
> >
> > I am running PHP4 with Apache on Redhat 6.2.
> >
> > I am sure I read this somewheres, but can't find it again. When I open a
> > webpage in a small password application that I wrote, the cursor is not
on
> > the first text box I need to fill in, I need to click on the text box to
> > begin typing. How do I get the cursor to "focus" on this text box?
> >
> > Many thanks in advance
> >
> > Ralph
> >
> >
> >
>
>


--- End Message ---
--- Begin Message ---
yeah, but what you want to do can only be accomplished with JavaScript.
PHP is a serverside language and you need a clientside-lang like JS.

Thomas

Ralph Jarvis wrote:
> I am not running Javascript, just PHP/HTML...
> THe particular script I am having problems with has several decision points
> and includes which I think is confusing the placement of the cursor
> 
> 
> "Gaylen Fraley" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED].;
> 
>>This is not a php question. It is a JavaScript issue.  You need to add
>>
> this
> 
>>code to the bottom of your page:
>>
>><script>
>>    document.forms[0].text_box_name.focus();
>></script>
>>
>>--
>>Gaylen
>>PHP KISGB v4.0.1 Guest Book http://www.gaylenandmargie.com/phpwebsite/
>>
>>"Ralph Jarvis" <[EMAIL PROTECTED]> wrote in message
>>news:[EMAIL PROTECTED].;
>>
>>>This is really a newbie question, but here goes.....
>>>
>>>I am running PHP4 with Apache on Redhat 6.2.
>>>
>>>I am sure I read this somewheres, but can't find it again. When I open a
>>>webpage in a small password application that I wrote, the cursor is not
>>>
> on
> 
>>>the first text box I need to fill in, I need to click on the text box to
>>>begin typing. How do I get the cursor to "focus" on this text box?
>>>
>>>Many thanks in advance
>>>
>>>Ralph
>>>
>>>
>>>
>>>
>>
> 
> 


--- End Message ---
--- Begin Message ---
Well, unless you've disabled JavaScript in your browser, you are running it.

--
Gaylen
PHP KISGB v4.0.1 Guest Book http://www.gaylenandmargie.com/phpwebsite/

"Ralph Jarvis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> I am not running Javascript, just PHP/HTML...
> THe particular script I am having problems with has several decision
points
> and includes which I think is confusing the placement of the cursor
>
>
> "Gaylen Fraley" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED].;
> > This is not a php question. It is a JavaScript issue.  You need to add
> this
> > code to the bottom of your page:
> >
> > <script>
> >     document.forms[0].text_box_name.focus();
> > </script>
> >
> > --
> > Gaylen
> > PHP KISGB v4.0.1 Guest Book http://www.gaylenandmargie.com/phpwebsite/
> >
> > "Ralph Jarvis" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED].;
> > > This is really a newbie question, but here goes.....
> > >
> > > I am running PHP4 with Apache on Redhat 6.2.
> > >
> > > I am sure I read this somewheres, but can't find it again. When I open
a
> > > webpage in a small password application that I wrote, the cursor is
not
> on
> > > the first text box I need to fill in, I need to click on the text box
to
> > > begin typing. How do I get the cursor to "focus" on this text box?
> > >
> > > Many thanks in advance
> > >
> > > Ralph
> > >
> > >
> > >
> >
> >
>
>


--- End Message ---
--- Begin Message ---
Hi, PHP will do NOTHING with cursor position in your page, because it's
running on server. Perhaps what you've read is generating some Javascript
(which actually places the cursor) with PHP...

Hmmm, if you are not running Javascript, maybe an attribute TABINDEX, which
almost every html tag has, would help, but sorry if i'm mistaken, didnt
check that...


Ralph Jarvis <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> I am not running Javascript, just PHP/HTML...
> THe particular script I am having problems with has several decision
points
> and includes which I think is confusing the placement of the cursor
>
>
> "Gaylen Fraley" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED].;
> > This is not a php question. It is a JavaScript issue.  You need to add
> this
> > code to the bottom of your page:
> >
> > <script>
> >     document.forms[0].text_box_name.focus();
> > </script>
> >
> > --
> > Gaylen
> > PHP KISGB v4.0.1 Guest Book http://www.gaylenandmargie.com/phpwebsite/
> >
> > "Ralph Jarvis" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED].;
> > > This is really a newbie question, but here goes.....
> > >
> > > I am running PHP4 with Apache on Redhat 6.2.
> > >
> > > I am sure I read this somewheres, but can't find it again. When I open
a
> > > webpage in a small password application that I wrote, the cursor is
not
> on
> > > the first text box I need to fill in, I need to click on the text box
to
> > > begin typing. How do I get the cursor to "focus" on this text box?
> > >
> > > Many thanks in advance
> > >
> > > Ralph
> > >
> > >
> > >
> >
> >
>
>


--- End Message ---
--- Begin Message ---
Hi Rasmus and Others,

  Thanks for your info I will look into those link you have provided.

  How do you think yahoo is able to do it so beautifully.  When i click web
cam in Yahoo Chat it opens a pop up window and says connecting to the server
and then it shows up web cam picture and it is pretty good.  Can I achieve
something like that in my web site.

  Regards,

karthikeyan.
----- Original Message -----
From: Rasmus Lerdorf <[EMAIL PROTECTED]>
To: karthikeyan <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, March 03, 2002 8:06 AM
Subject: Re: [PHP] Web Cam Support


>
> I will be setting one up next week so should have more for you then.  But
> there really isn't much for PHP to do here.  Basically you need something
> like camstream to regularly create an image somewhere and then a little
> meta-refresh page that reloads that image.  You are unlikely to be able to
> stream out the video feed in any sort of realtime fashion unless you have
> a whole lot of bandwidth going into this daycare.  The best you can do is
> most likely to update the image every couple of seconds.
>
> You can find camstream here:
>
> http://www.smcc.demon.nl/camstream/index.html
>
> I am assuming you have the right kernel driver for your webcam?  Assuming
> a USB cam, see: http://www.smcc.demon.nl/webcam/
>
> -Rasmus
>
> On Sun, 3 Mar 2002, karthikeyan wrote:
>
> > Hi All,
> >
> >   I am trying to develop a web site for daycare and would like to
support
> > web cam where users(parents) can login and see what their child is
doing.
> >
> >   I have PHP, Apache, Linux Setup.  What are the things required to get
me
> > going with this.
> >
> >   Looking forward for all your response.
> >
> >   Regards,
> >
> > karthikeyan.
> >
> >
> >
> > --
> > 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 ---
Hi Everybody,

  In my somename.cgi file  there are few hidden fields like this with the <form> tag:

  <form action="somename.php" method="post">
    <input type="text" name="somename" size="15"><br>
    <input type="submit">
    <input type="hidden" name="order" value="somevalue1">
    <input type="hidden" name="order" value="somevalue2">
  </form>

  Now in my php file (somename.php) i somehow need to get that hidden name and value 
and 
put it inside my php form like this :

<form action="somename.cgi" method="post">
    <input type="radio" name="somename" value="somevalue">
    <input type="submit">
    <input type="hidden" name="order" value="somevalue1">
    <input type="hidden" name="order" value="somevalue2">
</form>

Note : I cannot change the name of the hidden variable order into an array like 
order[1] or something like that because that variable is being used by some cgi 
program so I want to maintain the name as it is.

Note :  I cannot change my form method=get and use QUERYSTRING

  I have a cgi program which does job very easily like this :

  foreach $line (@orders) {print "<input type=hidden name=\"order\" value=\"$line\"> 
\n"}

   how do i accomplish the same in php.

  Looking forward for your response.

  Regards,

karthikeyan.
--- End Message ---
--- Begin Message ---
Hi Everybody,

  In my somename.cgi file there are few hidden fields like this with the <form> tag:

  <form action="somename.php" method="post">
    <input type="text" name="somename" size="15"><br>
    <input type="submit">
    <input type="hidden" name="order" value="somevalue1">
    <input type="hidden" name="order" value="somevalue2">
  </form>

  Now in my php file (somename.php) i somehow need to get that hidden name and value 
and 
put it inside my php form like this :

<form action="somename.cgi" method="post">
    <input type="radio" name="somename" value="somevalue">
    <input type="submit">
    <input type="hidden" name="order" value="somevalue1">
    <input type="hidden" name="order" value="somevalue2">
</form>

Note : I cannot change the name of the hidden variable order into an array like 
order[1] or something like that because that variable is being used by some cgi 
program so I want to maintain the name as it is.

Note :  I cannot change my form method=get and use QUERYSTRING

  I have a cgi program which does job very easily like this :

  foreach $line (@orders) {print "<input type=hidden name=\"order\" value=\"$line\"> 
\n"}

   how do i accomplish the same in php.

  Looking forward for your response.

  Regards,

karthikeyan.
--- End Message ---
--- Begin Message ---
On Sun, 3 Mar 2002, jtjohnston wrote:

>No one seems to be home at my favourite apache newsgroup :) so I'll ask
>here.
>I'm trying to reconfigure my PHPMyAdmin.
>
>What do I add to my conf file so as in http://phpmyadmin.somehere.com/
>points
>to a specific directory on my (windows) drive?
>
>For example, how would I point http://www.somehere.com// to a
>different directory than http://somehere.com/ , or
>http://123.somehere.com// to a different directory than
>http://456.somehere.com/ ?

This has nothing to do with phpMyAdmin or PHP.  This is a DNS issue.  What
you want is a canonical domain name, some folks refer to them as 'C' names
also.  You will need to request this addition with your isp.  Also, a new
virtual host will need to be added to Apache's config file.

-- 
-----------------------------------------------------------------------
Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/
-----------------------------------------------------------------------


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

Yes, well, PHP supports that a little bit differently.

If you append '[]' to the name, an array will be returned after submit 
with the values of the checked checkboxes.

<INPUT TYPE=TEXT NAME="test[]" VALUE="1" CHECKED>
<INPUT TYPE=TEXT NAME="test[]" VALUE="2">
<INPUT TYPE=TEXT NAME="test[]" VALUE="3" CHECKED>

(submit..)

$test now contains array("1","3");


bvr.


Ben Turner wrote:

>Don't checkboxes, if you name them all the same name, produce a comma delimited 
>string in php of the values selected???
>
>such as for 15 checkboxes with numeric values would produce a string such as....
>
>,,,,,,,13,,,,14,,,18
>
>when the form was submited??  This is the way it was handled in ASP... is there 
>something different for PHP?
>
>thanks!
>Ben
>





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

I have a host with ignore_user_abort turned off in php ini.

the man says
int ignore_user_abort ( [int setting])

so far i have tried 1 and true for the int setting but nothing changed, it still 
aborted.

I want it so the script finishes even the browser conection is lost.

anyone know what i should use for int setting

the man is not clear on this.

Paul Roberts
[EMAIL PROTECTED]
++++++++++++++++++++++++

--- End Message ---
--- Begin Message ---
Which version of PHP?  I just tested it and it works just fine for me.
How exactly do you know the script is not finishing?  Try a test like
this:

<?
    ignore_user_abort(1);

    $fp = fopen('/tmp/test','w');
    for($i=0; $i<30; $i++) {
        echo "Line $i<br>\n";
        flush();
        fputs($fp,"Line $i\n");
        fflush($fp);
        sleep(1);
    }
?>

Load up this file.  You should see it start writing lines to your browser.
If you hit the stop button and break the connection with your server you
will of course stop seeing the output from the script, but if you do a
"tail -f /tmp/test" you should be able to see that the script is indeed
still running as it keeps writing line numbers to this file.

Or did you perhaps think that turning on ignore_user_abort would prevent
the user from disconnecting from the server??  There is absolutely no way
to do that.  He could simply pull his network cable, have a power failure,
get frustrated and chuck his computer out the window...  We don't have a
PHP function that can prevent this.

-Rasmus

On Sun, 3 Mar 2002, Paul Roberts wrote:

> hi
>
> I have a host with ignore_user_abort turned off in php ini.
>
> the man says
> int ignore_user_abort ( [int setting])
>
> so far i have tried 1 and true for the int setting but nothing changed, it still 
>aborted.
>
> I want it so the script finishes even the browser conection is lost.
>
> anyone know what i should use for int setting
>
> the man is not clear on this.
>
> Paul Roberts
> [EMAIL PROTECTED]
> ++++++++++++++++++++++++
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
hm,
well i allready tried it, but it didnt work, so i chose to add it as a module.
...but the problem is, that i cannot "make" php. I allways get this error:

php_gd.h:69: warning: static declaration for `gdImageColorResolve' follows non-static
gd.c:92: conflicting types for `gdIOCtx'
/usr/include/gd_io.h:18: previous declaration of `gdIOCtx'
make[3]: *** [gd.lo] Error 1
make[3]: Leaving directory `/usr/src/php-4.1.2/ext/gd'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/src/php-4.1.2/ext/gd'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/php-4.1.2/ext'
make: *** [all-recursive] Error 1


...and i have no idea how to solve it!
Any help more than welcome...

Regards,

Duncan 


In article <001001c1c15f$22473370$0100a8c0@red5>, php-general@ring-
wraith.com says...

> hi again,
> 
> well sorry about that, it worked when i changed it to:
> 
> ./configure --with-apxs=/usr/local/apache/bin/apxs --with-xml --with-curl 
>--with-swf=/usr/local/flash

 --enable-ftp --with-gd=/usr --with-jpeg-dir=/usr/local --with-xpm-
dir=/usr/X11R6 --with-png-dir=/usr --with-imap --with-ming=/usr/src/ming-
0.2a --enable-magic-quotes --with-mysql --enable-safe-mode --enable-
track-vars --with-ttf --enable-versioning --with-zlib

> 
> ...however, now i ran into another problem: Ming!
> The source is located /usr/src/ming-0.2a
> and the installed files are located:
> /usr/lib
> /usr/include
> 
> but neither of these 3 is accepted in the configure line.
> Or can i just leave it in the configure line and then just add the php_ming.so file, 
>copy it into the extension dir and add it to php.ini file?
> 
> Regards,
> 
> Duncan
> 

Um, lateral thinking here? The same solution that worked for GD should 
work for Ming. In other words, 

--with-ming=/usr

and configure will look under /usr for the lib and include.

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

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






--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


* and then Steven Walker declared....
> Nick,
> 
> If I understand the problem correctly, the form reset button doesn't
> work when the form is prefilled with POST data.
> 
> To overcome this, I created reset button of type='submit' value='Reset'.
> When loading the form page I test to see if submit=='Reset' or 'Submit'.
> If it equals 'Reset', then I clear all the data.

Yep, that's what I ended up doing. Can't believe I didn't work that out
on my own!

Cheers Steven
- -- 
- -----------------------------------------------------------
 www.explodingnet.com   |    Projects, Forums and
                        +    Articles for website owners 
- -- Nick Wilson --     |    and designers.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8gl9kHpvrrTa6L5oRAideAJ9TZIm0RFm9UQL7M9Q4JNcI9XGNygCaA3yK
yRepNH1fZnkLyTU81w4kKZg=
=T53I
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
I have often looked at problems and immediately thought that PHP is not 
capable of the solution, but then some discovery sheds light and 
suddenly many new things are possible. This fell into that category for 
me too :)

Steven J. Walker
Walker Effects
www.walkereffects.com
[EMAIL PROTECTED]

On Sunday, March 3, 2002, at 09:37  AM, Nick Wilson wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> * and then Steven Walker declared....
>> Nick,
>>
>> If I understand the problem correctly, the form reset button doesn't
>> work when the form is prefilled with POST data.
>>
>> To overcome this, I created reset button of type='submit' 
>> value='Reset'.
>> When loading the form page I test to see if submit=='Reset' or 
>> 'Submit'.
>> If it equals 'Reset', then I clear all the data.
>
> Yep, that's what I ended up doing. Can't believe I didn't work that out
> on my own!
>
> Cheers Steven
> - --
> - -----------------------------------------------------------
>  www.explodingnet.com   |    Projects, Forums and
>                         +    Articles for website owners
> - -- Nick Wilson --     |    and designers.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
>
> iD8DBQE8gl9kHpvrrTa6L5oRAideAJ9TZIm0RFm9UQL7M9Q4JNcI9XGNygCaA3yK
> yRepNH1fZnkLyTU81w4kKZg=
> =T53I
> -----END PGP SIGNATURE-----
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi everyone.
I've been working on a program to help me (and others) knock out contact
forms quickly.

I'm looking for some help translating a few error msg's and field titles
into different languages. Currently I have English and Danish.

If you're interested you can check out the project here....
www.explodingnet.com/tools/php-contact-form/

see ya...
- -- 
- -----------------------------------------------------------
 www.explodingnet.com   |    Projects, Forums and
                        +    Articles for website owners 
- -- Nick Wilson --     |    and designers.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8gmCWHpvrrTa6L5oRAo/WAJ9XIDS2YP/ikkw6qxCaec4w7ce5qwCfSKTw
Krw4qFA+yvoUzYEVJ5/ZW+s=
=eygl
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
Hai 

I am very new to PHP develope Can any one please help
me to use session variables. 
I am able to register an variable.
My probelm is how to get the values of that registered
variable in the successive pages?  

Thanx



__________________________________________________
Do You Yahoo!?
Yahoo! Sports - sign up for Fantasy Baseball
http://sports.yahoo.com
--- End Message ---
--- Begin Message ---
On Sun, 3 Mar 2002, Ramesh Nagendra Pillai wrote:

>I am very new to PHP develope Can any one please help
>me to use session variables.
>I am able to register an variable.
>My probelm is how to get the values of that registered
>variable in the successive pages?

You probably need to pass the session_name() and session_id() in the url,
or if you're submitting a form you can send them ahead as hidden
variables:

Make your links like this:

<a href="page.php?<?=session_name()?>=<?=session_id()?>">click
here</a>

Or your hidden form fields like this:

<input type="hidden" name="<?=session_name()?>" value="<?session_id()?>">

Also, there is a specific compile time option that can influence if
this is automatic or not, --enable-trans-sid, have a look at:

http://www.php.net/manual/en/ref.session.php
http://www.php.net/manual/en/install.configure.php


-- 
-----------------------------------------------------------------------
Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/
-----------------------------------------------------------------------


--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


* and then Ramesh Nagendra Pillai declared....
> I am very new to PHP develope Can any one please help
> me to use session variables. 
> I am able to register an variable.
> My probelm is how to get the values of that registered
> variable in the successive pages?  


Firstly, read up on them in the manual. There's loads of good stuff
there. Here's the quick answer to your question though.

page-one.php
<?
session_start();
session_register("a_var");
$a_var="a value";
?>

page-two.php
<?
session_start();
print($a_var);
?>
- -- 
- -----------------------------------------------------------
 www.explodingnet.com   |    Projects, Forums and
                        +    Articles for website owners 
- -- Nick Wilson --     |    and designers.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8gmzyHpvrrTa6L5oRAskdAJ9zMCCJuMSSe97qfj0RbbUUOdq3hQCePJw9
pb/ZAO3x1aztJa9zyowCd0I=
=Ct9D
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
To all who responded: Thank You!

I realized something after I posted the message- I did a little 
research to clarify what I really need, and it boils down to this: I 
need a php installation that supports the GIF and JPEG-related 
functions (like ImageCreateFromGif), and it would also be nice if it 
offered Truetype support, so that I can use functions like 
ImageTTFText. I will check out the recommendations at this point.

Thanks very much.

Tom


>Datasnake.co.uk would be able to help you out
>
>Alastair
>
>>  -----Original Message-----
>>  From: Tom [mailto:[EMAIL PROTECTED]]
>>  Sent: 28 February 2002 04:57
>>  To: [EMAIL PROTECTED]
>>  Subject: [PHP] Hosting companies that offer PHP?
>>
>>
>>
>>  I think I might be about to discover that our hosting company neither
>>  supports the GD-related functions in php, nor has any plans to do so.
>>  Consequently, I may very well be looking for another hosting company,
>>  and I'd be interested in any recommendations from the php community
>>  at large, preferably of hosts that offer shell accounts.
>>
>>  Regards,
>>
>>  Tom
>>
>>  --
>>  PHP General Mailing List (http://www.php.net/)
>>  To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
On Fri, 2002-03-01 at 20:03, michael kimsal wrote:
> Diana Castillo wrote:
> > Is there any way tomake a page that cannot be printed??
> > 
> 
> 
> GZIP the page and force the end user to use Netscape.  ???

No, still wouldn't work. If the data ever gets displayed, then it
is present on the viewer's machine, and can be printed.


-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506

--- End Message ---
--- Begin Message ---
Lars Torben Wilson wrote:

> On Fri, 2002-03-01 at 20:03, michael kimsal wrote:
> 
>>Diana Castillo wrote:
>>
>>>Is there any way tomake a page that cannot be printed??
>>>
>>>
>>
>>GZIP the page and force the end user to use Netscape.  ???
>>
> 
> No, still wouldn't work. If the data ever gets displayed, then it
> is present on the viewer's machine, and can be printed.
> 
> 
> 


It was meant as a jab at Netscape.  Yes someone could take a screen shot
and print, or grab to the clipboard and print the text, but hitting 
'print' from netscape would cause it to go grab gzipped info and print 
out the zipped info - essentially printing garbage to the printer 
instead of what it's rendered on the screen earlier.

--- End Message ---
--- Begin Message ---
This jaust what I wanted to say... but while reading this I got to question:
Is it possible to count active sessions, if the one uses php's sessions
without writing any handler functions, just what php4 provides by default?

>
> >I have a site with logins, etc.  I was wondering if there's any way to
see
> >how many users are logged in.  I know I could change a database and add
one
> >to a number when a user logs in, and subtract one when they log off, but
> >what if they just go to another site or close their browser?
>
> I use database managed sessions and count the number of "active"
> sessions, like how many sessions have had activity in the last 5 minutes
> or so.



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

I'm looking for the fastest way to fetch multiple pages from php. 
Currently I'm trying the curl-lib and it works fine - I just don't 
understand how to use curl that it stores multiple requests in multiple 
files.
I'll try to explain my problem more detailed:
Somewhere are the pages
http://foo.bar.com/page1.html
http://foo.bar.com/page2.html
http://foo.bar.com/page3.html
I want to fetch them with php and write them locally to the files
foobarpage1.html
foobarpage2.html
foobarpage3.html
And I try to achieve a maximal speed.
I tried following code:

$fh1 = fopen("foobarpage1.html", "w");
$fh2 = fopen("foobarpage2.html", "w");
$fh3 = fopen("foobarpage3.html", "w");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://foo.bar.com/page1.html";);
curl_setopt($ch, CURLOPT_FILE, $fh1);
curl_exec($ch); //exec1
curl_setopt($ch, CURLOPT_URL, "http://foo.bar.com/page2.html";);
curl_setopt($ch, CURLOPT_FILE, $fh2);
curl_exec($ch); //exec2
curl_setopt($ch, CURLOPT_URL, "http://foo.bar.com/page3.html";);
curl_setopt($ch, CURLOPT_FILE, $fh3);
curl_exec($ch);
curl_close($ch);

fclose($fh1);
fclose($fh2);
fclose($fh3);

I just tells me that it's not capable of executing one handler multiple 
times. If I delete the lines with exec1 and exec2 it works but only 
stores the last page...

Who can help?

TIA & greets
Stefan Rusterholz

--- End Message ---
--- Begin Message ---
$SQLString = "INSERT INTO Movies (Title, Actors, Review, Reviewer, Short)
     VALUES ('$Title','$Actors','$Review','$Reviewer','$Short')";

As the manual says: Note: Unlike the two other syntaxes, variables will not
be expanded when they occur in single quoted strings. ... So maybe some your
fiels requires a numeric value, but because no extraction occurs, it
receives string?


Dr. Shim <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> I did, and a rather informative error message came. I didn't know how to
> debug like that. Sorry, I'm rather new to this.
>
> It says [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT
> INTO statement.
>
>
>
>
>
> "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED].;
> Well, add this and tell us what it says:
>
> if(!$cursor) echo odbc_error($db).": ".odbc_errormsg($db);
>
> right after that odbc_exec() call.
>
> *always check for errors - and when you get one, show it!*
>
> -Rasmus
>
> On Sat, 2 Mar 2002, Dr. Shim wrote:
>
> > I've tried, and tried. Reread, and reread. I can't at all find out
what's
> > wrong with these two lines of code.
> >
> >  $SQLString = "INSERT INTO Movies (Title, Actors, Review, Reviewer,
Short)
> >      VALUES ('$Title','$Actors','$Review','$Reviewer','$Short')";
> >  $cursor = odbc_exec($db, $SQLString);
> >
> > I have an if...then conditional statement causing echo to print out an
> error
> > message if the $cursor returns false.
> >
> > The $cursor keeps returning false. I don't know why! My $db variable
> (which
> > plugs into the odbc database) is fine. Those two lines have got to be
the
> > problem.
> >
> >
> > Can you people help me out with this?
> >
> > If I have to give you my whole script (not very long) I will.
> >
> > Thanks for any help you can give me.
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
>


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

First, thanks for reading my post...I tried to post this yesterday but it
disappeared - so if you've seen this before, please ignore it...

I am needing to change the permissions on a folder that is owned by 'usr'.
However, as I am trying to do this from a browser through php, I am browsing
as user 'nobody' and therefore I cannot change the directory permissions.

Some things to note. I know that you can change permissions through ftp or
telnet, however I am trying to design a system that can be installed simply
by uploading it and then working through a browser. Many of my customers who
will use the system use dreamweaver to upload and have never heard of chmod.
I do not want to have to manually set permissions on the directories for
them.

I am aware that php has some ftp functions and that these could possibly be
used to change the permissions. However, my ISP has not enabled these php
features and is unlikely to do so.

Is there another way? I know that you can use passthru() to chmod a dir (as
user 'nobody') - but that's about the extent of my knowledge.

Any help much appreciated.

Cheers

Pete







--- End Message ---
--- Begin Message ---
I'm getting loads of "undefined variable" errors with this script. any1 know
why?


--- End Message ---
--- Begin Message ---
Hi there, i created 3 tables in mysql, which is college.students,
college.classes, and college,student_in_class. After that, I made a web
form (page) that lists all the current students, and lists all the
current classes (each with a radio button).  As a user, you can click on
a student radio button, and a class radio button and that student
becomes registered in that class (ie fill the "student_in_class" table. 

I referred to your code and tried to apply to my module, but not much
luck. Do u mind take a look of my code and tell me what did i do wrong?
Much appreciated....


<?php
# Global variables
$script_name = 'register2.php';
$databasename = 'college';
$host = 'localhost';
$user = 'root';
$password = 'mollier';

function select_student() {
        # explicity request to use these global variables
        global $script_name, $databasename, $host, $user, $password;

        # connect to database
        $link = mysql_connect($host, $user, $password)
                or die("Connection failed: " . mysql_error());

        # select our table
        mysql_select_db($databasename)
                or die("Database selection failed [$db_name]: " .
mysql_error());

        # send a query
        $sql = "SELECT * FROM college.students ORDER BY student_id";
        $result = mysql_query($sql)
                or die("Query failed: " . mysql_error());

        echo "<H2>Welcome to Class Selection Page</H2>\n";
        echo "<FORM METHOD=POST ACTION=\"$script_name\">\n";
        echo "<TABLE BORDER=1>\n";


        # print the student selection table
        $table_row =  "<TR>";
        $table_row .= "<TH> </TH>";
        $table_row .= "<TH>Students First Name</TH>";
        $table_row .= "<TH>Students Last Name</TH>";
        $table_row .= "<TH>Address</TH>";
        $table_row .= "</TR>";
        echo "$table_row\n";
        while ($row = mysql_fetch_array($result)) {
                $table_row =  "<TR>";
                $table_row .= "<TD><INPUT TYPE=RADIO NAME=\"student\"";
                $table_row .= " VALUE=\"$row[student_id]\"></TD>";
                $table_row .= "<TD>$row[firstname]</TD>";
                $table_row .= "<TD>$row[lastname]</TD>";
                $table_row .= "<TD>$row[address]</TD>";
                $table_row .= "<TR>";
                echo "$table_row\n";
        }
        echo "</TABLE>\n";

        echo "</FORM>\n";
        
        mysql_free_result($result);
        mysql_close($link);
}


function select_class() {
        # explicity request to use these global variables
        global $script_name, $databasename, $host, $user, $password;

        # connect to database
        $link = mysql_connect($host, $user, $password)
                or die("Connection failed: " . mysql_error());

        # select our table
        mysql_select_db($databasename)
                or die("Database selection failed [$db_name]: " .
mysql_error());

        # send a query
        $sql = "SELECT * FROM college.classes ORDER BY class_id";
        $result = mysql_query($sql)
                or die("Query failed: " . mysql_error());

        
        echo "<FORM METHOD=POST ACTION=\"$script_name\">\n";
        echo "<TABLE BORDER=1>\n";


        # print the class selection table
        $table_row =  "<TR>";
        $table_row .= "<TH> </TH>";
        $table_row .= "<TH>Class Name</TH>";
        $table_row .= "<TH>Class Start Date</TH>";
        $table_row .= "<TH>Credits</TH>";
        $table_row .= "</TR>";
        echo "$table_row\n";
        while ($row = mysql_fetch_array($result)) {
                $table_row =  "<TR>";
                $table_row .= "<TD><INPUT TYPE=RADIO NAME=\"class\"";
                $table_row .= " VALUE=\"$row[class_id]\"></TD>";
                $table_row .= "<TD>$row[name]</TD>";
                $table_row .= "<TD>$row[start_date]</TD>";
                $table_row .= "<TD>$row[credits]</TD>";
                $table_row .= "<TR>";
                echo "$table_row\n";
        }
        echo "</TABLE>\n";

        echo "<INPUT TYPE=SUBMIT NAME=\"button\" VALUE=\"Submit
Result\">\n";
        echo "<INPUT TYPE=SUBMIT NAME=\"button\" VALUE=\"View
Result\">\n";
        echo "</FORM>\n";
        
        mysql_free_result($result);
        mysql_close($link);
}


function view_result() {
        # explicity request to use these global variables
        global $script_name, $databasename, $host, $user, $password;

        # connect to database
        $link = mysql_connect($host, $user, $password)
                or die("Connection failed: " . mysql_error());

        # select our table
        mysql_select_db($databasename)
                or die("Database selection failed [$db_name]: " .
mysql_error());

        # send a query
        $sql =  "SELECT student_id,class_id";
        $sql .= "FROM college.student_in_class";
        $sql .= "ORDER BY class_id";
        $result = mysql_query($sql)
                or die("Query failed: " . mysql_error());

        echo "<H2>Student in Class</H2>\n";
        echo "<TABLE BORDER=1>\n";

        # print the class selection table
        $table_row =  "<TR>";
        $table_row .= "<TH>Students ID</TH>";
        $table_row .= "<TH>Class ID</TH>";
        $table_row .= "</TR>";
        echo "$table_row\n";
        while ($row = mysql_fetch_array($result)) {
                $table_row =  "<TR>";
                $table_row .= "<TD>$row[student_id]</TD>";
                $table_row .= "<TD>$row[class_id]</TD>";
                $table_row .= "<TR>";
                echo "$table_row\n";
        }
        echo "</TABLE>\n";

        echo "<FORM METHOD=POST ACTION=\"$script_name\">\n";
        echo "<INPUT TYPE=SUBMIT NAME=\"button\" VALUE=\"Back to Student
Page\">\n";
        echo "</FORM>\n";
        
        mysql_free_result($result);
        mysql_close($link);
}



function save_result($student, $class) {
        # explicity request to use these global variables
        global $script_name, $databasename, $host, $user, $password;

        # connect to database
        $link = mysql_connect($host, $user, $password)
                or die("Connection failed: " . mysql_error());

        # select our table
        mysql_select_db($databasename)
                or die("Database selection failed [$db_name]: " .
mysql_error());

        # send a query
        $sql =  "INSERT INTO college.student_in_class";
        $sql .= "SET student_id='$student',class_id='$class'";
        mysql_query($sql)
                or die("Query failed: " . mysql_error());

        mysql_close($link);

        return mysql_insert_id();
}
?>

<HTML>
<HEAD><TITLE>Welcome to Class Selection Page</TITLE></HEAD>
<BODY>

<?php
        # main routine
        switch ($button) {
        case 'Submit Result':
                save_result($student, $class);
                select_student();
                select_class();
                break;
        case 'View Result':
                view_result();
                break;
        default:
                select_student();
                select_class();
        }
?>



</BODY></HTML>

--- End Message ---

Reply via email to