php-general Digest 31 Aug 2002 20:39:41 -0000 Issue 1558

Topics (messages 114754 through 114788):

Re: Ridding myself of HTML tags
        114754 by: Paul Roberts

Re: few things...
        114755 by: Andrew Brampton

Re: mail() function problem
        114756 by: Justin French
        114757 by: Dave at Sinewaves.net

Re: php and gnupg problems.
        114758 by: Jon Lawrence

calling sql results inoto variables
        114759 by: Victor
        114761 by: victor

Submit form from javascript code
        114760 by: Madjid Nasiri
        114788 by: Jason Wong

Re: command line argument  vs. urlencode ?
        114762 by: Renato Lins

Script Execution via URL
        114763 by: Sascha Braun

newest entry in db
        114764 by: Victor

Last URL visited
        114765 by: Monil Chheda

header problem
        114766 by: mike

working with images
        114767 by: stu9820

why do i get this error please tell me?
        114768 by: Victor
        114769 by: Chris Knipe
        114770 by: victor
        114775 by: Mark Charette

RE : include interpreted php file
        114771 by: you
        114773 by: Chris Knipe

Dumb Question
        114772 by: Gerard Samuel
        114776 by: . Edwin
        114781 by: Gerard Samuel
        114784 by: . Edwin

alter switch variable inside case?
        114774 by: Joe Janitor
        114777 by: . Edwin
        114778 by: Joe Janitor
        114780 by: . Edwin
        114783 by: Joe Janitor
        114785 by: . Edwin

posting form values doesn't work
        114779 by: Øystein Håland
        114786 by: Jason Wong

Re: [PHP-DB] RE: [PHP] why do i get this error please tell me?
        114782 by: victor
        114787 by: Mark Charette

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 ---
have a look at peg_replace in the man, you could also get your users to save as 
filtered html which get rid of some of it, there's also a MS tool "Microsoft Office 
HTML Filter 2" that will clean it some more, it says it's for word 2000 but it works 
fine for word 2002/XP.

but your best option is to use preg_replace to swap out all the "smart tags" etc.
Paul Roberts
http://www.paul-roberts.com
[EMAIL PROTECTED]
++++++++++++++++++++++++


----- Original Message ----- 
From: "DL Neil" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, August 31, 2002 12:02 AM
Subject: Re: [PHP] Ridding myself of HTML tags


> Liam,
> If you were to stristr()/remove everything up to and including the </head>
> tag, would that take care of things?
> =dn
> 
> 
> > I've got a lil problem with HTML tags. Here's the description.
> >
> > My site accepts HTML files by upload. A lot of these files are written in
> MS
> > Word and then saved as HTML files from that. MS Word likes to put a bunch
> of
> > garbage at the beginning of the file. Now, when users upload their HTML
> > files, my script goes and striptags all of the unnecessary junk in there
> > except it can't rid all this junk (HTML, XML, CSS, JavaScript) at the
> > beginning of the HTML file. Some of these tags span multiple lines, and my
> > script goes through line-by-line, so it won't identify these as tags. Is
> > there a simpler fashion? I don't need the junk about style sheeting and
> > stuff, because I have a style sheet that will take care of styling the
> files
> > the way they should be. I don't want the extra tags, even though they're
> > invisible to users when they web-view, because these are e-mailable files
> > (for HTML mail, it's fine; for text mail, I need to strip it down and
> that's
> > the problem).
> >
> > =================================================
> > Just in case, I've included the HTML code below:
> >
> >
> > <html xmlns:o="urn:schemas-microsoft-com:office:office"
> > xmlns:w="urn:schemas-microsoft-com:office:word"
> > xmlns="http://www.w3.org/TR/REC-html40";>
> >
> > <head>
> > <meta http-equiv=Content-Type content="text/html; charset=windows-1252">
> > <meta name=ProgId content=Word.Document>
> > <meta name=Generator content="Microsoft Word 10">
> > <meta name=Originator content="Microsoft Word 10">
> > <link rel=File-List href="NW100_files/filelist.xml">
> > <title>Test test test</title>
> > <!--[if gte mso 9]><xml>
> >  <o:DocumentProperties>
> >   <o:Author>Liam Gibbs</o:Author>
> >   <o:LastAuthor>Liam Gibbs</o:LastAuthor>
> >   <o:Revision>1</o:Revision>
> >   <o:TotalTime>1</o:TotalTime>
> >   <o:Created>2002-08-30T18:09:00Z</o:Created>
> >   <o:LastSaved>2002-08-30T18:10:00Z</o:LastSaved>
> >   <o:Pages>1</o:Pages>
> >   <o:Words>13</o:Words>
> >   <o:Characters>79</o:Characters>
> >   <o:Company>SXIA</o:Company>
> >   <o:Lines>1</o:Lines>
> >   <o:Paragraphs>1</o:Paragraphs>
> >   <o:CharactersWithSpaces>91</o:CharactersWithSpaces>
> >   <o:Version>10.3501</o:Version>
> >  </o:DocumentProperties>
> > </xml><![endif]--><!--[if gte mso 9]><xml>
> >  <w:WordDocument>
> >   <w:SpellingState>Clean</w:SpellingState>
> >   <w:GrammarState>Clean</w:GrammarState>
> >   <w:Compatibility>
> >    <w:BreakWrappedTables/>
> >    <w:SnapToGridInCell/>
> >    <w:WrapTextWithPunct/>
> >    <w:UseAsianBreakRules/>
> >   </w:Compatibility>
> >   <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
> >  </w:WordDocument>
> > </xml><![endif]-->
> > <style>
> > <!--
> >  /* Style Definitions */
> >  p.MsoNormal, li.MsoNormal, div.MsoNormal
> > {mso-style-parent:"";
> > margin:0cm;
> > margin-bottom:.0001pt;
> > mso-pagination:widow-orphan;
> > font-size:12.0pt;
> > font-family:"Times New Roman";
> > mso-fareast-font-family:"Times New Roman";}
> > span.SpellE
> > {mso-style-name:"";
> > mso-spl-e:yes;}
> > @page Section1
> > {size:612.0pt 792.0pt;
> > margin:72.0pt 90.0pt 72.0pt 90.0pt;
> > mso-header-margin:35.4pt;
> > mso-footer-margin:35.4pt;
> > mso-paper-source:0;}
> > div.Section1
> > {page:Section1;}
> > -->
> > </style>
> > <!--[if gte mso 10]>
> > <style>
> >  /* Style Definitions */
> >  table.MsoNormalTable
> > {mso-style-name:"Table Normal";
> > mso-tstyle-rowband-size:0;
> > mso-tstyle-colband-size:0;
> > mso-style-noshow:yes;
> > mso-style-parent:"";
> > mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
> > mso-para-margin:0cm;
> > mso-para-margin-bottom:.0001pt;
> > mso-pagination:widow-orphan;
> > font-size:10.0pt;
> > font-family:"Times New Roman";}
> > </style>
> > <![endif]-->
> > </head>
> >
> > <body lang=EN-US style='tab-interval:36.0pt'>
> >
> > <div class=Section1>
> >
> > <p class=MsoNormal>Test <span class=SpellE>test</span> <span
> > class=SpellE>test</span></p>
> >
> > <p class=MsoNormal align=center style='text-align:center'><span
> > class=SpellE>Fdjfkasdjfkla</span></p>
> >
> > <p class=MsoNormal align=center style='text-align:center'><span
> > class=SpellE><b
> > style='mso-bidi-font-weight:normal'>Fdjkslafjdklaf</b></span></p>
> >
> > <p class=MsoNormal style='text-align:justify'><o:p>&nbsp;</o:p></p>
> >
> > <p class=MsoNormal style='text-align:justify'><span
> > class=SpellE>Fdasfdfasffasdfdaadfdfs</span></p>
> >
> > <p class=MsoNormal style='text-align:justify'><span
> > class=SpellE>Dfsdfs</span></p>
> >
> > <p class=MsoNormal style='text-align:justify'>Hi</p>
> >
> > <p class=MsoNormal style='text-align:justify'><o:p>&nbsp;</o:p></p>
> >
> > <p class=MsoNormal style='text-align:justify'><span
> > style='mso-tab-count:3'> </span><span
> > class=SpellE>Jfdklas</span></p>
> >
> > <p class=MsoNormal style='text-align:justify'><o:p>&nbsp;</o:p></p>
> >
> > </div>
> >
> > </body>
> >
> > </html>
> >
> > --
> > 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 ---
comments inline
----- Original Message -----
From: "Matt Zur" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, August 31, 2002 4:40 AM
Subject: [PHP] few things...


> First of all...
> I'm a bit confused is there really a difference between echo and print?
>     They seem to do the same thing?

As far as anyone is concerned they do the same... Check the archives for
MANY MANY past discusions

>
> Also... I have trouble searching for these things in the docs:
> A Call Function to emulate a browser and contact a remote host?  For
> example... to load in a piece of text from another web site?

fopen? here is a quick snip from the user comments $page= join ('', file
('www.yahoo.com')); that basically loads all the HTML at Yahoo.com into
the varible $page... neat huh :)

>
> Hidden fuction.  For example lets say I have a form with 10 variables.
> Is there a function where I can do something like:
>
> hidden($var1,$var2,$var3)  etc etc so it will write this:
> <input type="hidden" name="var1name" value="var1value">
> <input type="hidden" name="var2name" value="var2value">
> <input type="hidden" name="var2name" value="var2value">

PHP doesn't really write HTML for you, thats your job... so a function or
a simple loop could do this...
for ($i=0; $i<3; $i++)
    echo "<input type='hidden' name='$$var[$i]' value='$var[$i]'>";

>
> Thanks for the help!

No problems :)
Andrew

>
> PHP Toolbar for Homesite v5.0 - http://zurnet.com/dl/hsphptb/
> Version 1.5 Coming Soon!!!
>
>
>
> --
> Matt Zur
> [EMAIL PROTECTED]
> http://www.zurnet.com
>


--- End Message ---
--- Begin Message ---
I think mailing list managers like Yahoo, ezmlm, etc all have "features" in
them to suspect bots and programs from subscribing/posting to the groups.  I
know I've had trouble subscribing/posting to groups managed by ezmlm...

Probably there is a header or two that PHP automatically sets which makes
the mailing lists suspicious... or something!! I don't know enough about
email to really come up with an answer!!!

You could try setting some headers similar to what your email client sets,
to see if it's something "missing"... or try sending yourself an email from
a php script and analysing the headers it sets.

It could also be the lack of a return address or something similar that
throws the lists off too.


Justin


on 31/08/02 6:32 PM, Akhmad D. Sembiring ([EMAIL PROTECTED]) wrote:

> Dear All,
> 
> I have a little problem with mail() function,
> 
> PHP Code:
> 
> --------------------------------------
> mail($email, "Membership ok", $themsg,
> "From: [EMAIL PROTECTED]\r\n");
> 
> mail("[EMAIL PROTECTED]",
> "", "", "From: $email\r\n");
> --------------------------------------
> 
> Why does the second mail() function did not ever send the email to
> yahoogroups?
> 
> I wonder, can the mail() function be put in a loop structure (that traverse
> an array of emails) and send all emails successfully?
> 
> Thanks for your advice,
> 
> Daniel
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02
> 

--- End Message ---
--- Begin Message ---
Most mailing lists reject mail if the Subject is blank.

That would probably explain why your subjectless 2nd example is disappearing
into the void.

Dave



-----Original Message-----
From: Justin French [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 31, 2002 3:20 AM
To: Akhmad D. Sembiring; [EMAIL PROTECTED]
Subject: Re: [PHP] mail() function problem


I think mailing list managers like Yahoo, ezmlm, etc all have "features" in
them to suspect bots and programs from subscribing/posting to the groups.  I
know I've had trouble subscribing/posting to groups managed by ezmlm...

Probably there is a header or two that PHP automatically sets which makes
the mailing lists suspicious... or something!! I don't know enough about
email to really come up with an answer!!!

You could try setting some headers similar to what your email client sets,
to see if it's something "missing"... or try sending yourself an email from
a php script and analysing the headers it sets.

It could also be the lack of a return address or something similar that
throws the lists off too.


Justin


on 31/08/02 6:32 PM, Akhmad D. Sembiring ([EMAIL PROTECTED]) wrote:

> Dear All,
>
> I have a little problem with mail() function,
>
> PHP Code:
>
> --------------------------------------
> mail($email, "Membership ok", $themsg,
> "From: [EMAIL PROTECTED]\r\n");
>
> mail("[EMAIL PROTECTED]",
> "", "", "From: $email\r\n");
> --------------------------------------
>
> Why does the second mail() function did not ever send the email to
> yahoogroups?
>
> I wonder, can the mail() function be put in a loop structure (that
traverse
> an array of emails) and send all emails successfully?
>
> Thanks for your advice,
>
> Daniel
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02
>


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

--- End Message ---
--- Begin Message ---
Richard,
Thanks for the reply.
'top' shows that the script is being run as nobody.
the '2<' stuff allow the password to be passed as a file descriptor and I 
think it is this that is breaking.
I have setup a nobody directory just for this. I then set the HOME variable 
to point to this directory.
If on command line, I su to nobody, setup the enviroment variable HOME, 
GNUPGHOME etc then run the php script command line it runs perfectly.
The problem seems to be that when running from apache, it can't handle the 2< 
bit.
If I set up a test key with no password, then I can run the script perfectly 
(ie I don't need to pass the password-fd bit.)
If I use exec, I get the same results.
I'll add the implode bits and try that.

Regards,
Jon


On Saturday 31 Aug 2002 01:06 am, Richard Lynch wrote:
> >Hi,
> >Appologies if this comes through twice. I tried to post it via goolg
> > groups but it didn't seem to work.
> >
> >
> >If I run the following script from within apache, then the script
> >fails and returns $error=2
> ><?php
> >$data="this is a test";
> >$GNUPGHOME="/home/nobody/.gnupg";
> >putenv("GNUPGHOME=$GNUPGHOME");
> >$HOME="/home/nobody/";
> >putenv("HOME=$HOME");
> >system ("echo '$data' |/usr/bin/gpg -vv --clearsign -u testing -o
> >/home/httpd/html/nic/output --passphrase-fd 2
> >2</home/httpd/html/nic/test",$error);
> >print $error;
> >?>
> >.
> >I've seen quite a lot on the web about this suggesting that it's a
> >permissions problem.
> >However, If I add #!/usr/bin/php to the top of the script and make it
> >executable, then su to 'nobody' (which appache runs as) then the
> >script runs perfectly from the command line - so I think that the
> >permissions are all OK.
> >Any ideas where I'm going wrong?
>
> Does <?php phpinfo();?> really and truly say that PHP is running as
> 'nobody'?
>
> Is there really a "nobody" directory?  I think part of the point of using
> "nobody" is that they shouldn't even *have* a directory in the first
> place...
>
> If the .gnupg files/directories all involved are owned by 'nobody' anyway,
> make them world readable and writable.  It's not all that different at that
> point anyway, since anybody would write a PHP script running as 'nobody' to
> read/write them.
>
> Is /home/httpd/html/nic/output really world-writable?...  Scary.
>
> I don't claim to understand that 2< ...test crap, but I'm guessing you're
> trying to re-direct errors somewhere?  Try taking that out for now, use
> exec() instead of system() and see what output you actually get:
>
> exec($command, $result, $error);
> echo implode("", $result);
>
> You may be a lead from that on where things are breaking.
--- End Message ---
--- Begin Message ---
I'm trying to go about doing this:

While there is data in an array, get and echo individual pieces from
this array and execute a mysql query that gets the other info in the
table where arraypiece. Stop when all arraypice have been echoed.

The array gets its values from and checkbox form. I got that part: 

<input type="checkbox" name="check[]" value="'.$ID.'">

So I count the number of times there is something in $check, which I
think is done like so:

for($i = 0; $i < sizeof($check); $i++) {
echo $i;
}

that should give me the number of checboxes clicked. (it does, I
verified)

so, now I say:

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
echo $data;

which brings me to getting the rest of the data from the tables (the
array I was talking about holds the ID) (aka the key) but I still need
to put the key in the door.

Ok, so no I would need to loop a mysql query for as long as there is
data in the array, - since I only have one key for each row.

Let me try to write it:

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
#echo $data;
mysql_query("SELECT * FROM table WHERE ID = '$data'");
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
}

Now, this should do the trick, let's test it ... testing ... 

Nope, mysql can't execute that query...
Hmmm...


I get this

could not execute queryYou have an error in your SQL syntax near 'table
WHERE ID = '1'' at line 1

no shit! I actually don't have a table called table!

Fixed that, testing ....

could not execute queryNo Database Selected

ok, let's do that. (I've been up all nigh what do you want!)

ok, now what?!

I get NOTHING! NOTHING! WHAAAAHHT!

I tried hardcoding the $ID, nothing, so that must be ok, as we have
proved earlier,

By this time I ended up with this code:

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
#echo $data;
mysql_query("SELECT * FROM kodak_user_pictures WHERE ID = '1'")
or die ('could not execute query '.mysql_error());
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
}

of course it gives me nothing! 

What the hell is $row?

Ok, let's fix that.

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
#echo $data;
$db_data = mysql_query("SELECT * FROM kodak_user_pictures WHERE ID =
'1'");
$row = mysql_fetch_array(db_data);
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
}

now I get this... I'm also getting tired...

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource

STUPID $ SIGN! (look near db_data, nope, the second one!)

Ok, let's test ... 

Ok, good, let's switch the hardcoded 1 from the query back to the
$data...
 Testing ...

Ok, now it only gets one...

Let's try a for each

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
#echo $data;
foreach ($data as $check[$i]) {
$db_data = mysql_query("SELECT * FROM kodak_user_pictures WHERE ID =
'$data'");
$row = mysql_fetch_array($db_data);
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
}
}

Warning: Invalid argument supplied for foreach()

Ok... 

Not better, but let's see...

Ok, now I ende up with this code:

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i];
$db_data = ("SELECT * FROM mytable WHERE ID = '$check[$i]'");
$row = mysql_query($db_data);
# $row = mysql_fetch_array($db_data);
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
#echo $data;
}

I don';t know what to do, I get nothing, I think the error is that I do
not know how to call the mysql query results into the variables fro
echoing, please I beg you someone tell me.


- Victor > www.argilent.com




______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
The silly me, I had an exit; inside the for loop and I was wondering why
id only looped once, somebody slap me!

- Victor > www.argilent.com

-----Original Message-----
From: Victor [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, August 31, 2002 7:52 AM
To: [EMAIL PROTECTED]
Subject: [PHP] calling sql results inoto variables

I'm trying to go about doing this:

While there is data in an array, get and echo individual pieces from
this array and execute a mysql query that gets the other info in the
table where arraypiece. Stop when all arraypice have been echoed.

The array gets its values from and checkbox form. I got that part: 

<input type="checkbox" name="check[]" value="'.$ID.'">

So I count the number of times there is something in $check, which I
think is done like so:

for($i = 0; $i < sizeof($check); $i++) {
echo $i;
}

that should give me the number of checboxes clicked. (it does, I
verified)

so, now I say:

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
echo $data;

which brings me to getting the rest of the data from the tables (the
array I was talking about holds the ID) (aka the key) but I still need
to put the key in the door.

Ok, so no I would need to loop a mysql query for as long as there is
data in the array, - since I only have one key for each row.

Let me try to write it:

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
#echo $data;
mysql_query("SELECT * FROM table WHERE ID = '$data'");
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
}

Now, this should do the trick, let's test it ... testing ... 

Nope, mysql can't execute that query...
Hmmm...


I get this

could not execute queryYou have an error in your SQL syntax near 'table
WHERE ID = '1'' at line 1

no shit! I actually don't have a table called table!

Fixed that, testing ....

could not execute queryNo Database Selected

ok, let's do that. (I've been up all nigh what do you want!)

ok, now what?!

I get NOTHING! NOTHING! WHAAAAHHT!

I tried hardcoding the $ID, nothing, so that must be ok, as we have
proved earlier,

By this time I ended up with this code:

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
#echo $data;
mysql_query("SELECT * FROM kodak_user_pictures WHERE ID = '1'")
or die ('could not execute query '.mysql_error());
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
}

of course it gives me nothing! 

What the hell is $row?

Ok, let's fix that.

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
#echo $data;
$db_data = mysql_query("SELECT * FROM kodak_user_pictures WHERE ID =
'1'");
$row = mysql_fetch_array(db_data);
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
}

now I get this... I'm also getting tired...

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource

STUPID $ SIGN! (look near db_data, nope, the second one!)

Ok, let's test ... 

Ok, good, let's switch the hardcoded 1 from the query back to the
$data...
 Testing ...

Ok, now it only gets one...

Let's try a for each

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i]; 
#echo $data;
foreach ($data as $check[$i]) {
$db_data = mysql_query("SELECT * FROM kodak_user_pictures WHERE ID =
'$data'");
$row = mysql_fetch_array($db_data);
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
}
}

Warning: Invalid argument supplied for foreach()

Ok... 

Not better, but let's see...

Ok, now I ende up with this code:

for($i = 0; $i < sizeof($check); $i++) {
# echo $i;
echo '<p>';
$data = $check[$i];
$db_data = ("SELECT * FROM mytable WHERE ID = '$check[$i]'");
$row = mysql_query($db_data);
# $row = mysql_fetch_array($db_data);
$db_ID = $row["ID"];
$db_picture_name = $row["picture_name"];
echo $db_ID;
echo $db_picture_name;
#echo $data;
}

I don';t know what to do, I get nothing, I think the error is that I do
not know how to call the mysql query results into the variables fro
echoing, please I beg you someone tell me.


- Victor > www.argilent.com




______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
Hi all
I need submit a form from javascript code. My code near this code:

<!-- My Code -->
<form name="myform" action="..." method="POST>
<input type="hidden" name="id" value="0">
</form>
<script language="javascript">
function submitform(iId)
{
  document.myform.elements['id'].value=iId;
  document.myform.submit();
  alert("foo"); // This is code is dummy
  retrun false;
}
</script>
<a href="..." onMouseDown="submitform(1);">Id One</a><br>
<a href="..." onMouseDown="submitform(2);">Id Two</a><br>
    ....
<a href="..." onMouseDown="submitform(1000);">Id 1000</a><br>
<!-- End My Code -->

If I remove alert() call in submitform function, this code noting work, but
if i used alert() or confirm() function this code working, Why?
How can i remove alert() function and my code work?

Thanks for Answer

Madjid Nasiri
[EMAIL PROTECTED]
http://www.kawacomputer.com



--- End Message ---
--- Begin Message ---
On Saturday 31 August 2002 19:43, Madjid Nasiri wrote:

> I need submit a form from javascript code. My code near this code:

Please ask javascript questions on a javascript list.

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

/*
Steinbach's Guideline for Systems Programming:
        Never test for an error condition you don't know how to handle.
*/

--- End Message ---
--- Begin Message ---
\+ does not work too, php treat command line arguments as a POST/GET , 
so I should urlencode/urldecode, I would like to know if there is a 
alway to turn this behavior off.

Thanks any way.
Renato

Richard Lynch wrote:

>> Any one know why the "+" (plus sign) is not passed as argument to 
>>$argv  when calling a php script from linux shell ?
>>
>>php test.php 123 xxx+yyyy
>>    
>>
>
>Best guess is + is a special character in the shell, so you need:
>
>php test.php 123 "xxx+yyyy"
>
>
>Or maybe even so far as:
>
>php test.php 123 "xxx\+yyyy"
>
>You'd have to read "man sh" to be 100% sure why + is special.
>
>  
>

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

i wrote a script which will be executed by HREF's. If a command is going to be 
executed by a click on a link the page reloads itself and jumps
in the part of the script, which should be executed.

Normaly I wrote some like this for doing this:

echo '<a href="'.$PHP_SELF.'?action=delete&id='.$arrResult['id'].'" class="text01">';

but now in a very special case i forgot to write $PHP_SELF like this

<a href="?action=delete&id='.$arrResult['id'].'" class="text01">

without knowing that I have forgotten to write this $PHP_SELF thing I clicked on the 
Link and i did execute the Script, like i wanted it to.

Is it normal that it works so fine? Can I use this everytime I link on the same page 
for script execusion?

Can I send Forms via an PHP Function like the submit() statement in Javascript?

Have a nice day, and please answer.

Sascha Braun
--- End Message ---
--- Begin Message ---
How can I use php to get the newest entry from  mysql database? Ie, if I
make a timestamp and then I want to retrieve the last timestamp I made
how do I go about doing it? Any php or mysql documentation?

- Victor > www.argilent.com


______________________________________________________________________ 
Post your ad for free now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
Hello,

I am a PHP rookie.

I would like to knoe as to how can i get the url of
the page I last visited on my present URL
eg. Suppose I visited http://www.eliteral.com ...

On Clicking or going to any other link on the pages , 
is it possible to get a url something as 
http://www.eliteral.com/somepage.php?visited=http://www.eliteral.com

(newpage ? old visited page)

or can i get some mechanism where the last url was
visited and always follows the URL.

I would be happy to know how to do the same

Thanks a zillion in advance for the same

=====
Best Regards,
Monil Chheda(INDIA)
http://domains.eliteral.com
===========================
===========================

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
--- End Message ---
--- Begin Message ---
i'm setting up a messages option on my site, i was looking in the
documentation and read that if headers are not included in an e-mail, the
message is sent to the junk folder, i don't use hotmail (so i would not
know), however i am adding headers: using

// The headers
$myHeaders = "From: \"".Autoresponse."\" <".$myAddress.">\r\n";
$myHeaders .= "To: \"".$myName."\" <".$myAddress.">\r\n";
$myHeaders .= "Reply-To: \"".$myName."\" <".$myAddress.">\r\n";
$myHeaders .= "MIME-Version: 1.0\r\n";
$myHeaders .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$myHeaders .= "X-Priority: 1\r\n";
$myHeaders .= "X-MSMail-Priority: High\r\n";
$myHeaders .= "X-Mailer: Just My Server";

// send the e-mail
mail($myAddress, $mySubject, $myMessage, $myHeaders);

##############################
when testing the file i get the response e-mail, however at the top of the
e-mail i get the following:


Content-Type: text/html; charset=iso-8859-1 X-Priority: 1 X-MSMail-Priority:
High X-Mailer: Just My Server

this must mean that i have written the headers wrong, can someone point me
in the right direction

thanks

| Mike |


--- End Message ---
--- Begin Message ---
Is there a way to determine what a user clicked from a page and pull info from 
that page to the new page from an array?

Example on one page:
echo "<a href='test.php?picName=$lines[$i]'><img 
src='Bid2002/$lines[$i]'></a>&nbsp;";
?>

on the test.php page how do i determine which picture the user clicked on?

Jeff
UWG Student
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
for($i = 0; $i < sizeof($check); $i++) { # start repating query
# turn pictures in order delete capability off
mysql_query("UPDATE kodak_user_pictures 
SET order=1 
WHERE ID='$check[$i]'") # turn off pictures
or die ('Unable to turn bit off '.mysql_error());
} # end repeat

You have an error in your SQL syntax near 'order=1 WHERE ID='2'' at line
2

- Victor > www.argilent.com


______________________________________________________________________ 
Post your ad for free now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
 
> You have an error in your SQL syntax near 'order=1 WHERE ID='2'' at line
> 2

ORDER is a reserved word in MySQL.

Change the query and escape order aswell

'order'='1' WHERE ID='2'

Or, rename the order column to something else.


--- End Message ---
--- Begin Message ---
Yep, figured it just now, thanks anyway, ahhh.. You'd thing they put
reserved names right besides the damn mysql command in the manual. Alas
it shall not be so.

- Victor > www.argilent.com

-----Original Message-----
From: Chris Knipe [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, August 31, 2002 1:30 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] why do i get this error please tell me?

 
> You have an error in your SQL syntax near 'order=1 WHERE ID='2'' at
line
> 2

ORDER is a reserved word in MySQL.

Change the query and escape order aswell

'order'='1' WHERE ID='2'

Or, rename the order column to something else.



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

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
Ahem. Why not check out the MySQL docs for reserved words (they _are_ right
there ...):

http://www.mysql.com/doc/en/Reserved_words.html

PHP Docs are for PHP. MySQL Docs are for MySQL. PHP != MySQL.

-----Original Message-----
From: victor [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 31, 2002 1:35 PM
To: 'Chris Knipe'; [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: [PHP] why do i get this error please tell me?


Yep, figured it just now, thanks anyway, ahhh.. You'd thing they put
reserved names right besides the damn mysql command in the manual. Alas
it shall not be so.

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

Thanks for u help. But i just wanna include a php file in an other. But
the included file must be interpreted before including it.

Thx 
kciop

-----Message d'origine-----
De : Richard Lynch [mailto:[EMAIL PROTECTED]] 
Envoyé : samedi 31 août 2002 02:12
À : you
Cc : [EMAIL PROTECTED]
Objet : Re: include interpreted php file

>pb : include a php file in an other php file
>contraints : the php file must be interpreted before being included
>solution known : fsock then get the html code from the server and
include
>it...
>
>Is there an other solution (easier) to include that file?

Not real sure if you *want* the PHP file interpreted or not, but if not,
try
this:

<?php
  $html = file("http://example.com/whatever.htm";) or die("Could not load
remote HTML");
  echo implode('', $html);
?>

You may (or may not) also want to use http://php.net/htmlentities to
show
the actual HTML source instead of making it a part of your web design
layout
HTML...

-- 
Like Music?  http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
fopen()

Regards,
Chris Knipe
Cell: (072) 434-7582
MegaLAN Corporate Networking Services


/-------
| This email is confidential and may contain legally privileged information.
| If you are not the intended recipient, you must not disclose or use
| the information contained in it. If you have received this email in error,
| please notify us immediately by return email and delete the document.
\-------

----- Original Message -----
From: "you" <[EMAIL PROTECTED]>
To: "'Richard Lynch'" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, August 31, 2002 7:44 PM
Subject: [PHP] RE : include interpreted php file


Hi,

Thanks for u help. But i just wanna include a php file in an other. But
the included file must be interpreted before including it.

Thx
kciop

-----Message d'origine-----
De : Richard Lynch [mailto:[EMAIL PROTECTED]]
Envoyé : samedi 31 août 2002 02:12
À : you
Cc : [EMAIL PROTECTED]
Objet : Re: include interpreted php file

>pb : include a php file in an other php file
>contraints : the php file must be interpreted before being included
>solution known : fsock then get the html code from the server and
include
>it...
>
>Is there an other solution (easier) to include that file?

Not real sure if you *want* the PHP file interpreted or not, but if not,
try
this:

<?php
  $html = file("http://example.com/whatever.htm";) or die("Could not load
remote HTML");
  echo implode('', $html);
?>

You may (or may not) also want to use http://php.net/htmlentities to
show
the actual HTML source instead of making it a part of your web design
layout
HTML...

--
Like Music?  http://l-i-e.com/artists.htm


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



--- End Message ---
--- Begin Message ---
And I feel foolish asking...
What is meant by 'procedural code' ???

-- 
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/


--- End Message ---
--- Begin Message ---
My "dumb" answer :)

  Try Google. Type:

    "procedural code"

  You might want to check,

    "object-oriented"

  as well...

  I'm sure, you'll find helpful explanations...

- E

>
>And I feel foolish asking...
>What is meant by 'procedural code' ???
>
>--
>Gerard Samuel
>http://www.trini0.org:81/
>http://dev.trini0.org:81/
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php




_________________________________________________________________
$B2q0wEPO?$OL5NA!&=<http://auction.msn.co.jp/
--- End Message ---
--- Begin Message ---
Google didn't have much to offer.
But if I should also check 'object-oriented' then I believe it deals
with classes.
I thought it was something else.
Just trying to figure out if phpdoc is for me, which it seems like its
not.... :(

Thanks


@ Edwin wrote:

> My "dumb" answer :)
>
> Try Google. Type:
>
> "procedural code"
>
> You might want to check,
>
> "object-oriented"
>
> as well...
>
> I'm sure, you'll find helpful explanations...
>
> - E
>
>>
>> And I feel foolish asking...
>> What is meant by 'procedural code' ???
>>
>> --
>> Gerard Samuel
>> http://www.trini0.org:81/
>> http://dev.trini0.org:81/
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
>
> _________________________________________________________________
> $B2q0wEPO?$OL5NA!&=<http://auction.msn.co.jp/
>
>
>

-- 
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/
--- End Message ---
--- Begin Message ---
>
>Google didn't have much to offer.

Sorry 'bout that. Actually, if you have an idea of what OO 
("object-oriented") is, I think I can say that "procedural" is just the 
opposite of it.

I tried Google myself and this came out on top:

  "Writing Procedural Code in Non-Procedural SQL"

There's a short explanation but I think it's enough to give you some hint 
about "procedural code".

- E

>But if I should also check 'object-oriented' then I believe it deals
>with classes.
>I thought it was something else.
>Just trying to figure out if phpdoc is for me, which it seems like its
>not.... :(
>
>Thanks

:)


>
>
>@ Edwin wrote:
>
> > My "dumb" answer :)
> >
> > Try Google. Type:
> >
> > "procedural code"
> >
> > You might want to check,
> >
> > "object-oriented"
> >
> > as well...
> >
> > I'm sure, you'll find helpful explanations...
> >
> > - E
> >
> >>
> >> And I feel foolish asking...
> >> What is meant by 'procedural code' ???
> >>
> >> --
> >> Gerard Samuel
> >> http://www.trini0.org:81/
> >> http://dev.trini0.org:81/
> >>
> >>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> >
> >
> > _________________________________________________________________
> > $B2q0wEPO?$OL5NA!&=<http://auction.msn.co.jp/
> >
> >
> >
>
>--
>Gerard Samuel
>http://www.trini0.org:81/
>http://dev.trini0.org:81/




_________________________________________________________________
$B$+$o$$$/$FL{2w$J%$%i%9%HK~:\(B MSN $B%-%c%i%/%?!<(B http://character.msn.co.jp/
--- End Message ---
--- Begin Message ---
I'd like to be able to modify the switch variable inside a case
statement, like this:

switch ($foo) {
  case 'step2':
    do_step2();
    if ($error) $foo='step1'; //repeat step1
  break;

  case 'step1':
    do_step1();
  break;

  case 'a_third_thing':
    do_something_else();
  break;
}

Can you modify the variable ($foo) inside a case statement and
have it evaluated for subsequent 'case's like this? If not, I 
will have to revert to a series of if statements, in which this can
be done:

if ($foo=='step2') {
  do_step2();
  if ($error) $foo='step1';
}
if ($foo=='step1') {
  do_step1();
}
etc.

Switch-case seems cleaner, and I'd prefer to stick with it.

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
--- End Message ---
--- Begin Message ---
Actually, you can--just don't "break;".

Try it.

- E

>
>I'd like to be able to modify the switch variable inside a case
>statement, like this:
>
>switch ($foo) {
>   case 'step2':
>     do_step2();
>     if ($error) $foo='step1'; //repeat step1
>   break;
>
>   case 'step1':
>     do_step1();
>   break;
>
>   case 'a_third_thing':
>     do_something_else();
>   break;
>}
>
>Can you modify the variable ($foo) inside a case statement and
>have it evaluated for subsequent 'case's like this? If not, I
>will have to revert to a series of if statements, in which this can
>be done:
>
>if ($foo=='step2') {
>   do_step2();
>   if ($error) $foo='step1';
>}
>if ($foo=='step1') {
>   do_step1();
>}
>etc.
>
>Switch-case seems cleaner, and I'd prefer to stick with it.
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Finance - Get real-time stock quotes
>http://finance.yahoo.com
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>




_________________________________________________________________
$B$+$o$$$/$FL{2w$J%$%i%9%HK~:\(B MSN $B%-%c%i%/%?!<(B http://character.msn.co.jp/
--- End Message ---
--- Begin Message ---

If you don't break, it continues to execute all the code until
the end of the switch, ignoring any subsequent case
statements.

In my example, eliminating the break after step2 would
cause execution of do_step1(), but also do_something_else(),
which is not desired.

--- "@ Edwin" <[EMAIL PROTECTED]> wrote:
> Actually, you can--just don't "break;".
> 
> Try it.
> 
> - E
> 
> >
> >I'd like to be able to modify the switch variable inside a case
> >statement, like this:
> >
> >switch ($foo) {
> >   case 'step2':
> >     do_step2();
> >     if ($error) $foo='step1'; //repeat step1
> >   break;
> >
> >   case 'step1':
> >     do_step1();
> >   break;
> >
> >   case 'a_third_thing':
> >     do_something_else();
> >   break;
> >}
> >
> >Can you modify the variable ($foo) inside a case statement and
> >have it evaluated for subsequent 'case's like this? If not, I
> >will have to revert to a series of if statements, in which this can
> >be done:
> >
> >if ($foo=='step2') {
> >   do_step2();
> >   if ($error) $foo='step1';
> >}
> >if ($foo=='step1') {
> >   do_step1();
> >}
> >etc.
> >
> >Switch-case seems cleaner, and I'd prefer to stick with it.
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Yahoo! Finance - Get real-time stock quotes
> >http://finance.yahoo.com
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> 
> 
> 
> _________________________________________________________________
> ¤«¤ï¤¤¤¯¤ÆÌû²÷¤Ê¥¤¥é¥¹¥ÈËþºÜ MSN ¥­¥ã¥é¥¯¥¿¡¼ http://character.msn.co.jp/
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
--- End Message ---
--- Begin Message ---
Well, you don't have to take away all the "break;". :)

For example, only here:

>  switch ($foo) {
>    case 'step2':
>    do_step2();
>    if ($error) $foo='step1'; //repeat step1
>    break;

- E

>
>
>If you don't break, it continues to execute all the code until
>the end of the switch, ignoring any subsequent case
>statements.
>
>In my example, eliminating the break after step2 would
>cause execution of do_step1(), but also do_something_else(),
>which is not desired.
>
>--- "@ Edwin" <[EMAIL PROTECTED]> wrote:
> > Actually, you can--just don't "break;".
> >
> > Try it.
> >
> > - E
> >
> > >
> > >I'd like to be able to modify the switch variable inside a case
> > >statement, like this:
> > >
> > >switch ($foo) {
> > >   case 'step2':
> > >     do_step2();
> > >     if ($error) $foo='step1'; //repeat step1
> > >   break;
> > >
> > >   case 'step1':
> > >     do_step1();
> > >   break;
> > >
> > >   case 'a_third_thing':
> > >     do_something_else();
> > >   break;
> > >}
> > >
> > >Can you modify the variable ($foo) inside a case statement and
> > >have it evaluated for subsequent 'case's like this? If not, I
> > >will have to revert to a series of if statements, in which this can
> > >be done:
> > >
> > >if ($foo=='step2') {
> > >   do_step2();
> > >   if ($error) $foo='step1';
> > >}
> > >if ($foo=='step1') {
> > >   do_step1();
> > >}
> > >etc.
> > >
> > >Switch-case seems cleaner, and I'd prefer to stick with it.
> > >
> > >__________________________________________________
> > >Do You Yahoo!?
> > >Yahoo! Finance - Get real-time stock quotes
> > >http://finance.yahoo.com
> > >
> > >--
> > >PHP General Mailing List (http://www.php.net/)
> > >To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> >
> >
> > _________________________________________________________________
> > $B!"%)!"!&!"!"%C!"%K%U{v(B&#58759;$B%O!&!"!&r'%1!&%M%R(B&#63730;$B%3%o(B MSN 
>$B!&%e!&f'r'%C!&%=!#%7(B 
http://character.msn.co.jp/
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Finance - Get real-time stock quotes
>http://finance.yahoo.com
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php




_________________________________________________________________
$B2q0wEPO?$OL5NA!&=<http://auction.msn.co.jp/
--- End Message ---
--- Begin Message ---
Regardless of how many break statements you take away (even
if only 1), case statements appear to be ignored after the
first match is made. I need a way to make the switch statement
continue evaluating case-matches, even after the first case
match is made. Further, it should allow one case segment to
alter the switch variable and have such alteration taken 
into account for subsequent matches.

Here's a more illustrative example of my situation:

switch ($foo) {
  case 'a':
    if (do_a()) echo "a was done";
    else $foo='menu';
  break;

  case 'b':
    if (do_b()) echo "b was done";
    else $foo='menu';
  break;

  case 'menu':
    print_menu();
  break;

  case 'logout':
    do_logout();
  break;
}

that code will not print_menu if do_a fails, since
it exits the switch statement upon seeing a break.

if I remove the break after do_a, it will execute
do_a and do_b -- bad. what we really want is for it
to execute do_a and if do_a returns false, print_menu.

Joe

--- "@ Edwin" <[EMAIL PROTECTED]> wrote:
> Well, you don't have to take away all the "break;". :)
> 
> For example, only here:
> 
> >  switch ($foo) {
> >    case 'step2':
> >    do_step2();
> >    if ($error) $foo='step1'; //repeat step1
> >    break;
> 
> - E
> 
> >
> >
> >If you don't break, it continues to execute all the code until
> >the end of the switch, ignoring any subsequent case
> >statements.
> >
> >In my example, eliminating the break after step2 would
> >cause execution of do_step1(), but also do_something_else(),
> >which is not desired.
> >
> >--- "@ Edwin" <[EMAIL PROTECTED]> wrote:
> > > Actually, you can--just don't "break;".
> > >
> > > Try it.
> > >
> > > - E
> > >
> > > >
> > > >I'd like to be able to modify the switch variable inside a case
> > > >statement, like this:
> > > >
> > > >switch ($foo) {
> > > >   case 'step2':
> > > >     do_step2();
> > > >     if ($error) $foo='step1'; //repeat step1
> > > >   break;
> > > >
> > > >   case 'step1':
> > > >     do_step1();
> > > >   break;
> > > >
> > > >   case 'a_third_thing':
> > > >     do_something_else();
> > > >   break;
> > > >}
> > > >
> > > >Can you modify the variable ($foo) inside a case statement and
> > > >have it evaluated for subsequent 'case's like this? If not, I
> > > >will have to revert to a series of if statements, in which this can
> > > >be done:
> > > >
> > > >if ($foo=='step2') {
> > > >   do_step2();
> > > >   if ($error) $foo='step1';
> > > >}
> > > >if ($foo=='step1') {
> > > >   do_step1();
> > > >}
> > > >etc.
> > > >
> > > >Switch-case seems cleaner, and I'd prefer to stick with it.
> > > >
> > > >__________________________________________________
> > > >Do You Yahoo!?
> > > >Yahoo! Finance - Get real-time stock quotes
> > > >http://finance.yahoo.com
> > > >
> > > >--
> > > >PHP General Mailing List (http://www.php.net/)
> > > >To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > >
> > >
> > >
> > >
> > > _________________________________________________________________
> > > ¡¢¥©¡¢¡¦¡¢¡¢¥Ã¡¢¥Ë¥Õûö&#58759;¥Ï¡¦¡¢¡¦ò§¥±¡¦¥Í¥Ò&#63730;¥³¥ï MSN 
>¡¦¥å¡¦æ§ò§¥Ã¡¦¥½¡£¥· 
> http://character.msn.co.jp/
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Yahoo! Finance - Get real-time stock quotes
> >http://finance.yahoo.com
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
> 
> _________________________________________________________________
> ²ñ°÷ÅÐÏ¿¤Ï̵ÎÁ¡¦½¼¼Â¤·¤¿½ÐÉÊ¥¢¥¤¥Æ¥à¤Ê¤é MSN ¥ª¡¼¥¯¥·¥ç¥ó 
> http://auction.msn.co.jp/
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
--- End Message ---
--- Begin Message ---
It seems like you can do something like this:

switch ($foo) {
   case 'a':
     if (do_a()) echo "a was done";
     else print_menu(); // changes here
   break;

   case 'b':
     if (do_b()) echo "b was done";
     else print_menu(); // changes here
   break;

   case 'menu':
     print_menu();
   break;

   case 'logout':
     do_logout();
   break;
}

Or, if for some reason you can't do that (or you don't want to)...

Here's another way: (I'm not sure if this will work.)

switch ($foo) {
   case 'a':
     if (do_a()) echo "a was done";
     else $foo='menu';
   
   case 'menu':
     print_menu();
   break;

   case 'b':
     if (do_b()) echo "b was done";
     else $foo='menu';

   case 'menu':
     print_menu();
   break;

   case 'logout':
     do_logout();
   break;
}

It doesn't look "clean" but it might just work...

BTW, I know this is just an example, but I expect you're doing your 

  if(){
  } else {
  }

properly in your real code...

- E

>
>Regardless of how many break statements you take away (even
>if only 1), case statements appear to be ignored after the
>first match is made. I need a way to make the switch statement
>continue evaluating case-matches, even after the first case
>match is made. Further, it should allow one case segment to
>alter the switch variable and have such alteration taken
>into account for subsequent matches.
>
>Here's a more illustrative example of my situation:
>
>switch ($foo) {
>   case 'a':
>     if (do_a()) echo "a was done";
>     else $foo='menu';
>   break;
>
>   case 'b':
>     if (do_b()) echo "b was done";
>     else $foo='menu';
>   break;
>
>   case 'menu':
>     print_menu();
>   break;
>
>   case 'logout':
>     do_logout();
>   break;
>}
>
>that code will not print_menu if do_a fails, since
>it exits the switch statement upon seeing a break.
>
>if I remove the break after do_a, it will execute
>do_a and do_b -- bad. what we really want is for it
>to execute do_a and if do_a returns false, print_menu.
>
>Joe
>
>--- "@ Edwin" <[EMAIL PROTECTED]> wrote:
> > Well, you don't have to take away all the "break;". :)
> >
> > For example, only here:
> >
> > >  switch ($foo) {
> > >    case 'step2':
> > >    do_step2();
> > >    if ($error) $foo='step1'; //repeat step1
> > >    break;
> >
> > - E
> >
> > >
> > >
> > >If you don't break, it continues to execute all the code until
> > >the end of the switch, ignoring any subsequent case
> > >statements.
> > >
> > >In my example, eliminating the break after step2 would
> > >cause execution of do_step1(), but also do_something_else(),
> > >which is not desired.
> > >
> > >--- "@ Edwin" <[EMAIL PROTECTED]> wrote:
> > > > Actually, you can--just don't "break;".
> > > >
> > > > Try it.
> > > >
> > > > - E
> > > >
> > > > >
> > > > >I'd like to be able to modify the switch variable inside a case
> > > > >statement, like this:
> > > > >
> > > > >switch ($foo) {
> > > > >   case 'step2':
> > > > >     do_step2();
> > > > >     if ($error) $foo='step1'; //repeat step1
> > > > >   break;
> > > > >
> > > > >   case 'step1':
> > > > >     do_step1();
> > > > >   break;
> > > > >
> > > > >   case 'a_third_thing':
> > > > >     do_something_else();
> > > > >   break;
> > > > >}
> > > > >
> > > > >Can you modify the variable ($foo) inside a case statement and
> > > > >have it evaluated for subsequent 'case's like this? If not, I
> > > > >will have to revert to a series of if statements, in which this 
can
> > > > >be done:
> > > > >
> > > > >if ($foo=='step2') {
> > > > >   do_step2();
> > > > >   if ($error) $foo='step1';
> > > > >}
> > > > >if ($foo=='step1') {
> > > > >   do_step1();
> > > > >}
> > > > >etc.
> > > > >
> > > > >Switch-case seems cleaner, and I'd prefer to stick with it.
> > > > >
> > > > >__________________________________________________
> > > > >Do You Yahoo!?
> > > > >Yahoo! Finance - Get real-time stock quotes
> > > > >http://finance.yahoo.com
> > > > >
> > > > >--
> > > > >PHP General Mailing List (http://www.php.net/)
> > > > >To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > > _________________________________________________________________
> > > > 
>$B!#!V!&%%!#!V!#%r!#!V!#!V!&%F!#!V!&%R!&%f|\(B&#58759;$B!&%^!#%r!#!V!#%r(B&#57822;$B!&%"!#%r!&%X!&%a(B&#63730;$B!&%&!&!&(B
MSN $B!#%r!&j#%rl)(B&#57822;$B!&%F!#%r!&%9!#!W!&%-(B
> > http://character.msn.co.jp/
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > >
> > >
> > >__________________________________________________
> > >Do You Yahoo!?
> > >Yahoo! Finance - Get real-time stock quotes
> > >http://finance.yahoo.com
> > >
> > >--
> > >PHP General Mailing List (http://www.php.net/)
> > >To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> >
> > _________________________________________________________________
> > 
>$B%$(B&#57643;&#58792;$B%_%^%=!"%^%U%*%[%A!#%r%9%7%7%D!"%-!"%=%9%_%N%O!&!V!&!"!&%K!&`&%O!"!&(BMSN
> $B!&%'!#%7!&%C!&%-!&n'!&(B> 
> http://auction.msn.co.jp/
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Finance - Get real-time stock quotes
>http://finance.yahoo.com




_________________________________________________________________
$B%O%$%;%s%9$J>&IJ$r5$7Z$K9XF~(B MSN $B%7%g%C%T%s%0(B http://shopping.msn.co.jp/
--- End Message ---
--- Begin Message ---
This is my form:
 <FORM NAME="answerform" METHOD=POST>
  Your name:<BR><INPUT TYPE=TEXT NAME="name" SIZE=20>
  Group:<BR><INPUT TYPE=TEXT NAME="group" SIZE=8>&nbsp;&nbsp;
  <INPUT TYPE=BUTTON VALUE=" OK!" onClick="Javascript:validate(this);">
 </FORM>

and the function validate:
function validate() {
  var ok=true;
 if (document.answerform.name.value=='') {
  ok=false;
  alert('Please write Your name')
  document.answerform.name.focus();
  document.answerform.name.select();
 }
 if (document.answerform.group.value=='') {
  ok=false;
  alert('What group?')
  document.answerform.group.focus();
  document.answerform.group.select();
 }
 if (ok==true) {
  location.href='groups/collect_answer.php?name=<?php echo $name;
?>&group=<?php echo $group; ?>';
  return true;
 } else { return false; }
}

and this doesn't work and I can't see why not


--- End Message ---
--- Begin Message ---
On Sunday 01 September 2002 02:52, Øystein Håland wrote:
> This is my form:
>  <FORM NAME="answerform" METHOD=POST>
>   Your name:<BR><INPUT TYPE=TEXT NAME="name" SIZE=20>
>   Group:<BR><INPUT TYPE=TEXT NAME="group" SIZE=8>&nbsp;&nbsp;
>   <INPUT TYPE=BUTTON VALUE=" OK!" onClick="Javascript:validate(this);">
>  </FORM>
>
> and the function validate:
> function validate() {
>   var ok=true;
>  if (document.answerform.name.value=='') {
>   ok=false;
>   alert('Please write Your name')
>   document.answerform.name.focus();
>   document.answerform.name.select();
>  }
>  if (document.answerform.group.value=='') {
>   ok=false;
>   alert('What group?')
>   document.answerform.group.focus();
>   document.answerform.group.select();
>  }
>  if (ok==true) {
>   location.href='groups/collect_answer.php?name=<?php echo $name;
> ?>&group=<?php echo $group; ?>';
>   return true;
>  } else { return false; }
> }
>
> and this doesn't work and I can't see why not

Looks like a javascript question to me.


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

/*
The opulence of the front office door varies inversely with the fundamental
solvency of the firm.
*/

--- End Message ---
--- Begin Message ---
I meant besides the UPDATE or SELECT or any filed that those words might
interfere with...

- Victor > www.argilent.com

-----Original Message-----
From: Mark Charette [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, August 31, 2002 2:18 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DB] RE: [PHP] why do i get this error please tell me?

Ahem. Why not check out the MySQL docs for reserved words (they _are_
right
there ...):

http://www.mysql.com/doc/en/Reserved_words.html

PHP Docs are for PHP. MySQL Docs are for MySQL. PHP != MySQL.

-----Original Message-----
From: victor [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 31, 2002 1:35 PM
To: 'Chris Knipe'; [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: [PHP] why do i get this error please tell me?


Yep, figured it just now, thanks anyway, ahhh.. You'd thing they put
reserved names right besides the damn mysql command in the manual. Alas
it shall not be so.


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

______________________________________________________________________ 
Post your ad for free now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
Then check the MySQL manual using the URL I posted!

PHP doesn't care about the hundred or so reserved MySQL words. MySQL does.
Perhaps you're confusing the two. Please check what I said:

PHP != MySQL

The documentation for each is separate. PHP has "convenience" functions for
talking to a MySQL database. It does not parse or check your SQL statements
for correctness - it just passes them along and lets the MySQL library do
its work. PHP does this for a great number of products: cURL, GD functions,
various ODBC interfaces, etc. It's up to you to read the support docs for
those products to use them fully. The docs for PHP don't need to be
cluttered with deep and detailed explanations of every supported interface,
not would I expect them to.

-----Original Message-----
From: victor [mailto:[EMAIL PROTECTED]]

I meant besides the UPDATE or SELECT or any filed that those words might
interfere with...

- Victor > www.argilent.com

-----Original Message-----
From: Mark Charette [mailto:[EMAIL PROTECTED]]

hem. Why not check out the MySQL docs for reserved words (they _are_
right
there ...):

http://www.mysql.com/doc/en/Reserved_words.html

PHP Docs are for PHP. MySQL Docs are for MySQL. PHP != MySQL.

-----Original Message-----
From: victor [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 31, 2002 1:35 PM
To: 'Chris Knipe'; [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: [PHP] why do i get this error please tell me?


Yep, figured it just now, thanks anyway, ahhh.. You'd thing they put
reserved names right besides the damn mysql command in the manual. Alas
it shall not be so.

--- End Message ---

Reply via email to