[PHP] Re: stop file process

2003-12-28 Thread Jed R. Brubaker
Found it!

Just use exit();


Jed R. Brubaker [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 This one should be simple.

 I am wondering if there is a simple way in which to stop the processing of
a
 file.

 The current example is a program that checks to see if the user is logged
 in. In the past I have done something like this:

 if ($loggedIn != true) {
 echo You are not logged in.;
 }
 else {
 echo Welcome;
 }

 This, however, becomes a substantial problem (or at least annoyance) when
 the else is pages long. I would prefer to have something like:

 if ($loggedIn != true) {
 echo You're not logged in.;
 // stop process of file here
 }
 // Page content (with no else)

 The ultimate objective is to have a simple function in the my class
include
 file to verify that the user is always logged in.

 Thanks in advance.

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



php-general Digest 28 Dec 2003 07:55:28 -0000 Issue 2498

2003-12-28 Thread php-general-digest-help

php-general Digest 28 Dec 2003 07:55:28 - Issue 2498

Topics (messages 173383 through 173393):

Re: How New Is HERE?
173383 by: stiano.optonline.net
173384 by: Olwen Williams

Re: HELP! -- Problem with imagejpeg()
173385 by: Al

Re: Regular Expression
173386 by: Joshua

newbie mysql and php
173387 by: tony
173390 by: Brad Pauly

PHP5 XML functions
173388 by: TopTenNut.aol.com

Printing out html
173389 by: Labunski
173391 by: Mike Brum

Re: stop file process
173392 by: Jed R. Brubaker
173393 by: Jed R. Brubaker

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]


--
---BeginMessage---
Bingo!

Thanks, everyone! And thanks especially to Andrew! You were right: I needed
the action and method attributes. And then it does increment.

My last question on this episode: Why did it work before this for some of
you trying it out for me? I mean, the code is the code, right? And either
it's correct or it's not. How come it worked without these other attributes
for some of you?

Steve 

-

It looks like your form tag is missing some attributes needed to point
your browser to the script as to where to submit the data.

if you were to try with your form tag as form
action=___SCRIPT_ITSELF_FILENAME___ method=post ??

Andrew.


mail2web - Check your email from the web at
http://mail2web.com/ .
---End Message---
---BeginMessage---
It incrementeted for me only after I changed $_POST to $_GET, but never 
gave errors.

[EMAIL PROTECTED] wrote:

Bingo!

Thanks, everyone! And thanks especially to Andrew! You were right: I needed
the action and method attributes. And then it does increment.
My last question on this episode: Why did it work before this for some of
you trying it out for me? I mean, the code is the code, right? And either
it's correct or it's not. How come it worked without these other attributes
for some of you?
Steve 

-

It looks like your form tag is missing some attributes needed to point
your browser to the script as to where to submit the data.
if you were to try with your form tag as form
action=___SCRIPT_ITSELF_FILENAME___ method=post ??
Andrew.


mail2web - Check your email from the web at
http://mail2web.com/ .
--
Olwen Williams
See my BB site
http://www.bandbclub.com
and my new site http://www.handyman.co.nz - A virtual shed for real kiwi 
blokes.
---End Message---
---BeginMessage---
Here is a complete function I wrote a few months ago.  It should do it 
for you or give you hints for fixing your problem. 

René fournier wrote:

Hello,

I have a function that is meant to check if an image is greater than
a certain width and height, and if it is, downsample it. The checking
part works fine. Downsampling is not happening though. Here's what 
I've  got
(btw, $file = /somedirectory/photo.jpg):

$src_img=imagecreatefromJPEG($file);   
$dst_img=imagecreatetruecolor($new_width,$new_height);

imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_width,$new_height,$siz 
e[0],$size[1]);
imagejpeg($dst_img,$file,$img_quality);

Any ideas?

Thanks.

...Rene

?php
/**
 * Resize an image to a new width.  Original image portion is maintained.
 * 
 * Has two modes: 
*  
* $auto == yes,  looks at $_FILES['username']['error'] to determine if a file was just uploaded. 
* If so, it gets the file name from $_FILES	and uses $file_location for the path, relative
* to the route.
* 
*  Or else, it uses the file $file_location, which must be the full path, relative to the route.  
*   
 * image resizer arguments:
 * $resize_args= array(quality = 100, new_width = 200, quality =100, backup_org = no);
 * 
 *   quality = percent [e.g. quality = 90] meaning 90%
 *   width = pixels [e.g., new_width = 200] i.e., 200 pixels.
 *   backup_org [original file] yes or no.  no is the default
 * 
 * Use this to fetch $resize_stats:
 * 		foreach($resize_stats as $key = $value)
 * {
 * echo $key .  =  . $value;
 * }
 */


function resize_width($file_location, $resize_args, $auto)
{
global $DOCUMENT_ROOT;

if (empty($resize_args)) die(p style=\color:red\Code error, argument(s) in \$resize_arg missing in resize_width. /p );

	if($auto== yes){

		if ($_FILES['username']['error'] == 0) {
	
			$name = key($_FILES); 			//could use the register variables, but this is safer.
			
	$org_img = $_FILES[$name]['name'];
	
	$org_img = filename_fixer($org_img);
			
			$org_img = $file_location . $org_img;
		}
	}
	else{$org_img = $file_location;}
	
if ($resize_args['backup_org'] == yes) {
file_backup($org_img);
} 


RE: [PHP] newbie mysql and php

2003-12-28 Thread Chris
It looks like mysql_query is failing, add these two lines to your code, and
see what message pops up:

...
$dbdo = mysql_query($query,$dbconnect);
if(false === $dbdo) echo mysql_errno(),': ',mysql_error();
else echo 'The query worked, $dbdo value is:',$dbdo;
while($row= mysql_fetch_array($dbdo)){
...


Chris

-Original Message-
From: tony [mailto:[EMAIL PROTECTED]
Sent: Saturday, December 27, 2003 4:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP] newbie mysql and php


hello

I'm new with php just learning and i have just a problem with the following
code

$dbconnect = mysql_connect(localhost, prog_tony,PASSWORD);
mysql_select_db(prog_dealer, $dbconnect);
$stop = 0;
$counter = 1;
while(!$stop){
$query = SELECT name FROM category WHERE id = $counter;
$dbdo = mysql_query($query,$dbconnect);
while($row= mysql_fetch_array($dbdo)){
if($row[0]){
$counter++;
}else{
$stop=1;
}
$row[0] = ;
}

}



I'm getting an error with mysql_fetch_array() which is line 14 because I
didn't show the other lines since it is not relevant.
here is the error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in /home/prog/public_html/php/cateadded.php on line 14

Thank you

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



Re: [PHP] newbie mysql and php

2003-12-28 Thread tony
the problem i get is that its say no database selected

Anthony


Chris [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 It looks like mysql_query is failing, add these two lines to your code,
and
 see what message pops up:

 ...
 $dbdo = mysql_query($query,$dbconnect);
 if(false === $dbdo) echo mysql_errno(),': ',mysql_error();
 else echo 'The query worked, $dbdo value is:',$dbdo;
 while($row= mysql_fetch_array($dbdo)){
 ...


 Chris

 -Original Message-
 From: tony [mailto:[EMAIL PROTECTED]
 Sent: Saturday, December 27, 2003 4:18 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] newbie mysql and php


 hello

 I'm new with php just learning and i have just a problem with the
following
 code

 $dbconnect = mysql_connect(localhost, prog_tony,PASSWORD);
 mysql_select_db(prog_dealer, $dbconnect);
 $stop = 0;
 $counter = 1;
 while(!$stop){
 $query = SELECT name FROM category WHERE id = $counter;
 $dbdo = mysql_query($query,$dbconnect);
 while($row= mysql_fetch_array($dbdo)){
 if($row[0]){
 $counter++;
 }else{
 $stop=1;
 }
 $row[0] = ;
 }

 }



 I'm getting an error with mysql_fetch_array() which is line 14 because I
 didn't show the other lines since it is not relevant.
 here is the error
 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result
 resource in /home/prog/public_html/php/cateadded.php on line 14

 Thank you

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



[PHP] Re: newbie mysql and php

2003-12-28 Thread tony
Hi,

I fixed it, I have not realize that my database was not connected to a user.

so when i logged as prog_tony  dealer was not a member of prog_tony so it
could not be found.

thanks for the help

Tony [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 hello

 I'm new with php just learning and i have just a problem with the
following
 code

 $dbconnect = mysql_connect(localhost, prog_tony,PASSWORD);
 mysql_select_db(prog_dealer, $dbconnect);
 $stop = 0;
 $counter = 1;
 while(!$stop){
 $query = SELECT name FROM category WHERE id = $counter;
 $dbdo = mysql_query($query,$dbconnect);
 while($row= mysql_fetch_array($dbdo)){
 if($row[0]){
 $counter++;
 }else{
 $stop=1;
 }
 $row[0] = ;
 }

 }



 I'm getting an error with mysql_fetch_array() which is line 14 because I
 didn't show the other lines since it is not relevant.
 here is the error
 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result
 resource in /home/prog/public_html/php/cateadded.php on line 14

 Thank you

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



[PHP] Can't upload files then 400K to MySQL

2003-12-28 Thread ahmetax
Hi,

I have the following PHP code to upload files to a MySQL table.

It works fine, but, I can't upload any files greater then 400K.

What might be the problem?

TIA

ahmet

?
if (isset($_POST[submit]))
{
$fname= $_FILES[user_file][name];
$tmp= addslashes($_FILES[user_file][tmp_name]);
$size= $_FILES[user_file][size];
$type=$_FILES[user_file][type];
$tanim=$_FILES[user_file][file_desc];
$fd=fopen($tmp,r) or die(Can't open file!);
$fdata=urlencode(fread($fd,filesize($tmp)));
$size=filesize($tmp);
$tanim=$descript;
include(baglan.inc);

mysql_select_db(dosyalar);
$sql=INSERT INTO files (name,file_type,file_desc,file_data,file_size).
 VALUES('$fname','$type','$descr','$fdata','$size');
mysql_query($sql);
}
?
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
titleAxTelSoft-Uploading a file /title
meta http-equiv=Content-Type content=text/html; charset=windows-1254
meta http-equiv=Content-Type content=text/html; charset=iso-8859-9
meta http-equiv=Content-Language content=tr
meta http-equiv=description content=axtelsoft, indir, download, delphi,
source code, kaynak kod
meta http-equiv=Pragma content=no-cache
meta name=Generator content=Ahmet Aksoy
/head
body

form enctype=multipart/form-data action=?php echo
$SERVER[PHP_SELF];? method=post
input type=hidden name=MAX_FILE_SIZE value=16777215

Send this file: input name=user_file type=file
Explanations : TEXTAREA NAME=descript ROWS=10 COLS=45 WRAP?php
echo($descr);
?/TEXTAREA
Pinput type=submit value=Send File name=submit
/form

/body
/html

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



[PHP] HELP NEEDED PLEASE - IMAP, MySQL and PHP

2003-12-28 Thread Vernon
Hello all,

I have been struggling for some time now to develop or find some product
that will allow me to scan documents (I have that part down no problem,
using OMNIPAGE 14.0) and put then into a searchable database with a copy of
it in some form that is readable like a formatted txt file.

I am looking for the easiest way to do this. I'm thinking if I can have the
files emailed into a MySQL database that would work expect the programs I
have found, however,will not allow me to bring the attachments into the
database. I've tried Xeoport which uses IMAP to access the email records and
pull all but the attachments in. Anyone know of anything that will help me
do this?

Thanks

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



Re: [PHP] Can't upload files then 400K to MySQL

2003-12-28 Thread Raditha Dissanayake
hi

try this article: http://www.radinks.com/upload/config.php
It's a quick guide on configuring php for large file uploads.
all the best



ahmetax wrote:

Hi,

I have the following PHP code to upload files to a MySQL table.

It works fine, but, I can't upload any files greater then 400K.

What might be the problem?

TIA

ahmet

?
if (isset($_POST[submit]))
{
$fname= $_FILES[user_file][name];
$tmp= addslashes($_FILES[user_file][tmp_name]);
$size= $_FILES[user_file][size];
$type=$_FILES[user_file][type];
$tanim=$_FILES[user_file][file_desc];
$fd=fopen($tmp,r) or die(Can't open file!);
$fdata=urlencode(fread($fd,filesize($tmp)));
$size=filesize($tmp);
$tanim=$descript;
include(baglan.inc);
mysql_select_db(dosyalar);
$sql=INSERT INTO files (name,file_type,file_desc,file_data,file_size).
 VALUES('$fname','$type','$descr','$fdata','$size');
mysql_query($sql);
}
?
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
titleAxTelSoft-Uploading a file /title
meta http-equiv=Content-Type content=text/html; charset=windows-1254
meta http-equiv=Content-Type content=text/html; charset=iso-8859-9
meta http-equiv=Content-Language content=tr
meta http-equiv=description content=axtelsoft, indir, download, delphi,
source code, kaynak kod
meta http-equiv=Pragma content=no-cache
meta name=Generator content=Ahmet Aksoy
/head
body
form enctype=multipart/form-data action=?php echo
$SERVER[PHP_SELF];? method=post
input type=hidden name=MAX_FILE_SIZE value=16777215
Send this file: input name=user_file type=file
Explanations : TEXTAREA NAME=descript ROWS=10 COLS=45 WRAP?php
echo($descr);
?/TEXTAREA
Pinput type=submit value=Send File name=submit
/form
/body
/html
 



--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Can't upload file greater than 11kb

2003-12-28 Thread raditha dissanayake
Hi,

if you are lucky LimitRequestBody could go into a .htaccess file (not 
sure though  been a couple of months since i last read the manual)

Chris wrote:

It has been my experience that max_file_size does terminate the upload
process if you include it in the form.
But you are right, if it gets to the upload, your stuck.
LimitRequestBody is beyond my control as the site is hosted by a third
party.
Thanks
Chris
Raditha Dissanayake [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 

Hi,

It's often said in many newsgroups and articles that the max_file_size
is next to useless. It's also said that once IE starts uploading it will
not stop even if you keep you foot on the stop button!
If i remembers the earlier messages you have said the php.ini settings
are correct. If so it could well be that you might be having
misconfigured proxy server or firewall in the way.
Apache also has a setting (LimitRequestBody) that could effect your
   

upload.
 

all the best

Chris wrote:

   

I don't believe that the MAX_FILE_SIZE needs to be there. It will only
terminate the upload process at the client, rather than wait for the
 

upload
 

to complete.

Anyway with or without MAX_FILE_SIZE the upload process is being
 

terminated
 

after the file is uploaded.

When the form is submitted, the selected file is uploaded to the server's
temp directory then copied to the maps dir.  For some reason, when the
 

file
 

size exceeds 11kb (very small) the process
gets aborted (with or without MAX_FILE_SIZE). I've put in diagnostic
messages and the POST script throws an error message if it can't find the
file
in the temp directory. I've uploaded several file sizes up to the max of
 

2MB
 

and it appears the file is being uploaded. I base this assumption on the
fact the upload time is proportional to the file size. When the file size
 

is
 

greater than 11kb it appears that the file is deleted from the temp dir.

Still no idea what is going on.
Chris
Larry Brown [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 

The input type=hidden ... is more than a convenience for the client.

   

It

 

must be before the ...type=file... tag and after form.. (at least
   

with
 

Mozilla Firebird as the client) If you have it in there and remember it
   

is
 

in bytes not kb and set it to a size large enough the script accepting
   

the
 

file will show $_FILE['name'] and it will show $_FILE['tmp_name'] having

   

the

 

temporary file.  Then you take that hidden tag out and do the same the
$_FILE['tmp_name'] variable will be empty since it did not recieve the
   

file.

 

So I know at least in my case that the hidden field has to be there.

Larry

-Original Message-
From: Chris [mailto:[EMAIL PROTECTED]
Sent: Monday, December 22, 2003 8:55 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Can't upload file greater than 11kb
I've got a situation where I want to upload a file to a server then
   

enter
 

the data in that file into mysql. I have used this well documented
   

upload
 

form

form enctype=multipart/form-data action=_URL_ method=POST
Send this file: input name=userfile type=file
input type=submit value=Send File

/form

script on many php servers. However I am on one now which is not
   

allowing
 

   

me

 

to upload a file greater than 12kb.

I know the upload_max_filesize is 2M but something else is stopping the
upload and I don't have a clue what it is. I know you should include
   

input

 

type=hidden name=MAX_FILE_SIZE value=3 in the above form but

   

that

 

is only a convenience for the user.

This particular server is running php as a cgi module.

Thanks

Chris

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

 

--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
   

 



--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Maths dumbass

2003-12-28 Thread Ryan A
Hi,
Thanks for replying, sorry for the late replies but was busy with the
holidays.

Will look in to what you guys wrote, dont fully understand it  :-p so will
spend some time with it and if I run into any problems will get back to ya.

Cheers,
-Ryan




Basically, have an array of # of days per month. Do a quick compare given
the month for the # of days. For the sake of example, we'll assume the month
in question has 31 days. So, here's some givens:

$month_days = 31;
$former_plan_days = $current_date;
$new_plan_days = ($current_date - $month_days);


Now, to get the values:

$former_plan_bill = ($full_former_price * ($former_plan_days /
$month_days));

$new_plan_bill = ($full_new_price * ($new_plan_days / $month_days));

$total_month_bill = ($former_plan_bill + $new_plan_bill);


There you have it. This should work no matter if they get an upgrade or
downgrade in service because it just takes the ratio of days to get the
percentage of the price that's owed and then multiplies the full price to
get the percentage that's owed.

Make sense? :)



 Problem, selling 4 packages rangeing from $27.50-$99.00 a month...the
 subscriber can change anytime he wants from one package to the other
 (upgrade), if so I have to calculate how many days he has is with us and
 then he just pays the balance...
 
 eg:
 if he is on the smallest package ($27.50)
 and the month has 30 days,
   and 15 days are up,
 (means 50% is used and that translates to 13.75$)
   and he wants to upgrade to the next higher package ($43.00) he just has
to
 pay $29.25
 
 Can you give me a clue on how to calculate that depending on the 12
months
 and 4 packages?

 basically just thinking out loud here... not sure if this is what we want,
but:

 $daysNotPaid = $maxDaysInPackage - $daysPaid;
 $pricePerDay = $newPrice / $daysInPackage;
 $priceToPay = $pricePerDay * $daysNotPaid;

 obviously, for this you need some code to pick up how many days have
 elapsed in the current month, and something to pull the number of days in
 the package along with the price.

 naturally you can shove this all into one calculation and save 2
variables:

 $priceToPay = ($newPrice / $daysInPackage) * ($maxDaysInPackage -
$daysPaid);

 and if some of it don't vary, you can change that into the appropriate
 values naturally...

 HTH

 Rene (not a math wiz, but I do calcs like this constantly in my Excel
macros)

 -- 
 Rene Brehmer
 aka Metalbunny

 http://metalbunny.net/
 References, tools, and other useful stuff...




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



[PHP] Simple question

2003-12-28 Thread Labunski
Hello, I have only one simple question..
I'm using this method to get the values from the text box:

  if(isset($_POST[Submit])  $_POST[Submit]==Submit)
 {
   $add = $_POST['textbox'] ;
 }

But I don't know how to write the source for this:

If the value from the textbox ($add) is Hello then.. do something.
I think it could be nicely done with IF, but I dont know how to write this..

Can someone help me, please?

Regards,
Lab.

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



php-general Digest 28 Dec 2003 21:19:11 -0000 Issue 2499

2003-12-28 Thread php-general-digest-help

php-general Digest 28 Dec 2003 21:19:11 - Issue 2499

Topics (messages 173394 through 173402):

Re: newbie mysql and php
173394 by: Chris
173395 by: tony
173396 by: tony

Can't upload files  then 400K to MySQL
173397 by: ahmetax
173399 by: Raditha Dissanayake

HELP NEEDED PLEASE - IMAP, MySQL and PHP
173398 by: Vernon

Re: Can't upload file greater than 11kb
173400 by: raditha dissanayake

Re: Maths dumbass
173401 by: Ryan A

Simple question
173402 by: Labunski

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]


--
---BeginMessage---
It looks like mysql_query is failing, add these two lines to your code, and
see what message pops up:

...
$dbdo = mysql_query($query,$dbconnect);
if(false === $dbdo) echo mysql_errno(),': ',mysql_error();
else echo 'The query worked, $dbdo value is:',$dbdo;
while($row= mysql_fetch_array($dbdo)){
...


Chris

-Original Message-
From: tony [mailto:[EMAIL PROTECTED]
Sent: Saturday, December 27, 2003 4:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP] newbie mysql and php


hello

I'm new with php just learning and i have just a problem with the following
code

$dbconnect = mysql_connect(localhost, prog_tony,PASSWORD);
mysql_select_db(prog_dealer, $dbconnect);
$stop = 0;
$counter = 1;
while(!$stop){
$query = SELECT name FROM category WHERE id = $counter;
$dbdo = mysql_query($query,$dbconnect);
while($row= mysql_fetch_array($dbdo)){
if($row[0]){
$counter++;
}else{
$stop=1;
}
$row[0] = ;
}

}



I'm getting an error with mysql_fetch_array() which is line 14 because I
didn't show the other lines since it is not relevant.
here is the error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in /home/prog/public_html/php/cateadded.php on line 14

Thank you

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---End Message---
---BeginMessage---
the problem i get is that its say no database selected

Anthony


Chris [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 It looks like mysql_query is failing, add these two lines to your code,
and
 see what message pops up:

 ...
 $dbdo = mysql_query($query,$dbconnect);
 if(false === $dbdo) echo mysql_errno(),': ',mysql_error();
 else echo 'The query worked, $dbdo value is:',$dbdo;
 while($row= mysql_fetch_array($dbdo)){
 ...


 Chris

 -Original Message-
 From: tony [mailto:[EMAIL PROTECTED]
 Sent: Saturday, December 27, 2003 4:18 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] newbie mysql and php


 hello

 I'm new with php just learning and i have just a problem with the
following
 code

 $dbconnect = mysql_connect(localhost, prog_tony,PASSWORD);
 mysql_select_db(prog_dealer, $dbconnect);
 $stop = 0;
 $counter = 1;
 while(!$stop){
 $query = SELECT name FROM category WHERE id = $counter;
 $dbdo = mysql_query($query,$dbconnect);
 while($row= mysql_fetch_array($dbdo)){
 if($row[0]){
 $counter++;
 }else{
 $stop=1;
 }
 $row[0] = ;
 }

 }



 I'm getting an error with mysql_fetch_array() which is line 14 because I
 didn't show the other lines since it is not relevant.
 here is the error
 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result
 resource in /home/prog/public_html/php/cateadded.php on line 14

 Thank you

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

I fixed it, I have not realize that my database was not connected to a user.

so when i logged as prog_tony  dealer was not a member of prog_tony so it
could not be found.

thanks for the help

Tony [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 hello

 I'm new with php just learning and i have just a problem with the
following
 code

 $dbconnect = mysql_connect(localhost, prog_tony,PASSWORD);
 mysql_select_db(prog_dealer, $dbconnect);
 $stop = 0;
 $counter = 1;
 while(!$stop){
 $query = SELECT name FROM category WHERE id = $counter;
 $dbdo = mysql_query($query,$dbconnect);
 while($row= mysql_fetch_array($dbdo)){
 if($row[0]){
 $counter++;
 }else{
 $stop=1;
 }
 $row[0] = ;
 }

 }



 I'm getting an error with mysql_fetch_array() 

[PHP] Re: Simple question

2003-12-28 Thread Andy Higgins
Hi Lab,

I normally use code of the following format, which I think is quite neat:

//Note that you do not need curely brackets in an if statement is there is
only one line
if ($_SERVER['REQUEST_METHOD'] == 'POST')
$add  = $HTTP_POST_VARS['textbox'];

if ($add == 'Hello')
do something

//It is however recommended that you do the following in order to ensure
that a user does not try to use malicious code in their input

if ($_SERVER['REQUEST_METHOD'] == 'POST')
$add  = clean($HTTP_POST_VARS['textbox'], 20);;

if ($add == 'Hello')
do something

where clean() is a function defined in an include as follows:

function clean($input, $maxlength)
{
$input = substr($input, 0, $maxlength);
$input = EscapeShellCmd($input);
return ($input);
}

Hope that helps.

Regards,
Andy



Labunski [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello, I have only one simple question..
 I'm using this method to get the values from the text box:

   if(isset($_POST[Submit])  $_POST[Submit]==Submit)
  {
$add = $_POST['textbox'] ;
  }

 But I don't know how to write the source for this:

 If the value from the textbox ($add) is Hello then.. do something.
 I think it could be nicely done with IF, but I dont know how to write
this..

 Can someone help me, please?

 Regards,
 Lab.

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



Re: [PHP] Can't upload file greater than 11kb

2003-12-28 Thread Chris
Unfortunately, creating/editing .htaccess is not an operational requirement.

Thanks anyway.
Chris

Raditha Dissanayake [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 if you are lucky LimitRequestBody could go into a .htaccess file (not
 sure though  been a couple of months since i last read the manual)

 Chris wrote:

 It has been my experience that max_file_size does terminate the upload
 process if you include it in the form.
 But you are right, if it gets to the upload, your stuck.
 
 LimitRequestBody is beyond my control as the site is hosted by a third
 party.
 
 Thanks
 Chris
 
 
 Raditha Dissanayake [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
 
 Hi,
 
 It's often said in many newsgroups and articles that the max_file_size
 is next to useless. It's also said that once IE starts uploading it will
 not stop even if you keep you foot on the stop button!
 
 If i remembers the earlier messages you have said the php.ini settings
 are correct. If so it could well be that you might be having
 misconfigured proxy server or firewall in the way.
 
 Apache also has a setting (LimitRequestBody) that could effect your
 
 
 upload.
 
 
 all the best
 
 Chris wrote:
 
 
 
 I don't believe that the MAX_FILE_SIZE needs to be there. It will only
 terminate the upload process at the client, rather than wait for the
 
 
 upload
 
 
 to complete.
 
 Anyway with or without MAX_FILE_SIZE the upload process is being
 
 
 terminated
 
 
 after the file is uploaded.
 
 When the form is submitted, the selected file is uploaded to the
server's
 temp directory then copied to the maps dir.  For some reason, when the
 
 
 file
 
 
 size exceeds 11kb (very small) the process
 gets aborted (with or without MAX_FILE_SIZE). I've put in diagnostic
 messages and the POST script throws an error message if it can't find
the
 file
 in the temp directory. I've uploaded several file sizes up to the max
of
 
 
 2MB
 
 
 and it appears the file is being uploaded. I base this assumption on
the
 fact the upload time is proportional to the file size. When the file
size
 
 
 is
 
 
 greater than 11kb it appears that the file is deleted from the temp
dir.
 
 Still no idea what is going on.
 Chris
 
 Larry Brown [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
 
 
 
 The input type=hidden ... is more than a convenience for the
client.
 
 
 
 
 It
 
 
 
 
 must be before the ...type=file... tag and after form.. (at least
 
 
 with
 
 
 Mozilla Firebird as the client) If you have it in there and remember
it
 
 
 is
 
 
 in bytes not kb and set it to a size large enough the script accepting
 
 
 the
 
 
 file will show $_FILE['name'] and it will show $_FILE['tmp_name']
having
 
 
 
 
 the
 
 
 
 
 temporary file.  Then you take that hidden tag out and do the same the
 $_FILE['tmp_name'] variable will be empty since it did not recieve the
 
 
 
 
 file.
 
 
 
 
 So I know at least in my case that the hidden field has to be there.
 
 Larry
 
 -Original Message-
 From: Chris [mailto:[EMAIL PROTECTED]
 Sent: Monday, December 22, 2003 8:55 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Can't upload file greater than 11kb
 
 
 I've got a situation where I want to upload a file to a server then
 
 
 enter
 
 
 the data in that file into mysql. I have used this well documented
 
 
 upload
 
 
 form
 
 form enctype=multipart/form-data action=_URL_ method=POST
 Send this file: input name=userfile type=file
 
 input type=submit value=Send File
 
 /form
 
 script on many php servers. However I am on one now which is not
 
 
 allowing
 
 
 
 
 me
 
 
 
 
 to upload a file greater than 12kb.
 
 I know the upload_max_filesize is 2M but something else is stopping
the
 upload and I don't have a clue what it is. I know you should include
 
 
 
 
 input
 
 
 
 
 type=hidden name=MAX_FILE_SIZE value=3 in the above form
but
 
 
 
 
 that
 
 
 
 
 is only a convenience for the user.
 
 This particular server is running php as a cgi module.
 
 Thanks
 
 Chris
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 
 
 -- 
 Raditha Dissanayake.
 
 http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
 Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
 Graphical User Inteface. Just 150 KB | with progress bar.
 
 
 
 
 


 -- 
 Raditha Dissanayake.
 
 http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
 Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
 Graphical User Inteface. Just 150 KB | with progress bar.

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



[PHP] need a little help all

2003-12-28 Thread webmaster
Here is what i have i call 2 cookies in the top of my script, now i need to
call another when another script is called but it keeps givin me the error
headers already sent,
now ive seen this done in other scripts but wont work for me so please help
me is it in my php.ini or is it just not possible and imagened seeing it
somwhere else. Thanks all.

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



Re: [PHP] need a little help all

2003-12-28 Thread Richard Davey
Hello,

Wednesday, December 17, 2003, 11:50:52 AM, you wrote:

wmc Here is what i have i call 2 cookies in the top of my script, now i need to
wmc call another when another script is called but it keeps givin me the error
wmc headers already sent,
wmc now ive seen this done in other scripts but wont work for me so please help
wmc me is it in my php.ini or is it just not possible and imagened seeing it
wmc somwhere else. Thanks all.

You can access the value of cookies anywhere in your script,
regardless if the headers have been sent or not. However you cannot
SET a cookie once the headers have gone for use in the same page
session. This isn't a PHP setting, it's just not possible.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



[PHP] mcrypt and PHP to encrypt values to be passed to differend server

2003-12-28 Thread Mark Wouters
Hello!

I'm trying to use mcrypt to encrypt some values (login and password) I have
to pass from one website to another.
I thook this code from the php.net website as an example:

?php
/* Open the cipher */
$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');

/* Create the IV and determine the keysize length */
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM);
$ks = mcrypt_enc_get_key_size ($td);

/* Create key */
$key = substr (md5 ('very secret key'), 0, $ks);

/* Intialize encryption */
mcrypt_generic_init ($td, $key, $iv);

/* Encrypt data */
$encrypted = mcrypt_generic ($td, 'This is very important data');

/* Terminate encryption handler */
mcrypt_generic_deinit ($td);

/* Initialize encryption module for decryption */
mcrypt_generic_init ($td, $key, $iv);

/* Decrypt encrypted string */
$decrypted = mdecrypt_generic ($td, $encrypted);

/* Terminate decryption handle and close module */
mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);

/* Show string */
echo trim ($decrypted).\n;
?

I put this in the page starting from:

?php
$adminlogin = $row1[adminlogin];
$adminpw = $row1[adminpw];
// both are queried from a database

$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM);
$ks = mcrypt_enc_get_key_size ($td);
$key = substr (md5 ('a key fsfqz'), 0, $ks);
mcrypt_generic_init ($td, $key, $iv);

/* Encrypt data */
$encryptedlogin = mcrypt_generic ($td, $adminlogin);
$encryptedpassw = mcrypt_generic ($td, $adminpw);

mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);
?
a href=destinationpage.php?login=?php echo($encryptedlogin);
?password=?php echo($encryptedpassw); ? target=_blanklink/a


In the destination page (destinationpage.php, on a different server) I have
this:

  $td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
  $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td),
MCRYPT_DEV_RANDOM);
  $ks = mcrypt_enc_get_key_size ($td);
  $key = substr (md5 ('a key fsfqz'), 0, $ks);
  mcrypt_generic_init ($td, $key, $iv);

  /* Decrypt encrypted string */
  $login = mdecrypt_generic ($td, $login);
  $login = trim ($login);
  $password = mdecrypt_generic ($td, $password);
  $password = trim ($password);

  mcrypt_generic_deinit ($td);
  mcrypt_module_close ($td);

  and then an echo($login - $passwordbr); to check if the values are
correct.

But they are not!!
What am I doing wrong?? Is it because both are on a different server?
I would very much appreciate your help. Or if someone has an other good way
of encrypting values, please let me know!

Thanks!!!

Mark.

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



[PHP] [Newbie Guide] For the benefit of new members

2003-12-28 Thread Ma Siva Kumar
===
This message is for the benefit of new subscribers 
and those new to PHP.  Please feel free to add 
more points and send to the list.
===
1. If you have any queries/problems about PHP try 
http://www.php.net/manual/en first. You can 
download a copy and use it offline also. 

Please also try http://www.php.net/manual/faq.php 
to get answers to frequently answered questions 
about PHP (added by Christophe Chisogne).

2. Try http://www.google.com next. Searching for 
php YOUR QUERY may fetch you relevant results 
within the first 10 results, if you are lucky.

3. There is a searchable archive of the mailing 
list discussion at 
http://phparch.com/mailinglists. Many of the 
common topics are discussed repeatedly, and you 
may get answer to your query from the earlier 
discussions. 

For example: One of the repeatedly discussed 
question in the list is Best PHP editor. 
Everyone has his/her favourite editor. 
You can get all the opinions by going through the 
list archives. If you want a chosen list try this 
link : http://phpeditors.linuxbackup.co.uk/ 
(contributed by Christophe Chisogne).

4. Not sure if PHP is working or you want find out 
what extensions are available to you?

Just put the following code into a file with a 
.php extension and access it through your 
webserver:

?php
phpinfo();
? 

If PHP is installed you will see a page with a lot 
of information on it. If PHP is not installed (or 
not working correctly) your browser will try
to download the file.

(contributed by Teren and reworded by Chris W 
Parker)

5. If you are stuck with a script and do not 
understand what is wrong, instead 
of posting the whole script, try doing some 
research yourself. One useful trick is to print 
the variable/sql query using print or echo 
command and check whether you get what you 
expected. 

After diagnosing the problem, send the details of 
your efforts (following steps 1, 2  3) and ask 
for help.

6. PHP is a server side scripting language. 
Whatever processing PHP does takes 
place BEFORE the output reaches the client. 
Therefore, it is not possible to access the 
users'  computer related information (OS, screen 
size etc) using PHP. You need to go for 
JavaScript and ask the question in a JavaScript 
list.

On the other hand you can access the information 
that is SENT by the user's browser when a client 
requests a page from your server. You can
find details about browser, OS etc as reported by 
this request. - contributed by Wouter van Vliet 
and reworded by Chris W Parker.

7. Provide a clear descriptive subject line. Avoid 
general subjects like Help!!, A Question etc.  
Especially avoid blank subjects. 

8. When you want to start a new topic, open a new 
mail composer and enter the mailing list address 
[EMAIL PROTECTED] instead of replying to 
an existing thread and replacing the subject and 
body with your message.

9. It's always a good idea to post back to the 
list once you've solved your problem. People 
usually add [SOLVED] to the subject line of their
email when posting solutions. By posting your 
solution you're helping the next person with the 
same question. [contribued by Chris W Parker]

10. Ask smart questions  
http://catb.org/~esr/faqs/smart-questions.html
[contributed by Jay Blanchard)

Hope you have a good time programming with PHP.

Best regards,

-- 
Integrated Management Tools for leather industry
--
http://www.leatherlink.net

Ma Siva Kumar,
BSG LeatherLink (P) Ltd,
Chennai - 600106

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



Re: [PHP] mcrypt and PHP to encrypt values to be passed to differend server

2003-12-28 Thread Tom Rogers
Hi,

Monday, December 29, 2003, 9:30:11 AM, you wrote:
MW Hello!

MW I'm trying to use mcrypt to encrypt some values (login and password) I have
MW to pass from one website to another.


You will need to pass the $iv which kinda defeats the object of it, or
use a null one. Here is a class I use for this which also corrects the
string lengths as decryption will usually have a few /0 tacked on to
make it a block size:

class encrypt_class{
var $secret;
function encrypt_class(){
$this-secret = 'choose your own pass phrase here';
}
Function encode($id){
$eid = $iv = 0;
$len = strlen($id);
$id = $len.'-'.$id;
$td = mcrypt_module_open(MCRYPT_TripleDES, , MCRYPT_MODE_ECB, );
$key = substr($this-secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);
$eid = base64_encode(mcrypt_generic ($td, $id));
mcrypt_generic_deinit($td);
  return $eid;
}
Function decode($eid){
$id = $iv = 0;
$td = mcrypt_module_open (MCRYPT_TripleDES, , MCRYPT_MODE_ECB, );
$key = substr($this-secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);
$id = mdecrypt_generic ($td, base64_decode($eid));
$len = strtok($id,'-');
$id = substr($id,(strlen($len)+1),$len);
mcrypt_generic_deinit($td);
return $id;
}
}
 //usage
 $password = 'password';
 $name = 'me';
 
 $mesage[0] = $password;
 $message[1] = $name;

 $serial = serialize($message);
 
 $enc = new encrypt_class();
 $enc_message = $enc-encode($serial);
 //send message ?enc_message=$enc_message

 //next page
 $enc = new encrypt_class();
 $serial = $enc-decode($_GET['enc_message']);
 $message = unserialize($serial);
 print_r($message);

-- 
regards,
Tom

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



[PHP] fopen

2003-12-28 Thread Cesar Aracena
Hello,

I am trying to open my first text file using PHP and my PC almost freezed...
please don't laught. Here's my script:

function welcometext()
{
 $fp = fopen(../files/welcome.txt, a+);

 while (!feof($fp, 100))
 {
  $text = fgets($fp, 100);
  echo $text;
 }

 fclose($fp);
}

What can be wrong? Thanks in advanced,

Cesar Aracena

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



Re: [PHP] [Newbie Guide] For the benefit of new members

2003-12-28 Thread Raditha Dissanayake
Hi,

This compilation of your is really excellent. Over the last few months i 
have noticed that many posters are cleary sending messages without 
having read your newby guide.  IMHO whenever that happens all of us on 
this list should suggest that the user should read this message in the 
archive first before responding to his query.

best regards



Ma Siva Kumar wrote:

===
This message is for the benefit of new subscribers 
and those new to PHP.  Please feel free to add 
more points and send to the list.
===
 

--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] multiple select option alternative to field_name[]

2003-12-28 Thread Terence
Dear All,

The only way I know to retrieve all the values from a multiple select field
is to use
the square brackets after the field name ie. user_id[]

The problem however is that when I use a javascript function to transfer the
items
from multiple_select_list1 to multiple_select_list2, I cannot use the square
brackets
in a field name, as this obviously conflicts with something in the script.

So I am wondering if there's any other way in PHP to get the items, or do I
have
to find an alternative way in javascript? If anyone has ideas it would be
great.

Thanks
Terence



my code:

 (This works)

   echo select name='select1' multiple size='7'
class='inputstyle'/select\n;

input type='button' class='buttonstyle' value='  ' onClick=\if
(document.images) copySelected(this.form.select1,this.form.select2)\
input type='button' class='buttonstyle' value='  ' onClick=\if
(document.images) copySelected(this.form.select2,this.form.select1)\
input type='button' class='buttonstyle' value='' onClick=\if
(document.images) copyAll(this.form.select1,this.form.select2)\
input type='button' class='buttonstyle' value='' onClick=\if
(document.images) copyAll(this.form.select2,this.form.select1)\

select name='select2' multiple size='7' class='inputstyle'/select

(This is the problem - notice the square brackets behind select2)

 echo select name='select1' multiple size='7'
class='inputstyle'/select\n;

input type='button' class='buttonstyle' value='  ' onClick=\if
(document.images) copySelected(this.form.select1,this.form.select2[])\
input type='button' class='buttonstyle' value='  ' onClick=\if
(document.images) copySelected(this.form.select2[],this.form.select1)\
input type='button' class='buttonstyle' value='' onClick=\if
(document.images) copyAll(this.form.select1,this.form.select2[])\
input type='button' class='buttonstyle' value='' onClick=\if
(document.images) copyAll(this.form.select2[],this.form.select1)\

select name='select2[]' multiple size='7' class='inputstyle'/select


Javascript:

echo script language='JavaScript'!--\n;
 echo function deleteOption(object,index) {\n;
echo object.options[index] = null;\n;
 echo }\n;

 echo function addOption(object,text,value) {\n;
 echo var defaultSelected = true;\n;
 echo var selected = true;\n;
 echo var optionName = new Option(text, value, defaultSelected,
selected)\n;
 echo object.options[object.length] = optionName;\n;
 echo }\n;

 echo function copySelected(fromObject,toObject) {\n;
 echo for (var i=0, l=fromObject.options.length;il;i++) {\n;
 echo if (fromObject.options[i].selected)\n;
 echo
addOption(toObject,fromObject.options[i].text,fromObject.options[i].value);
\n;
 echo }\n;
 echo for (var i=fromObject.options.length-1;i-1;i--) {\n;
 echo if (fromObject.options[i].selected)\n;
 echo deleteOption(fromObject,i);\n;
 echo }\n;
 echo }\n;

 echo function copyAll(fromObject,toObject) {\n;
 echo for (var i=0, l=fromObject.options.length;il;i++) {\n;
 echo
addOption(toObject,fromObject.options[i].text,fromObject.options[i].value);
\n;
 echo }\n;
 echo for (var i=fromObject.options.length-1;i-1;i--) {\n;
 echo deleteOption(fromObject,i);\n;
 echo }\n;
 echo }\n;
 echo //--/script\n;

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



Re: [PHP] fopen

2003-12-28 Thread Gerard Samuel
On Sunday 28 December 2003 11:17 pm, Cesar Aracena wrote:
  $fp = fopen(../files/welcome.txt, a+);


Change to
$fp = fopen(../files/welcome.txt, r);

Use r to read, when you use a it appends (or adds) to the file
Its also suggested to use the b option to so it would look like
$fp = fopen(../files/welcome.txt, rb);

That is done for portability between *nix and windows.

More info is at the manual
http://us2.php.net/manual/en/function.fopen.php

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



Re: [PHP] [Newbie Guide] For the benefit of new members

2003-12-28 Thread Ma Siva Kumar
On Monday 29 Dec 2003 10:24 am, you wrote:
 Hi,

 This compilation of your is really excellent.
 Over the last few months i have noticed that
 many posters are cleary sending messages
 without having read your newby guide.  IMHO
 whenever that happens all of us on this list
 should suggest that the user should read this
 message in the archive first before responding
 to his query.


Thanks. The idea is to send it once a week to 
catch the new subscribers with a message into 
their inbox before they commit any of the sins 
(!).  Guess, some new users slip in the gap in 
between.

Best regards,

Ma SivaKumar



-- 
Integrated Management Tools for leather industry
--
http://www.leatherlink.net

Ma Siva Kumar,
BSG LeatherLink (P) Ltd,
Chennai - 600106

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



Re: [PHP] multiple select option alternative to field_name[]

2003-12-28 Thread Binay
Hi Terence

Assign ids to multiple select field and then use id attribute of select tag
in JavaScript to access (copy,del etc.) instead of using the name attribute.

Hope this helps.

Cheers
Binay
- Original Message -
From: Terence [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 29, 2003 11:46 AM
Subject: [PHP] multiple select option alternative to field_name[]


 Dear All,

 The only way I know to retrieve all the values from a multiple select
field
 is to use
 the square brackets after the field name ie. user_id[]

 The problem however is that when I use a javascript function to transfer
the
 items
 from multiple_select_list1 to multiple_select_list2, I cannot use the
square
 brackets
 in a field name, as this obviously conflicts with something in the script.

 So I am wondering if there's any other way in PHP to get the items, or do
I
 have
 to find an alternative way in javascript? If anyone has ideas it would be
 great.

 Thanks
 Terence



 my code:

  (This works)

echo select name='select1' multiple size='7'
 class='inputstyle'/select\n;

 input type='button' class='buttonstyle' value='  ' onClick=\if
 (document.images) copySelected(this.form.select1,this.form.select2)\
 input type='button' class='buttonstyle' value='  ' onClick=\if
 (document.images) copySelected(this.form.select2,this.form.select1)\
 input type='button' class='buttonstyle' value='' onClick=\if
 (document.images) copyAll(this.form.select1,this.form.select2)\
 input type='button' class='buttonstyle' value='' onClick=\if
 (document.images) copyAll(this.form.select2,this.form.select1)\

 select name='select2' multiple size='7' class='inputstyle'/select

 (This is the problem - notice the square brackets behind select2)

  echo select name='select1' multiple size='7'
 class='inputstyle'/select\n;

 input type='button' class='buttonstyle' value='  ' onClick=\if
 (document.images) copySelected(this.form.select1,this.form.select2[])\
 input type='button' class='buttonstyle' value='  ' onClick=\if
 (document.images) copySelected(this.form.select2[],this.form.select1)\
 input type='button' class='buttonstyle' value='' onClick=\if
 (document.images) copyAll(this.form.select1,this.form.select2[])\
 input type='button' class='buttonstyle' value='' onClick=\if
 (document.images) copyAll(this.form.select2[],this.form.select1)\

 select name='select2[]' multiple size='7'
class='inputstyle'/select


 Javascript:

 echo script language='JavaScript'!--\n;
  echo function deleteOption(object,index) {\n;
 echo object.options[index] = null;\n;
  echo }\n;

  echo function addOption(object,text,value) {\n;
  echo var defaultSelected = true;\n;
  echo var selected = true;\n;
  echo var optionName = new Option(text, value, defaultSelected,
 selected)\n;
  echo object.options[object.length] = optionName;\n;
  echo }\n;

  echo function copySelected(fromObject,toObject) {\n;
  echo for (var i=0, l=fromObject.options.length;il;i++) {\n;
  echo if (fromObject.options[i].selected)\n;
  echo

addOption(toObject,fromObject.options[i].text,fromObject.options[i].value);
 \n;
  echo }\n;
  echo for (var i=fromObject.options.length-1;i-1;i--) {\n;
  echo if (fromObject.options[i].selected)\n;
  echo deleteOption(fromObject,i);\n;
  echo }\n;
  echo }\n;

  echo function copyAll(fromObject,toObject) {\n;
  echo for (var i=0, l=fromObject.options.length;il;i++) {\n;
  echo

addOption(toObject,fromObject.options[i].text,fromObject.options[i].value);
 \n;
  echo }\n;
  echo for (var i=fromObject.options.length-1;i-1;i--) {\n;
  echo deleteOption(fromObject,i);\n;
  echo }\n;
  echo }\n;
  echo //--/script\n;

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