php-windows Digest 21 Jan 2003 07:24:04 -0000 Issue 1547
Topics (messages 17996 through 18009):
Re: Moving an uploaded file keeps failing
17996 by: Matt Babineau
17997 by: Matt Babineau
17998 by: Chris Kranz
17999 by: Matt Babineau
18001 by: The Head Sage
Unable to load dynamic library php_oci8.dll on Windows XP SPK1
18000 by: Andre Matos
18004 by: Edin Kadribasic
CH 5 pg 150
18002 by: Wade
Re: SQL-query
18003 by: Cam Dunstan
Re: ssl:// with fsockopen () on Windows XP
18005 by: Edin Kadribasic
how to read lob,clob and long field in oracle
18006 by: Ha Duy Thien
Re: Non-thread safe Win32 builds
18007 by: Edin Kadribasic
Re: arrays and nested arrays and loops and databases...
18008 by: Dash McElroy
Re: Odd for loop behavior.
18009 by: Uttam
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 ---
Well, I made these changes, and it still is giving me errors for some
reason. Also, the drive IIS is on is FAT32, so I don't think it can be a
security issue...since there is none ;-)
db.txt
d:\Temp\php4EE.tmp
0
PHP Warning: move_uploaded_file(d:\) [function.move-uploaded-file]:
failed to create stream: No such file or directory in
D:\wwwroot\kingmanchamber\secure-area\administration\upload\file_upload.
php on line 24 PHP Warning: move_uploaded_file()
[function.move-uploaded-file]: Unable to move 'd:\Temp\php4EE.tmp' to
'd:\' in
D:\wwwroot\kingmanchamber\secure-area\administration\upload\file_upload.
php on line 24
--> -----Original Message-----
--> From: Stephen Edmonds [mailto:[EMAIL PROTECTED]]
--> Sent: Monday, January 20, 2003 12:26 PM
--> To: Matt Babineau
--> Cc: PHP Windows Helplist
--> Subject: Re: [PHP-WIN] Moving an uploaded file keeps failing
-->
-->
--> Currently from what I can see there are a few problems:
-->
--> The Form:
-->
--> <form enctype="multipart/form-data" action="<? echo
--> $_SERVER['SCRIPT_NAME'];?>" method="post"> Send this file:
--> <input name="userfile" type="file"> <input type="submit"
--> value="Send File"> </form>
-->
--> action is not essential if the form is sending to itself
--> (okay, maybe thats just me being lazy :p). However, you
--> missed out a vital field
-->
--> <input type="hidden" name="MAX_FILE_SIZE" value="Maximum
--> file size in bytes">
-->
--> This needs to appear just before the file upload input. It
--> tells PHP what the biggest size of file to accept is.
--> Without it, no file will be uploaded! Remember to change
--> the value to an actual number
-->
--> Upload Script
-->
--> You should be using $_FILES array when uploading a file.
-->
--> $_FILES["userfile"]["name"] - Orginal name of the file
--> uploaded, given by the user
-->
--> $_FILES["userfile"]["error"] - Variable that contains an
--> error report. If something goes wrong, a number will get
--> put in here. 0 - Upload was okay 1 - The uploaded file
--> exceeds the upload_max_filesize directive in php.ini. 2 -
--> The uploaded file exceeds the MAX_FILE_SIZE directive that
--> was specified in the html form. 3 - The uploaded file was
--> only partially uploaded 4 - No file was uploaded
-->
--> $_FILES["userfile"]["tmp_name"] - This contains the
--> location and name of the file which was uploaded
-->
--> $_FILES['userfile']['type'] - The type of file that was
--> uploaded (See link below for more info!)
-->
--> $_FILES['userfile']['size'] - The size of the newly uploaded file
-->
--> For more infomation visit
--> http://www.php.net/manual/en/features.file-upload.php
-->
--> It is important to check the error number before you try to
--> move the file. Also, rather than checking for 'post', check
--> for $_FILES['userfile']['name']
-->
--> If you still have problems, email the list again with your
--> error message/code. Good luck
-->
--> Stephen
-->
-->
--> ----- Original Message -----
--> From: "Matt Babineau" <[EMAIL PROTECTED]>
--> To: <[EMAIL PROTECTED]>
--> Sent: Monday, January 20, 2003 4:55 PM
--> Subject: [PHP-WIN] Moving an uploaded file keeps failing
-->
-->
--> > Here is the error:
--> >
--> > PHP Warning: move_uploaded_file(/) [function.move-uploaded-file
--> > <http://www.php.net/function.move-uploaded-file> ]:
--> failed to create
--> > stream: No such file or directory in
--> >
--> D:\wwwroot\kingmanchamber\secure-area\administration\upload\
--> file_uploa
--> > d.
--> > php on line 22 PHP Warning: move_uploaded_file()
--> > [function.move-uploaded-file
--> > <http://www.php.net/function.move-uploaded-file> ]: Unable to move
--> > 'd:\Temp\php443.tmp' to '/' in
--> >
--> D:\wwwroot\kingmanchamber\secure-area\administration\upload\
--> file_upload.
--> > php on line 22
--> >
--> > Here is the code:
--> >
--> > <form enctype="multipart/form-data" action="<? echo
--> > $_SERVER['SCRIPT_NAME'];?>" method="post"> Send this file: <input
--> > name="userfile" type="file"> <input type="submit"
--> value="Send File">
--> > </form>
--> >
--> > <?
--> > if ($_SERVER['REQUEST_METHOD'] == "POST") {
--> > echo $_FILES['userfile']['name'] . "<BR>";
--> > echo $_FILES['userfile']['tmp_name'] . "<BR>";
--> >
--> > move_uploaded_file($_FILES['userfile']['tmp_name'], "/");
--> >
--> > }
--> > ?>
--> >
--> > I am running this on a winxp pro machine iis 5.1, php
--> 4.3.0 running as
--> > a CGI.
--> >
--> > This code is pretty much from the PHP.net site, so I am a
--> tad baffled
--> > on this one.
--> >
--> > -Matt
--> >
-->
-->
-->
--> --
--> PHP Windows Mailing List (http://www.php.net/)
--> To unsubscribe, visit: http://www.php.net/unsub.php
-->
-->
--- End Message ---
--- Begin Message ---
UPDATE:
Ok, I got the page to stop giving me errors by supplying the source file
path like this:
move_uploaded_file("d:\\temp\\" . $_FILES['userfile']['tmp_name'],
"d:\\");
But that still doesn't move the uploaded file to the d:\ either.
Any ideas?
--> -----Original Message-----
--> From: Matt Babineau [mailto:[EMAIL PROTECTED]]
--> Sent: Monday, January 20, 2003 3:19 PM
--> To: 'Stephen Edmonds'
--> Cc: 'PHP Windows Helplist'
--> Subject: RE: [PHP-WIN] Moving an uploaded file keeps failing
-->
-->
--> Well, I made these changes, and it still is giving me
--> errors for some reason. Also, the drive IIS is on is FAT32,
--> so I don't think it can be a security issue...since there
--> is none ;-)
-->
--> db.txt
--> d:\Temp\php4EE.tmp
--> 0
-->
--> PHP Warning: move_uploaded_file(d:\)
--> [function.move-uploaded-file]: failed to create stream: No
--> such file or directory in
--> D:\wwwroot\kingmanchamber\secure-area\administration\upload\
--> file_upload.
--> php on line 24 PHP Warning: move_uploaded_file()
--> [function.move-uploaded-file]: Unable to move
--> 'd:\Temp\php4EE.tmp' to 'd:\' in
--> D:\wwwroot\kingmanchamber\secure-area\administration\upload\
--> file_upload.
--> php on line 24
-->
--> --> -----Original Message-----
--> --> From: Stephen Edmonds [mailto:[EMAIL PROTECTED]]
--> --> Sent: Monday, January 20, 2003 12:26 PM
--> --> To: Matt Babineau
--> --> Cc: PHP Windows Helplist
--> --> Subject: Re: [PHP-WIN] Moving an uploaded file keeps failing
--> -->
--> -->
--> --> Currently from what I can see there are a few problems:
--> -->
--> --> The Form:
--> -->
--> --> <form enctype="multipart/form-data" action="<? echo
--> --> $_SERVER['SCRIPT_NAME'];?>" method="post"> Send this file:
--> --> <input name="userfile" type="file"> <input type="submit"
--> --> value="Send File"> </form>
--> -->
--> --> action is not essential if the form is sending to itself
--> --> (okay, maybe thats just me being lazy :p). However, you
--> --> missed out a vital field
--> -->
--> --> <input type="hidden" name="MAX_FILE_SIZE" value="Maximum
--> --> file size in bytes">
--> -->
--> --> This needs to appear just before the file upload input. It
--> --> tells PHP what the biggest size of file to accept is.
--> --> Without it, no file will be uploaded! Remember to change
--> --> the value to an actual number
--> -->
--> --> Upload Script
--> -->
--> --> You should be using $_FILES array when uploading a file.
--> -->
--> --> $_FILES["userfile"]["name"] - Orginal name of the file
--> --> uploaded, given by the user
--> -->
--> --> $_FILES["userfile"]["error"] - Variable that contains an
--> --> error report. If something goes wrong, a number will get
--> --> put in here. 0 - Upload was okay 1 - The uploaded file
--> --> exceeds the upload_max_filesize directive in php.ini. 2 -
--> --> The uploaded file exceeds the MAX_FILE_SIZE directive that
--> --> was specified in the html form. 3 - The uploaded file was
--> --> only partially uploaded 4 - No file was uploaded
--> -->
--> --> $_FILES["userfile"]["tmp_name"] - This contains the
--> --> location and name of the file which was uploaded
--> -->
--> --> $_FILES['userfile']['type'] - The type of file that was
--> --> uploaded (See link below for more info!)
--> -->
--> --> $_FILES['userfile']['size'] - The size of the newly
--> uploaded file
--> -->
--> --> For more infomation visit
--> --> http://www.php.net/manual/en/features.file-upload.php
--> -->
--> --> It is important to check the error number before you try to
--> --> move the file. Also, rather than checking for 'post', check
--> --> for $_FILES['userfile']['name']
--> -->
--> --> If you still have problems, email the list again with your
--> --> error message/code. Good luck
--> -->
--> --> Stephen
--> -->
--> -->
--> --> ----- Original Message -----
--> --> From: "Matt Babineau" <[EMAIL PROTECTED]>
--> --> To: <[EMAIL PROTECTED]>
--> --> Sent: Monday, January 20, 2003 4:55 PM
--> --> Subject: [PHP-WIN] Moving an uploaded file keeps failing
--> -->
--> -->
--> --> > Here is the error:
--> --> >
--> --> > PHP Warning: move_uploaded_file(/)
--> [function.move-uploaded-file
--> --> > <http://www.php.net/function.move-uploaded-file> ]:
--> --> failed to create
--> --> > stream: No such file or directory in
--> --> >
--> --> D:\wwwroot\kingmanchamber\secure-area\administration\upload\
--> --> file_uploa
--> --> > d.
--> --> > php on line 22 PHP Warning: move_uploaded_file()
--> --> > [function.move-uploaded-file
--> --> > <http://www.php.net/function.move-uploaded-file> ]:
--> Unable to move
--> --> > 'd:\Temp\php443.tmp' to '/' in
--> --> >
--> --> D:\wwwroot\kingmanchamber\secure-area\administration\upload\
--> --> file_upload.
--> --> > php on line 22
--> --> >
--> --> > Here is the code:
--> --> >
--> --> > <form enctype="multipart/form-data" action="<? echo
--> --> > $_SERVER['SCRIPT_NAME'];?>" method="post"> Send this
--> file: <input
--> --> > name="userfile" type="file"> <input type="submit"
--> --> value="Send File">
--> --> > </form>
--> --> >
--> --> > <?
--> --> > if ($_SERVER['REQUEST_METHOD'] == "POST") {
--> --> > echo $_FILES['userfile']['name'] . "<BR>";
--> --> > echo $_FILES['userfile']['tmp_name'] . "<BR>";
--> --> >
--> --> > move_uploaded_file($_FILES['userfile']['tmp_name'], "/");
--> --> >
--> --> > }
--> --> > ?>
--> --> >
--> --> > I am running this on a winxp pro machine iis 5.1, php
--> --> 4.3.0 running as
--> --> > a CGI.
--> --> >
--> --> > This code is pretty much from the PHP.net site, so I am a
--> --> tad baffled
--> --> > on this one.
--> --> >
--> --> > -Matt
--> --> >
--> -->
--> -->
--> -->
--> --> --
--> --> PHP Windows Mailing List (http://www.php.net/)
--> --> To unsubscribe, visit: http://www.php.net/unsub.php
--> -->
--> -->
-->
-->
--> --
--> PHP Windows Mailing List (http://www.php.net/)
--> To unsubscribe, visit: http://www.php.net/unsub.php
-->
-->
--- End Message ---
--- Begin Message ---
move_uploaded_file("d:\\temp\\" . $_FILES['userfile']['tmp_name'],
"d:\\blah.txt");
see if that creates a file called blah.txt
if it does, then you gonna have to name your file, rather than just tell
it d:\
chris kranz
fatcuban.com
-----Original Message-----
From: Matt Babineau [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 20, 2003 8:50 PM
To: 'PHP Windows Helplist'
Subject: RE: [PHP-WIN] Moving an uploaded file keeps failing
UPDATE:
Ok, I got the page to stop giving me errors by supplying the source file
path like this:
move_uploaded_file("d:\\temp\\" . $_FILES['userfile']['tmp_name'],
"d:\\");
But that still doesn't move the uploaded file to the d:\ either.
Any ideas?
--- End Message ---
--- Begin Message ---
I tried that, and it did not create d:\blah.txt.
Alternatively, I also tried
"d:\\" . $_FILES['userfile']['name']
With no luck either.
--> -----Original Message-----
--> From: Chris Kranz [mailto:[EMAIL PROTECTED]]
--> Sent: Monday, January 20, 2003 3:59 PM
--> To: [EMAIL PROTECTED]
--> Subject: RE: [PHP-WIN] Moving an uploaded file keeps failing
-->
-->
--> move_uploaded_file("d:\\temp\\" .
--> $_FILES['userfile']['tmp_name'], "d:\\blah.txt");
-->
--> see if that creates a file called blah.txt
-->
--> if it does, then you gonna have to name your file, rather
--> than just tell it d:\
-->
--> chris kranz
--> fatcuban.com
-->
-->
--> -----Original Message-----
--> From: Matt Babineau [mailto:[EMAIL PROTECTED]]
--> Sent: Monday, January 20, 2003 8:50 PM
--> To: 'PHP Windows Helplist'
--> Subject: RE: [PHP-WIN] Moving an uploaded file keeps failing
-->
--> UPDATE:
-->
--> Ok, I got the page to stop giving me errors by supplying
--> the source file path like this:
-->
--> move_uploaded_file("d:\\temp\\" .
--> $_FILES['userfile']['tmp_name'], "d:\\");
-->
--> But that still doesn't move the uploaded file to the d:\ either.
-->
--> Any ideas?
-->
-->
-->
--> --
--> PHP Windows Mailing List (http://www.php.net/)
--> To unsubscribe, visit: http://www.php.net/unsub.php
-->
-->
--- End Message ---
--- Begin Message ---
I encountered the same problem recently while working on my sites Fan Art section.
There's a small error in the PHP manual which solves your problem.
With the move_uploaded_file(); function, in the end string you need to put the
actual file name as well..
e.g:
$filename = $_FILES['userfile']['name'];
$path = $_SERVER["DOCUMENT_ROOT"]."/fanart/art/".$uid2."/".$filename;
$tmpname = $_FILES['userfile']['tmp_name'];
move_uploaded_file($tmpname, $path);
So in your case it would be:
move_uploaded_file($_FILES['userfile']['tmp_name'], "/".$_FILES['userfile']['name']);
I believe this should solve the problem, other wise i just pointed out something to
fix
^^;
- Daniel "TheHeadSage" Spain
Founder of Voidsoft.
Head of IRC Relations for Manga-Sketchbook.Org
On 20 Jan 2003 at 11:55, Matt Babineau wrote:
> Here is the error:
>
> PHP Warning: move_uploaded_file(/) [function.move-uploaded-file
> <http://www.php.net/function.move-uploaded-file> ]: failed to create
> stream: No such file or directory in
> D:\wwwroot\kingmanchamber\secure-area\administration\upload\file_upload.
> php on line 22 PHP Warning: move_uploaded_file()
> [function.move-uploaded-file
> <http://www.php.net/function.move-uploaded-file> ]: Unable to move
> 'd:\Temp\php443.tmp' to '/' in
> D:\wwwroot\kingmanchamber\secure-area\administration\upload\file_upload.
> php on line 22
>
> Here is the code:
>
> <form enctype="multipart/form-data" action="<? echo
> $_SERVER['SCRIPT_NAME'];?>" method="post">
> Send this file: <input name="userfile" type="file">
> <input type="submit" value="Send File">
> </form>
>
> <?
> if ($_SERVER['REQUEST_METHOD'] == "POST") {
> echo $_FILES['userfile']['name'] . "<BR>";
> echo $_FILES['userfile']['tmp_name'] . "<BR>";
>
> move_uploaded_file($_FILES['userfile']['tmp_name'], "/");
>
> }
> ?>
>
> I am running this on a winxp pro machine iis 5.1, php 4.3.0 running as a
> CGI.
>
> This code is pretty much from the PHP.net site, so I am a tad baffled on
> this one.
>
> -Matt
>
--- End Message ---
--- Begin Message ---
Hi,
I am receiving the mensage "Unable to load dynamic library
"C:\ApacheGroup\PHP\extensions\php_oci8.dll"
I am using Windows XP SPK1 with Apache2.0.43 with PHP4-4.2.3.
I tried to use with Oracle but when I uncomment the line:
extension=php_oci8.dll
I started to receive this mensage:
Unable to load dynamic library "C:\ApacheGroup\PHP\extensions\php_oci8.dll
Regards,
Andre Matos
--- End Message ---
--- Begin Message ---
You need to have Oracle client on the machine where PHP is installed.
Edin
"Andre Matos" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> I am receiving the mensage "Unable to load dynamic library
> "C:\ApacheGroup\PHP\extensions\php_oci8.dll"
>
> I am using Windows XP SPK1 with Apache2.0.43 with PHP4-4.2.3.
>
> I tried to use with Oracle but when I uncomment the line:
>
> extension=php_oci8.dll
>
> I started to receive this mensage:
>
> Unable to load dynamic library "C:\ApacheGroup\PHP\extensions\php_oci8.dll
>
>
> Regards,
> Andre Matos
>
>
--- End Message ---
--- Begin Message ---
01202003 1702 CST
Ive been going back over all these exercises trying to do them with the
Global Variables off. Its much more difficult.
Below is the exercise on Switch and Case. Im uncertain about the
$_X["Y"] in each statement. This code currently produces nothing when run.
<?php
$Duration = 0;
switch ($_POST["Loan"])
{
case 1000:
$Interest = 5;
break;
case 5000:
$Interest = 6.5;
break;
case 10000:
$Interest 8;
break;
default:
echo "You didnt enter a loan package!";
break;
}
while ($_POST["Loan"] > 0)
{
$Duration = $Duration + 1;
$Monthly = $_POST["Month"] - ($_POST["Loan"] * $Interest / 100);
if ($Monthly <=0)
{
echo "You need larger repayments to pay off your loan!";
exit;
}
$_POST["Loan"] = $_POST["Loan"] - $Monthly;
}
echo "This would take you $Duration months to pay this off at the
interest rate of $Interest percent.";
?>
Wade
--- End Message ---
--- Begin Message ---
Wow! thanks fellas I really enjoyed that! except when Sean fired me! Hey
Sean can I get my Mars Bars and stuff out of my drawer or is it straight out
onto the street?
Nothing like the subject of auto increment to cause a few hot flushes hey
girls!! Proof indeed you have all had your moments with them. Strictly
though we are off-topic - but we have all missed some important points -
anyone know of a good spot to continue this discussion?
----- Original Message -----
From: "Sean Malloy" <[EMAIL PROTECTED]>
To: "Bobo Wieland" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, January 18, 2003 11:29 AM
Subject: RE: [PHP-WIN] SQL-query
> Why the hell would you want to do that?
>
> It looks ugly?
>
> I'll tell you what, when you have 80000 records in the database, and
#34,501
> is missing, I wonder if you'll notice, or want to write code to fill, the
> "hole"
>
> if you really want to fix the hole (as much as I think you are seriously
> wasting your time, and a sneaking suspicion as to why you would actually
> want to do it)..
>
> You would have to pull the data down into an arrya, loop through the array
> from start to finish, all the while checking if the current ID equals the
> counter value, as soon as it doesn't, you know you have found an ID you
can
> insert into the DB safely. Ofcourse, if there are records in other tables
> related by that ID, and you forgot to delet those, you'll get some really
> weird results.
>
> Not to mention the extra time your code would be taking to execute.
>
> if I saw someone writing all the code to patch holes in record sequences,
I
> would fire them. But thats just me. I'd rather have my employees working
on
> making things better, not slower for no reason at all other than 'i like
> pretty sequences'
>
>
> However, I'm guessing its because you actually want to create < PREV |
NEXT
> > next buttons, and you can't think of a way to link up the records.
>
> If thats the case, email me back, and I'll send you some example code
which
> should (perhaps), make your life much simpler.
>
--- End Message ---
--- Begin Message ---
If you replace your php4ts.dll with
http://ftp.proventum.net/pub/php/win32/misc/openssl/php-4.3.0-ssl.zip you
problem should be solved.
Edin
"Alexander Stirmlinger" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello,
>
> when I try to open a SSL-connection via ssl:// with fsockopen () on
Windows
> XP and PHP 4.3.0, I get the following error message:
>
> "no SSL support in this build..."
>
> I tried to add "extension=php_openssl.dll" in my php.ini and copied
> libeay32.dll into the SYSTEM32-directory, but that doesn't help.
>
> Is it possible to use SSL-support in the standard windows binary
> distribution or do I have to build PHP from the source by myself?
>
> Thanks in advance,
> alex.
>
--- End Message ---
--- Begin Message ---
Dear PHP gurus,
Do you know the way to read data from LOB, CLOB, or LONG field in Oracle
database
Please tell me how to do it.
Thanks very much
Thien
--- End Message ---
--- Begin Message ---
Its a case of simple misunderstanding. There are no plans to discontinue PHP
support for Windows. Non-thread safe Win32 builds have not been made for
quite some time (if ever for 4.x.x) so the question on php-dev was weather
to remove obsolete source files needed for those builds.
Edin
"Victor Medina" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi guys!
>
> first, my name is Victor Medina I am a php and java developer from
> venezuela , and i am the maintainer of a small project on sourceforge,
> named Ikirux that include Apache 2 and php4 on windows, it is mostly an
> installer.
>
> http://sourceforge.net/projects/ikirux
>
> Enough!
>
> Now straight to the point.
>
> I am concerned about this I read on the Zend.com :
>
>
> "TLK: Non-thread safe Win32 builds
>
> It looks like the above version of PHP has been slipping more and more out
> of sync with the standard Windows version. There may well be the
> possibility of dropping support for a non-thread safe PHP soon. If you are
> building from source under Windows and there is any reason why these
should
> stick around, now would be the time to e-mail the list. "
>
> What does it means for people like us, that actively develop and support
> php on the windows platform? I am currently working on the next release of
> the Ikirux server, and wanted it to support PHP4.3 and PEAR.
>
> What are my options?
>
> Thnaxs in advance, pardon my english
>
> Victor Medina
>
>
>
>
--- End Message ---
--- Begin Message ---
Eric,
If I understand your request, it seems as if you are wondering what would
happen if the array got too large. If you want to do some kind of
processing with the array, instead of loading it into an array, do the
processing in the while loop.
$query = "select email, fullname from tablename where updateannounce = 1";
$result = mysql_query($query);
while ($output = mysql_fetch_array($result)) {
//do whatever you want here, i.e. echo $result['name'] or $result['address']
}
-Dash
Newlan's Truism:
An "acceptable" level of unemployment means that the government
economist to whom it is acceptable still has a job.
On Mon, 20 Jan 2003, Eric wrote:
> Dear sir,
> I'am Eric
> I have the same question about this.
> But what if does will this the final $to[] array will contains all of
> address and name data.
> but the address bar should not be hold if a large number of address
> presents.
> Is that have any suggestions??
> Thanks yours
>
> tarn@hk
>
> ----- Original Message -----
> From: "Dash McElroy" <[EMAIL PROTECTED]>
> To: "H Marc Bower" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Sunday, January 19, 2003 11:33 AM
> Subject: Re: [PHP-WIN] arrays and nested arrays and loops and databases...
>
>
> > If I understand correctly, you want to have an array containing an array
> > with people's email address and name from your db like this:
> >
> > $to[0]['address'] = [EMAIL PROTECTED]
> > $to[0]['name'] = Bob Smith
> > $to[1]['address'] = [EMAIL PROTECTED]
> > $to[1]['name'] = John Jones
> >
> > (the above is obviously not valid PHP...)
> >
> > I would do something like this:
> >
> > $to = array();
> > $query = "select email, fullname from tablename where updateannounce = 1";
> > $result = mysql_query($query);
> > while ($output = mysql_fetch_array($result)) {
> > $to[] = array('address' => $output['address'],
> > 'name' => $output['name']);
> > }
> >
> > assuming, of course, that your database column names are 'address' and
> > 'name'.
> >
> > This should work, but I may have borked something up on the name based
> > arrays.
> >
> > -Dash
> >
> > "The pyramid is opening!"
> > "Which one?"
> > "The one with the ever-widening hole in it!"
> > -- Firesign Theater, "How Can You Be In Two Places At
> > Once When You're Not Anywhere At All"
> >
> > On Sat, 18 Jan 2003, H Marc Bower wrote:
> >
> > > Well... I can usually puzzle myself through these things, but I figured
> > > it's time to ask the list. :) It may be a simple thing that I'm
> missing,
> > > but here's what I have.
> > >
> > > The structure that I'm trying to modify is as follows:
> > >
> > > $to = array(
> > > array(
> > > 'address'=>'[EMAIL PROTECTED]',
> > > 'name'=>'Bob Smith'
> > > ),
> > > array(
> > > 'address'=>'[EMAIL PROTECTED]',
> > > 'name'=>'John Jones'
> > > )
> > > );
> > >
> > > That said, I have a database of names and email addresses which I want
> to
> > > insert into this structure, but in a loop since I don't want to have an
> > > array() section for each one, not knowing how many are going to be in
> the
> > > list at the time this script is run. I want to loop the 'sub' array()
> > > statements so that I can build up the main array(). I use mysql as
> follows:
> > >
> > > $query = "select email, fullname from tablename where updateannounce =
> 1";
> > > $result = mysql_query($query);
> > > while ($output = mysql_fetch_array($result))
> > > {
> > > //This is where I want the loop of arrays to appear, so I can
> > > dynamically insert the email and fullname fields into the obvious spots
> > > }
> > >
> > >
> > > I need to figure out how to do this, essentially:
> > >
> > > $to = array(<loop to fill other array() statements>);
> > >
> > > I don't know how to get that loop to work inside the overall array()
> > > statement, though... any assistance would be greatly appreciated.
> > >
> > > Thank you,
> > >
> > > Marc
> > >
> > >
> > >
> > > --
> > > PHP Windows Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
i think the problem is not with this code but with the code u r filling your
array with. r u sure the array $traits is the way u want it to be?
i got correct result with following code:
<?php
$traits=Array (Array ( 'traitid' => 1, 'traitname' => 'Ideas'), Array (
'traitid' => 3, 'traitname' => 'Voice' ),Array ( 'traitid' => 5, 'traitname'
=> 'Fluency' ));
for($x = 0; $x < sizeof($traits); $x++) {
echo '<tr>'
.'<td align="right" class="header">'.$traits[$x]['traitname'] . $x .'</td>'
.'<td align="center" class="text"><input type="radio"
name="'.$traits[$x]['traitid'] . '" value="1"> 1</td>'
.'<td align="center" class="text"><input type="radio"
name="'.$traits[$x]['traitid'] . '" value="2"> 2</td>'
.'<td align="center" class="text"><input type="radio" name="' .
$traits[$x]['traitid'] . '" value="3"> 3</td>'
.'<td align="center" class="text"><input type="radio" name="' .
$traits[$x]['traitid'] . '" value="4"> 4</td>'
.'</tr>';
}
?>php
Output:
<tr>
<td align="right" class="header">Ideas0</td>
<td align="center" class="text"><input type="radio" name="1" value="1">
1</td>
<td align="center" class="text"><input type="radio" name="1" value="2">
2</td>
<td align="center" class="text"><input type="radio" name="1" value="3">
3</td>
<td align="center" class="text"><input type="radio" name="1" value="4">
4</td>
</tr>
<tr>
<td align="right" class="header">Voice1</td>
<td align="center" class="text"><input type="radio" name="3" value="1">
1</td>
<td align="center" class="text"><input type="radio" name="3" value="2">
2</td>
<td align="center" class="text"><input type="radio" name="3" value="3">
3</td>
<td align="center" class="text"><input type="radio" name="3" value="4">
4</td>
</tr>
<tr>
<td align="right" class="header">Fluency2</td>
<td align="center" class="text"><input type="radio" name="5" value="1">
1</td>
<td align="center" class="text"><input type="radio" name="5" value="2">
2</td>
<td align="center" class="text"><input type="radio" name="5" value="3">
3</td>
<td align="center" class="text"><input type="radio" name="5" value="4">
4</td>
</tr>
regds,
-----Original Message-----
From: Sterling Anderson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 21, 2003 00:19
To: PHP-Windows
Subject: Odd for loop behavior.
I have the following code:
for($x = 0; $x < sizeof($traits); $x++) {
echo '<tr>'
. '<td align="right" class="header">' .
$traits[$x]['traitname'] . $x .
'</td>'
. '<td align="center" class="text"><input type="radio"
name="' .
$traits[$x]['traitid'] . '" value="1"> 1</td>'
. '<td align="center" class="text"><input type="radio"
name="' .
$traits[$x]['traitid'] . '" value="2"> 2</td>'
. '<td align="center" class="text"><input type="radio"
name="' .
$traits[$x]['traitid'] . '" value="3"> 3</td>'
. '<td align="center" class="text"><input type="radio"
name="' .
$traits[$x]['traitid'] . '" value="4"> 4</td>'
. '</tr>';
}
The array this code is using looks like this:
Array (
[0] => Array ( [traitid] => 1 [traitname] => Ideas )
[1] => Array ( [traitid] => 3 [traitname] => Voice )
[2] => Array ( [traitid] => 5 [traitname] => Fluency )
)
Here is the HTML:
<tr>
<td align="right" class="header">Ideas0</td>
<td align="center" class="text">
<input type="radio" name="1" value="1"> 1
</td>
<td align="center" class="text">
<input type="radio" name="1" value="2"> 2
</td>
<td align="center" class="text">
<input type="radio" name="1" value="3"> 3
</td>
<td align="center" class="text">
<input type="radio" name="1" value="4"> 4
</td>
</tr>
<tr>
<td align="right" class="header">1</td>
<td align="center" class="text">
<input type="radio" name="" value="1"> 1
</td>
<td align="center" class="text">
<input type="radio" name="" value="2"> 2
</td>
<td align="center" class="text">
<input type="radio" name="" value="3"> 3
</td>
<td align="center" class="text">
<input type="radio" name="" value="4"> 4
</td>
</tr>
<tr>
<td align="right" class="header">Voice2</td>
<td align="center" class="text">
<input type="radio" name="3" value="1"> 1
</td>
<td align="center" class="text">
<input type="radio" name="3" value="2"> 2
</td>
<td align="center" class="text">
<input type="radio" name="3" value="3"> 3
</td>
<td align="center" class="text">
<input type="radio" name="3" value="4"> 4
</td>
</tr>
<tr>
<td colspan="5">
<input type="submit" value="Submit" class="formfield">
<input type="reset" value="Cancel" class="formfield">
</td>
</tr>
As you can see, where value [1] of the arrray is supposed to be it is
inserting nothing. But for value [2] it is inserting [1]'s data. I'm
hoping someone can take a look at this and point out where I may have
gone
wrong. The really odd thing is this code seems to work with different
data. For example, if I have a 6 field array it properly inserts [0] to
[5].
Thanks for any input.
^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^
Sterling Anderson -- [EMAIL PROTECTED]
http://sterlinganderson.net
Human female: "The sheer drama of this election has driven voter turnout
to
it's highest level in centuries, six percent."
Morbo: "Exit poll show evil underdog Richard Nixon trailing with
estimated zero votes."
Human female: "The time is 7:59 and the robot polls are now opening. And
robot votes are now in. Nixon has won."
Morbo: "Morbo congratulates our gargantuan cyborg president. May death
come quickly to his enemies."
^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^
--- End Message ---