Re: [PHP] Form executes differently in IE than in FireFox?

2004-11-03 Thread Chris Dowell
Murray
I'm guessing that IE sends $recid = '' whereas firefox doesn't send it 
at all because it's an empty form field.

Try checking for empty($recid) instead - that way you can check that it 
not only exists (as in isset) but also that it has a value (i.e. not '', 
NULL, 0 or FALSE)

Hope this helps
Cheers
crhis
Murray @ PlanetThoughtful wrote:
Hi Jason,
I wasn't under the impression that posting 18ish lines of code would be
thought of as inconsiderate, but thank you for the pointer all the same. 

Btw, have you noticed that your signature is about 12 lines long? I assume
that goes out on all of your messages, not just the once-off of my post?
Laugh, don't mind me, I'm as much of a hypocrite as the next person.
Thank you again.
Much warmth,
Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.
-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 4 November 2004 5:01 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Form executes differently in IE than in FireFox?

On Wednesday 03 November 2004 09:55, Murray @ PlanetThoughtful wrote:
Please be considerate by NOT posting your COMPLETE code. Construct a
*concise* 
example that sufficiently illustrates your problem.


However, the same form, submitted with what should be a blank recid hidden
field value, is being treated differently - in IE it's being treated as
though it's an edit, while in FireFox it's being treated as I expect it
to,
as an insert.

var_dump($_POST['recid']) and show what you're getting from IE and Firefox.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Strange Array Error

2004-10-21 Thread Chris Dowell
Shaun
The problem is that you've assigned $test_array[] = array();
This means that the first element ($test_array[0]) is an array.
You're then trying to add $i to it, as in $test_array[$i] = 
$test_array[$i] + 1;

in terms of types what you're doing is array = array + integer
Which doesn't make any sense.
If you change the first line to $test_array = array();
Then the individual elements will all be NULL, which evaluates to 0 in 
an integer context, and you will get the result you expect.

Hope this helps
Cheers
Chris
Shaun wrote:
Hi,
I have been trying for the past two hours to understand why I get an error 
with the following code:

?php
 $test_array[] = array();
 $i = 0;
 while($i  7){
  $test_array[$i] += $i;
  echo '$day_total[$i] = '.$day_total[$i].'br';
 }
?
Fatal error: Unsupported operand types in 
/usr/home/expensesystem/public_html/test.php on line 5

I am trying to create a loop where $i is added to array element $i, and 
can't find any information relating to this on google or php.net...

Thanks for your advice. 

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


Re: [PHP] Strange Array Error

2004-10-21 Thread Chris Dowell
That is, expected results, *apart* from the infinite loop you'll have 
due to not incrementing $i

Cheers
Chris
Chris Dowell wrote:
Shaun
The problem is that you've assigned $test_array[] = array();
This means that the first element ($test_array[0]) is an array.
You're then trying to add $i to it, as in $test_array[$i] = 
$test_array[$i] + 1;

in terms of types what you're doing is array = array + integer
Which doesn't make any sense.
If you change the first line to $test_array = array();
Then the individual elements will all be NULL, which evaluates to 0 in 
an integer context, and you will get the result you expect.

Hope this helps
Cheers
Chris
Shaun wrote:
Hi,
I have been trying for the past two hours to understand why I get an 
error with the following code:

?php
 $test_array[] = array();
 $i = 0;
 while($i  7){
  $test_array[$i] += $i;
  echo '$day_total[$i] = '.$day_total[$i].'br';
 }
?
Fatal error: Unsupported operand types in 
/usr/home/expensesystem/public_html/test.php on line 5

I am trying to create a loop where $i is added to array element $i, 
and can't find any information relating to this on google or php.net...

Thanks for your advice.

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


Re: [PHP] File Copy

2004-10-20 Thread Chris Dowell
Aidal
Could you post the relevant parts of your code so we have a little 
context to work in?

You say you're copying a file from one location to another on the same 
server. If this is the case you are very unlikely to be in need of the 
ftp family of functions, which are only valid for use over an 
established ftp connection.

I suspect that the file is indeed now owned by the webserver
has it changed from aidal:somegroup to nobody:nogroup or something like 
that?

Post us some code and the answers you get will probably be more useful
Cheers
Chris
Aidal wrote:
ftp_chmod() is part of PHP 5 and I'm working with PHP 4.3.1.
I tried the ftp_raw('CHMOD 777 filename.jpg'); doesn't work either though :(
Silvio Porcellana [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Aidal wrote:
Hi NG.
I'm experiencing some problems when trying to copy a file from one
location
to another on the web server.
example:
dir1/subdir1/some_image_name.jpg  --
dir2/subdir2/some_new_image_name.jpg
When I do this the file permissions changes and I'm no longer the owner
of
the file. I tried to use chmod('the_new_file', 0777); but it doesn't
work,
because chmod() wont let me change the permissions since I'm not the
owner
of this new file.
The owner should now be the user the Web server is running as.
To change file ownerships you need to use the PHP FTP functions.
Check out these pages: http://php.libero.it/manual/en/ref.ftp.php
HTH, cheers!
Silvio Porcellana

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


Re: [PHP] 'Intelligently' truncate string?

2004-10-19 Thread Chris Dowell
You could also try a combination of html_entity_decode to change all 
entities back, then truncate it, then use html_entities to get back to 
the encoded string.

Hope this helps
Cherrs
Chris
Robert Cummings wrote:
On Mon, 2004-10-18 at 14:35, Murray @ PlanetThoughtful wrote:
Hi All,
I'm working on a page where I'm attempting to display article titles in a
relatively narrow area. To save from ugly wrap-arounds in the links, I've
decided to truncate the article title string at 20 chars. This works well
except where the truncate occasionally falls in the middle of a HTML entity
reference (eg nbsp; or copy; etc).

after you do your usual truncation just add the following:
$truncated = ereg_replace( '[[:alpha:]]*$', '', $truncated );
You may need to replace alpha with alnum since I can't remember if there
are any entities with digits :)
Cheers,
Rob.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Session

2004-10-19 Thread Chris Dowell
Deleo
We had an interesting conversation on this last just last week regarding 
the length of sessions.

The title of the thread is [PHP]Sessions not destroyed. Try searching 
the archives with that text.

I believe Marek's and my own messages may have the information you're 
looking for - basically, PHP doesn't provide a mechanism to *guarantee* 
expiry of sessions - only to deal with garbage-collecting defunkt ones. 
Any explicit session-expiry will have to be implemented by the end-user; 
i.e. you.

Hope this helps
Cheers
Chris
Deleo Paulo Ribeiro Junior wrote:
Hello!
I am trying to make my pages last for only 1 minute but I am not been successfull.
I have already changed session.cache_expire = 1 in php.ini (USING RedHat) but nothing 
happens.
I would like the pages to last only for 1 minute, this means that if the user do not 
use the site within 1 minute all the session variables will be lost and he will have 
to log on again (I am using session variables to store name and password).
Can anyone help me?
Thank you
Deleo
 

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


Re: [PHP] Nesting level too deep - recursive dependency?

2004-10-18 Thread Chris Dowell
Francisco
You really need to post this to [EMAIL PROTECTED] - this list is 
for us lowly users of PHP, the developers and maintainers of the 
language have their own list.

Cheers
Chris
Francisco M. Marzoa Alonso wrote:
Can someone tell me if I should fill a bug report about this or is it my 
fault???

Francisco M. Marzoa Alonso wrote:
This code:
?php
class TestClass {
public $myself;
function __construct () {
$this-myself = $this;
}
}
$TestObj = new TestClass ();
if ( $TestObj-myself == $TestObj ) {
echo They are same.\n;
}
?
Gives me a Fatal error: Nesting level too deep - recursive dependency?
on line #13: if ( $TestObj-myself == ...)
Could this be a PHP bug or I'm doing something wrong?
FYI:
PHP Version 5.0.2
PHP API 20031224
PHP Extension 20040412
Zend Extension 220040412
Server API Apache 2.0 Handler

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


Re: [PHP] Nested foreach ?

2004-10-17 Thread Chris Dowell
Stuart,
Having read what you've written so far, you may want to try something 
like this.

In your HTML (I've left the selects empty, but you can see what I mean):

input type=text name=skills[0][name] /select 
name=skills[0][years] /select name=skills[0][used] /

input type=text name=skills[1][name] /select 
name=skills[1][years] /select name=skills[1][used] /

input type=text name=skills[2][name] /select 
name=skills[2][years] /select name=skills[2][used] /

...
input type=text name=skills[9][name] /select 
name=skills[9][years] /select name=skills[9][used] /


Then in PHP
?php
foreach ($_POST['skills'] as $skill)
{
 $skillname = $skill['name'];
 $yearsused = $skill['years'];
 $lastused = $skill['used'];
 ...
}
?
Hope this helps
Cheers
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] add item to end of (multidimensional) array

2004-10-15 Thread Chris Dowell
try $Arr[] = array('name' = 'arnold', 'address' = 'street');
Arnold wrote:
Hi,
How can i add new items to an array without using an index.
Normally (single dimension) you can do:  Arr[]=x and this item is
added to the array, but what if i have subitems like:
Arr[]['name']=arnold; Arr[]['address']=street.
This last example doesnt work and i think there will be an easy solution but
who can tell me this?
Arnold
 

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


Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Chris Dowell
Try is_int($_POST['mobile_number']) or ctype_digit($_POST['mobile_number'])
HTH
Cheers
Chris
Robert Cummings wrote:
On Fri, 2004-10-15 at 07:45, Gareth Williams wrote:
Do you even need a regex?
What about
if (strlen($_POST['mobile_number']) != 11  
substr($_POST['mobile_number'],0,3) != 447)
{
	$error=Invalid Number;
}

This doesn't verify that the portion following 447 is also a number.
   eg. 4474567X901
Cheers,
Rob.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Advanced maths help (for GD image functionality)

2004-10-15 Thread Chris Dowell
Problem 1)
$h_1 = 600;
$w_1 = 800;
$h_2 = 120;
$w_2 = $w_1 * ($h_2 / $h_1);
Problem 2 a)
Assuming you're wanting the central portion of the original image (which 
I think you are from what you've written)

$h_1 = 600;
$w_1 = 800;
$h_2 = 120;
$w_2 = 90;
$x = ($h_1 - $h_2) / 2;
$y = ($w_1 - $w_2) / 2;
Problem 2 b)
If you're in fact trying to get the central portion of the new thumbnail
$h_1 = 600;
$w_1 = 800;
$h_2 = 120;
$w_2 = $w_1 * ($h_2 / $h_1);  // need to have the correct thumbnail 
width to start from

$x = ($w_2 - 90) / 2;
$y = 0;  // because the image is only 120px high
Hope this helps
Cheers
Chris

Mag wrote:
 [snip]
 Heres my maths problems in 2 parts:

 Problem 1)
 I need to scale down an image (eg: example.jpg) to
 height of 120 pixels while maintaining the images
 proportions.
 [/snip]
 ...
 [snip]
 Problem 2)
 After getting the above image now I need the x and y
 parameters to cut a h120 x w90 thumb *from the center
 of the image*
 [/snip]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Advanced maths help (part 2)

2004-10-15 Thread Chris Dowell
I think you've a couple of problems with your second problem (problem 
problem problem).

First of all, you're setting $dst_h to 0, which gives you a height of 0 
- IIRC that's not what you wanted :)

You should be setting that $dst_h = 120 as you always want it to be 120px
I reckon that your code should look more like this:
?php
// assuming that we're creating two thumbnails, one has h=120, w=?, the 
second has h=120, w=90
// we'll also assume that the original has h=600, w=800

$src_img =  imagecreatefromjpeg(tgp1.jpg);
$src_h = imagesy($src_img); // 600
$src_w = imagesx($src_img); // 800
$dst_h = 120;
$dst_w =  $src_w * ($dst_h / $src_h);
$dst_img = imagecreatetruecolor($dst_w,$dst_h);
imagecopyresampled ($dst_img, $srcImage, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
// so far so good, now, lets save the file
imagejpeg($dst_img, 'test.jpg');
unset($dst_img);
// time for problem 2
// first we need a h=120, w=90 image
// image size for h=120, w=90 thumbnail
$dst_h = 120;
$dst_w = 90;
$dst_img = imagecreatetruecolor($dst_w, $dst_h);
// we will be copying to the top left corner of the new thumbnail
$dst_x = 0;
$dst_y = 0;
// now, let's find the top-left offset from the larger original image
$src_x = ($src_h - $dst_h) / 2;
$src_y = ($src_w - $dst_w) / 2;
// no need for imagecopyresampled as we'll be doing 1-1 pixel copying here
imagecopy ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $src_w, 
$src_h);

// so far so good, now, lets save the file
imagejpeg($dst_img, 'test2.jpg');
unset($dst_img);
?
img src=test.jpg /img src=test2.jpg /

Hope this helps (although I haven't tested it)
Cheers
Chris

Mag wrote:
Hi again guys, :-)
Thanks to the educated (and excellient) help of Chris
and trevor I am now getting proportionate thumbs
(which was problem 1, remember? )
Heres the code that i am using, if it may help anyone
else:
** code start **
$src_img =  imagecreatefromjpeg(tgp1.jpg);
$img_dim = getimagesize(tgp1.jpg);
$h_1 = $img_dim[1];
$w_1 = $img_dim[0];
$dst_h = 120;
$dst_w = $w_1 * ($dst_h / $h_1);
$dst_img = imagecreatetruecolor($dst_w,$dst_h);
$src_w = imagesx($src_img);
$src_h = imagesy($src_img);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
// problem 1 solved till here
** code end **
Then i am trying to work with problem 2, instead of
starting all over again from the beginning of getting
the images dimensions etc I am continueing and trying
to get it straight from the above like so:
** code start problem 2**
$dst_w = ($dst_w - 90) / 2;
$dst_h = 0;  // because the image is only 120px high
imagecopyresampled($dst_img,$src_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
ImageJPEG($dst_img,'test.jpg');
echo img src=test.jpgbrThe bitch works!;
** code end problem 2 **
When i check the output I am only getting the first
parts output... is what i am doing even possible? or
do I have to do everything from the start for problem
2 (eg: read from disk, calculate dimensions etc)
Thanks,
Mag

=
--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
		
__
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 


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


Re: [PHP] Help with sessions problem please

2004-10-14 Thread Chris Dowell
No
I think it's more likely that one of his tentacles slipped
Chris Shiflett wrote:
--- John Holmes [EMAIL PROTECTED] wrote:
header('Location: http://www.example.org/script2.php?.SID);

He is human after all. :-)
Chris
=
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly HTTP Developer's Handbook - Sams
Coming December 2004http://httphandbook.org/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Query Returning Error

2004-10-13 Thread Chris Dowell
You can get around this problem more easily by putting your variables 
inside curly brackets when they appear inside strings.

See here: 
http://uk.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

Or as an example:
?php
$Query01 = SELECT * FROM Users
WHERE UserID = '{$_POST['TXT_UserID']}'
AND UserPassword = '{$_POST['TXT_UserPassword']}';
$Result01 = mysql_query($Query01) or die (Error 01:  . mysql_error());
?
Note also that you didn't quote the index you were using inside the 
$_POST array. This is wrong - it will work in raw PHP because it will 
be interpreted as an undefined constant, and thus replaced with the 
string, however the behaviour inside a quoted string is even less 
correct, and will almost certainly not do what you expect.

Hope this helps
Cheers
Chris
Graham Cossey wrote:
Besides adding $ to Query01, I have had little luck in the past when  using
$_POST or $_GET directly in an evaluated string. If you are still having
problems, try something like:
?php
$user = $_POST['TXT_UserID'];
$pwd = $_POST['TXT_UserPassword'];
// Authenticate User:
   $Query01 = SELECT * FROM Users
   WHERE UserID='$user' AND
 UserPassword='$pwd';
   $Result01 = mysql_query($Query01) or die(Error 01:  . mysql_error());
?
HTH
Graham

-Original Message-
From: Harlequin [mailto:[EMAIL PROTECTED]
Sent: 13 October 2004 08:32
To: [EMAIL PROTECTED]
Subject: [PHP] Query Returning Error
Morning all.
this is such a basic question I'm embarrassed to ask but the query worked
fine a few minutes ago and now returns an error:
I get an error:
Parse error: parse error, unexpected '=' in sample.php on line 2
[CODE]
// Authenticate User:
  Query01 = SELECT * FROM Users
  WHERE UserID='$_POST[TXT_UserID]'
  AND UserPassword='$_POST[TXT_UserPassword]';
  $Result01 = mysql_query($Query01) or die(Error 01:  . mysql_error());
[/CODE]
WTF...?
--
-
Michael Mason
Arras People
www.arraspeople.co.uk
-
--
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] Using HTTP/PUT with PHP Apache Any browser in the whole world that works properly??????

2004-10-13 Thread Chris Dowell
Guys
According to the docs, you need to use either php://stdin or php://input 
 to read from files uploaded via PUT, however I'm unable to get even 
that  far.

My HTML form is as shown:
form action=index.php method=put enctype=multipart/form-data
input type=file name=putfile /input type=submit /
/form
However both firefox  IE use GET instead of PUT. Has anyone used PUT 
for anything, and if so, how did you get this most basic of steps to work?

FYI, googling for html forms method=PUT -xforms gets me nothing.
Cheers
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Exporting HTML to Excel

2004-10-13 Thread Chris Dowell
Header(Content-type: application/ms-excel);
or whatever the content type should be (on IE you can probably get away 
with application/octet-stream as it bases its decisions of file 
extensions for a lot of things).

HTH
Chris
Philip Thompson wrote:
How exactly would I change the mime headers?
~Philip
On Oct 12, 2004, at 5:07 PM, Vail, Warren wrote:
Have you tried changing your file name to project.htm but continue 
issuing
the mime headers for excel?

Warren Vail
-Original Message-
From: Philip Thompson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 12, 2004 2:21 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Exporting HTML to Excel
Hi all.
This may not be completely a PHP question, but hopefully you will be
able to provide some insight. I have a table in HTML that I want to
export to an excel spreadsheet. Using PHP, I can create an excel
document - however, it's empty/blank. I think I am just doing it
incorrectly. Anybody done this before and/or have any ideas? I would
prefer to NOT use a third-party program.
I've searched the web and php.net, but have been somewhat unsuccessful
in finding anything. Here's what I have so far:
-
?php
header('Content-Type: application/ms-excel');
header('Content-Disposition: attachment; filename=project.xls'); ?
table
tr
tdSomething/td
/tdSomething else/td
/tr
/table
-
I just want it to have that content in the spreadsheet. It's actually
more involved than that, but that's the gist of it.
Thanks in advance.
~Philip
--
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Using HTTP/PUT with PHP Apache Any browser in the whole world that works properly??????

2004-10-13 Thread Chris Dowell
I could
But on massive file uploads the various gateways between clients and
server are timing out.
I've no evidence that PUT would help me solve this problem, but it's an
avenue I thought worth pursuing, as the whole point of the PUT method is
to send large quantities of data to a server. I am hoping that the
gateways will respect this fact (although I'm not holding my breath).
If anyone has any alternate suggestions (other than Stop using MS
gateway servers, which is unfortunately impossible given our clients),
I'd be happy to hear them.
Cheers
Chris
John Nichel wrote:
Chris Dowell wrote:
Guys
According to the docs, you need to use either php://stdin or 
php://input  to read from files uploaded via PUT, however I'm unable 
to get even that  far.

My HTML form is as shown:
form action=index.php method=put enctype=multipart/form-data
input type=file name=putfile /input type=submit /
/form
However both firefox  IE use GET instead of PUT. Has anyone used PUT 
for anything, and if so, how did you get this most basic of steps to 
work?

FYI, googling for html forms method=PUT -xforms gets me nothing.

Can you just use 'POST' as your form method?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Exporting HTML to Excel

2004-10-13 Thread Chris Dowell
meek /
sorry
[skulks off into dark corner to cry]
Philip Thompson wrote:
Chris, as you may have (or may have not) noticed, I did that. Look at my 
original email. I wasn't sure if there was more to it than that.

~Philip
On Oct 13, 2004, at 8:34 AM, Chris Dowell wrote:
Header(Content-type: application/ms-excel);
or whatever the content type should be (on IE you can probably get 
away with application/octet-stream as it bases its decisions of file 
extensions for a lot of things).

HTH
Chris
Philip Thompson wrote:
How exactly would I change the mime headers?
~Philip
On Oct 12, 2004, at 5:07 PM, Vail, Warren wrote:
Have you tried changing your file name to project.htm but continue 
issuing
the mime headers for excel?

Warren Vail
-Original Message-
From: Philip Thompson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 12, 2004 2:21 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Exporting HTML to Excel
Hi all.
This may not be completely a PHP question, but hopefully you will be
able to provide some insight. I have a table in HTML that I want to
export to an excel spreadsheet. Using PHP, I can create an excel
document - however, it's empty/blank. I think I am just doing it
incorrectly. Anybody done this before and/or have any ideas? I would
prefer to NOT use a third-party program.
I've searched the web and php.net, but have been somewhat unsuccessful
in finding anything. Here's what I have so far:
-
?php
header('Content-Type: application/ms-excel');
header('Content-Disposition: attachment; filename=project.xls'); ?
table
tr
tdSomething/td
/tdSomething else/td
/tr
/table
-
I just want it to have that content in the spreadsheet. It's actually
more involved than that, but that's the gist of it.
Thanks in advance.
~Philip
--
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Exporting HTML to Excel

2004-10-13 Thread Chris Dowell
In an attempt to make amends, have you tried PEAR's 
Spreadsheet_Excel_Writer?

http://pear.php.net/package/Spreadsheet_Excel_Writer
It certainly works, we used it last week (although I have no *personal* 
experience of it)

Cheers
Chris
Chris Dowell wrote:
meek /
sorry
[skulks off into dark corner to cry]
Philip Thompson wrote:
Chris, as you may have (or may have not) noticed, I did that. Look at 
my original email. I wasn't sure if there was more to it than that.

~Philip
On Oct 13, 2004, at 8:34 AM, Chris Dowell wrote:
Header(Content-type: application/ms-excel);
or whatever the content type should be (on IE you can probably get 
away with application/octet-stream as it bases its decisions of file 
extensions for a lot of things).

HTH
Chris
Philip Thompson wrote:
How exactly would I change the mime headers?
~Philip
On Oct 12, 2004, at 5:07 PM, Vail, Warren wrote:
Have you tried changing your file name to project.htm but continue 
issuing
the mime headers for excel?

Warren Vail
-Original Message-
From: Philip Thompson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 12, 2004 2:21 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Exporting HTML to Excel
Hi all.
This may not be completely a PHP question, but hopefully you will be
able to provide some insight. I have a table in HTML that I want to
export to an excel spreadsheet. Using PHP, I can create an excel
document - however, it's empty/blank. I think I am just doing it
incorrectly. Anybody done this before and/or have any ideas? I would
prefer to NOT use a third-party program.
I've searched the web and php.net, but have been somewhat unsuccessful
in finding anything. Here's what I have so far:
-
?php
header('Content-Type: application/ms-excel');
header('Content-Disposition: attachment; filename=project.xls'); ?
table
tr
tdSomething/td
/tdSomething else/td
/tr
/table
-
I just want it to have that content in the spreadsheet. It's actually
more involved than that, but that's the gist of it.
Thanks in advance.
~Philip
--
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] With a graphic image, making text transparent

2004-10-12 Thread Chris Dowell
http://uk.php.net/imagecolorallocatealpha
Todd Cary wrote:
I would like to place text on a graphic but vary the transparency of 
the text.  Can this be done with the gd library?

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


Re: [PHP] RE: **[SPAM]** RE: [PHP] Newsgroups Space

2004-10-09 Thread Chris Dowell
Matthew Sims wrote:
Nice idea, but you want to be future-proof, don't you?
Once alt.binaries.vr.animals.lobster starts filling up with 5 hour
Virtual Reality ROMs you're looking at needing a lot more than that. I'd
go with about 6 YB if I were you, and that's only because there aren't
any SI prefixes higher than Yotta (10^24).
Yeah, that Super Turbo Lobster Fighter Alpha EX2 Special is freakin' huge.
 

Mmmm. I  wasn't actually talking about games, but I guess you could use 
it for that too.

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


Re: [PHP] Sessions not destroyed

2004-10-09 Thread Chris Dowell
As Marek has stated a number of times, the session options in php.ini
are meant to be set to reasonable values for the usage pattern for your
server, in order that you can achieve a balance between a /tmp or
/var/tmp of several zillion kilobytes, and a constant 100% cpu usage as
the gc routine runs again and again.
That's all it is. If you wish to time out your sessions for security
purposes, you need to handle that security in your application. Security
is the responsibility of the developer, and should always remain that
way. Anything else is leaving you open to trouble.
To restate, the session.gc_maxlifetime defines how long the session must
have been inactive in order for it to be SAFE to be gc'ed. That's why
it's session.*GC*_maxlifetime and not session.security_maxlifetime. The
setting has no bearing on when a session MUST be gc'ed. That is up to
the developer to deal with - hell, with session.gc_divisor = 0, you can
have session files which are never deleted if you desire - that doesn't
mean your users should never be logged out, now does it?
Hope this clears things up a little.
Cheers
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Grab an array from a cookie without throwing errors?

2004-10-09 Thread Chris Dowell
pedantry
Of course, you're running unserialize() twice.
What about
if (empty($_COOKIE['bookmarks']) || !($bookmarks = 
unserialize($_COOKIE['bookmarks'])))
{
 $bookmarks = array();
}

Does the same with only one call to a potentially weighty function.
/pedantry
Cheers
Chris
John Nichel wrote:
Brian Dunning wrote:
I've got a cookie that's either non-existent or a serialized array. 
I'm trying all sorts of different code combinations to retrieve it 
into an array variable, but everything I try throws up some 
combination of notices and/or warnings. Here is my latest  greatest:

$cookie = $_COOKIE['bookmarks'];
if(unserialize($cookie) == true) {
$bookmarks = unserialize($cookie);
} else {
$bookmarks = array();
}

Use isset
if ( isset ( $_COOKIE['bookmarks'] )  unserialize ( 
$_COOKIE['bookmarks'] ) ) {
$bookmarks = unserialize ( $_COOKIE['bookmarks'] );
} else {
$bookmarks = array();
}

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


Re: [PHP] Callback functions inside classes - how to?

2004-10-09 Thread Chris Dowell
From the manual:
http://uk.php.net/manual/en/language.pseudo-types.php#language.types.callback
If you want to change things in the callback, the function (or method) 
should accept its parameters by reference.

e.g.
class A
{
 function name($a, $b, $c)
 {
   $a = $b . $c;
   return;
 }
 function parse()
 {
   // whatever
   // then (calls $this-name())
   $parser-set_handler( root/page/title, array($this, 'name') );
   // or (calls A::name())
   $parser-set_handler( root/page/title, array('A', 'name') );
   // more whatever
 }
}
Hope this helps
Cheers
Chris
Thomas Hochstetter wrote:
Hi again,
I have always been wondering how this is done properly:
Here is an example:
[snip]
class A {
  function name( $a, $b, $c) {
 $tmp = array();
 $tmp[a] = $a;
 .
array_push( $GLOBALS['XMLStack'], $tmp );
 }
 function parse() {
   .. some definitions .
   $parser-set_handler( root/page/title, name );
  . some more stuff here .
 }
}
[/snip]
What I want is to have the callback function name as it is in the above
example. But, obviously, the above code won't work. So, how do I tell the
set_handler function that it must use the name function from the class?
Using:
A::name or $this-name (if instantiated) . how do these callback
function calls work, because the same issue is with the xml handler
functions in php4 (have not as yet been to v5).
Also, how can I get the data from the callback function out without using
$GLOBALS? I cannot just return an array, can I?
Any ideas.
Thanks so  long.
Thomas

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


Re: [PHP] Grab an array from a cookie without throwing errors?

2004-10-09 Thread Chris Dowell
pedantry
Of course, you're running unserialize() twice.
What about
if (empty($_COOKIE['bookmarks']) || !($bookmarks = 
unserialize($_COOKIE['bookmarks'])))
{
 $bookmarks = array();
}

Does the same with only one call to a potentially weighty function.
/pedantry
Cheers
Chris
John Nichel wrote:
Brian Dunning wrote:
I've got a cookie that's either non-existent or a serialized array. 
I'm trying all sorts of different code combinations to retrieve it 
into an array variable, but everything I try throws up some 
combination of notices and/or warnings. Here is my latest  greatest:

$cookie = $_COOKIE['bookmarks'];
if(unserialize($cookie) == true) {
$bookmarks = unserialize($cookie);
} else {
$bookmarks = array();
}

Use isset
if ( isset ( $_COOKIE['bookmarks'] )  unserialize ( 
$_COOKIE['bookmarks'] ) ) {
$bookmarks = unserialize ( $_COOKIE['bookmarks'] );
} else {
$bookmarks = array();
}

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


Re: [PHP] RE: **[SPAM]** RE: [PHP] Newsgroups Space

2004-10-08 Thread Chris Dowell
Nice idea, but you want to be future-proof, don't you?
Once alt.binaries.vr.animals.lobster starts filling up with 5 hour 
Virtual Reality ROMs you're looking at needing a lot more than that. I'd 
go with about 6 YB if I were you, and that's only because there aren't 
any SI prefixes higher than Yotta (10^24).

Jay Blanchard wrote:
[snip]
Better go with 2TB. You know how all that porn fills up.
[/snip]
Shoot, I forgot porn. 4-7TB minimum
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] splitting string into array

2004-09-29 Thread Chris Dowell
In PHP4
$array = explode(';', chunk_split(A12B05C45D34, 3, ';'));
In PHP4
$array = str_split(A12B05C45D34, 3);
RTFM
Cheers
Chris
blackwater dev wrote:
How can I take a string and create an array?
Example,
A12B05C45D34
I need to split this into chunks of three A12,B05,C45..etc?
Thanks!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] How can I formated a PHP script into colored HTML

2004-09-28 Thread Chris Dowell
There's also a pear package that might help you:

http://pear.php.net/package/Text_Highlighter

Cheers

Chris

Jason Wong wrote:
 On Tuesday 28 September 2004 12:40, [EMAIL PROTECTED] wrote:
 
 
How can I make a code into html format like this
 
 
 You can have a look at the highlight_file() function.
 

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



Re: [PHP] Wrong php.ini being read at my hosting account

2004-09-24 Thread Chris Dowell
I think you really need to contact your hosting company and berate them 
for lying to you.

Like Jason says, the definitive list is from *your* php_info(), not the 
hosting companies - you might like to send them copies of both and ask 
them to explain the differences.

Cheers
Chris
missshus wrote:
When I log into my hosting account I have access to the official phpinfo() 
script and it shows certain extensions (like mbstring for example) as 
available, but they are not available to my scripts. Every time I try to 
use them I get Call to undefined function errors. At first I just avoided 
those extensions but now I really need the mbstring extension so I started 
looking for solutions to this problem. I realized that my phpinfo() script 
gives a different output than the official one, and I think it's because 
it's showing a different path to php.ini. My script shows /usr/local/lib as 
its php.ini path and the official one shows /etc/php4/apache. So, after 
reading some of the older messages on this list I tried putting SetEnv 
PHPRC /etc/php4/apache in my .htaccess file. Then, my script was showing 
that as its php.ini path but it was obvious it was still giving the same 
output. 

I also remember (from the archives) someone else said his phpinfo() was 
showing the same path, but he said there was no php.ini file at 
/usr/local/lib on his system. And all I remember from his thread is that 
php is probably just using the default settings and showing /usr/local/lib 
as its path. I don't know if there is a php.ini on their system at that 
path or not, all I want to do is use the extension the hosting company is 
showing as available in it's phpinfo() script. I've tried contacting them, 
but they have given me some really stupid answers (free hosting, that's 
kind of what I expected). 

I think it's also important to point out that this it the first time I've 
opened a hosting account so I'm not really sure if this is their problem or 
mine. Shouldn't both phpinfo() scripts give the same results?

Any help would be really appreciated.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Pear::Image_Text - how to change background color from black

2004-09-24 Thread Chris Dowell
Guys
Without hacking the pear library, does anyone know of any way (using the 
API) to change the background color of an image created with Image_Text 
from black?

The bg is black because the image resource is created using 
imagecreatetruecolor() which returns a black image - this is on some of 
lines 550-569 in the pear source. I could change this, but I'm sure 
Tobias must have written in some way for this to be changed - the docs 
are of course minimal, and I can't find anything in the source.

The text is nice and yellow, as specified in the code below, the only 
problem is changing the background from the lovely black default.

Can anyone help me out? Code follows:
Cheers
Chris
-
?php
require_once 'Image/Text.php';
$options = array( 'image_type' = IMAGETYPE_JPEG,
  'font_file' = 'flc.ttf',
  'width' = 100,
  'height' = 200,
  'font_path' = '/path/to/font/file/',
  'max_lines' = 1,
  'x' = 2,
  'y' = 2,
  'font_size' = 12,
);
$hImage = Image_Text::construct(hello world, $options);
$hImage-setColor('#00', 0);
$hImage-init();
$hImage-render();
$hImage-display();
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] [SOLVED] [PHP] Pear::Image_Text - how to change background color from black

2004-09-24 Thread Chris Dowell
Just FYI
I figured it out - there is an $options['canvas'] option which accepts, 
amongst other things, a handle to an image resource. Trivial then to use 
imagecreate() and imagecolorallocate() to create a white-background 
starting point.

Sorry for wasting everyone's time
Cheers
Chris
Chris Dowell wrote:
Guys
Without hacking the pear library, does anyone know of any way (using 
the API) to change the background color of an image created with 
Image_Text from black?

The bg is black because the image resource is created using 
imagecreatetruecolor() which returns a black image - this is on some 
of lines 550-569 in the pear source. I could change this, but I'm sure 
Tobias must have written in some way for this to be changed - the docs 
are of course minimal, and I can't find anything in the source.

The text is nice and yellow, as specified in the code below, the only 
problem is changing the background from the lovely black default.

Can anyone help me out? Code follows:
Cheers
Chris
-
?php
require_once 'Image/Text.php';
$options = array( 'image_type' = IMAGETYPE_JPEG,
  'font_file' = 'flc.ttf',
  'width' = 100,
  'height' = 200,
  'font_path' = '/path/to/font/file/',
  'max_lines' = 1,
  'x' = 2,
  'y' = 2,
  'font_size' = 12,
);
$hImage = Image_Text::construct(hello world, $options);
$hImage-setColor('#00', 0);
$hImage-init();
$hImage-render();
$hImage-display();
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] interesting behavior of ob_end_flush() in __destruct()

2004-09-24 Thread Chris Dowell

it seems that php first ends output buffering and then calls then 
destructs the objects. so the output buffering is still ended when the 
destructor is calles. one has to unset the object to reverse that 
order manually.

aRZed
If I remember correctly, there were a number of posts about this subject 
on the internals list before PHP5 came out. I seem to recall that the 
gist of it was that destructors are called *after* the script 
terminates. Someone mentioned that output from destructors (echo, print, 
etc) may not be passed to the browser at all due to the connection 
having (possibly) been closed.

I haven't searched through the archives to refresh my memory, but it's 
something to bear in mind. I wonder whether error messages are also not 
passed to the browser...

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


Re: [PHP] Mohavi

2004-09-22 Thread Chris Dowell
Yeah
I've rebuilt a huge CoOperative Marketing Fund Administration tool using 
version 1.3 or 1.4 (I can't be arsed to look right now).

It's good for what it does - the only problem I have lies in the fact 
that the classes you generate for actions and views are generally quite 
large, and if the code is not tidy it becomes hellishly difficult to 
read. I have a colleague who singlehandedly caused me to pull out most 
of my hair because his normally-inconvenient style of coding was made 
incomprehensible due to the sheer size of some of the classfiles.

Version 2 looks even better, but unfortunately wasn't released when I 
started :(

Hope this helps
Cheers
Chris
p.s. I think the gist of that was that I like Mojavi but not people who 
use it

Greg Donald wrote:
Anyone using this?
http://mojavi.org/
If so, how do you like it?

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


Re: [PHP] inserting timestamp into mysql field

2004-09-22 Thread Chris Dowell
That's not 100% correct
If you have more than one TIMESTAMP field only the first (IIRC) will be 
filled with the current time - other TIMESTAMP fields will only be filed 
if you set them = NULL.

This is true of MySQL  4.1.2 - there is more fine-grained control over 
the behaviour from 4.1.2 onwards.

Note that for  4.1.2 the first TIMESTAMP field will also be 
automatically set on UPDATE.

Hope this helps
Cheers
Chris
Andrew Kreps wrote:
On Tue, 21 Sep 2004 16:25:37 +0100, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
i need to insert a current timestamp into a mysql field when a form is posted.
can anyone suggest a simple way of doing this?

Here's the MySQL answer: If you have a (data type) timestamp field in
your table, you don't need to do anything.  MySQL will automatically
fill it in on insert, and update it when you run an update query.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] inserting timestamp into mysql field

2004-09-21 Thread Chris Dowell
Not really a MySQL question - the answer happens to be MySQL, but the 
question asks how to do it in PHP

This might still be necessary if the OP is using something like 
DB_DataObject, as you can't really use NOW() in that situation

Try strftime [ http://uk.php.net/strftime - RTFM :) ] - a good format 
string would be %Y-%m-%d %H:%M:%S which will produce -00-00 00:00:00

Marek Kilimajer wrote:
[EMAIL PROTECTED] wrote:
Subject: inserting timestamp into mysql field
hi there,
i need to insert a current timestamp into a mysql field when a form is 
posted.
can anyone suggest a simple way of doing this? i would like to set a 
variable
in my php script to add into the insert statement. it needs to be in the
format 00-00-00 00:00:00.

insert table set .., date_added = NOW()
mysql question by the way...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Infinate looping

2004-09-21 Thread Chris Dowell
Are you by any chance doing something like this?
while (1)
{
 $dbh = mysql_connect(x, x, x);
 mysql_query(...);
 sleep(10);
}
If so, you could run into that maxclients problem very quickly because 
you're not closing those mysql connections (they'll time out eventually, 
and there are persistent connection options in php.ini), but as you're 
only running one thread, you should never really have more than one 
connection open at a time - a well-placed mysql_close() may do wonders

Of course, that's just a guess as to how your script might be executing
If it really matters to you, you can get a cron job to execute (I think) 
every second, which would probably be a better solution

Or http://uk.php.net/manual/en/features.persistent-connections.php might 
have some useful info - I don't know because I haven't taken the time to 
read it :)

Cheers
Chris
Stephen Craton wrote:
i haven't paid a lot of attention to your setup. are you running this 
through your web server or via the php-cli?
   

Basically I have a file that connects to a database, before the loop, and
then checks the database for new messages. If there are, it displays them
accordingly
 

if via php through the 
web server i suspect you're running into a maxclients problem (your 
client connections aren't closing fast enough so you're using up all 
the client connections).
   

I was thinking this could be the case. Is there any way not to use up
maxclients? I'm just running one loop, though it may be infinite.
 

if you're running this through your web server, a much more efficient 
approach would be via a php-cli or perl application. either of these 
should be able to run as continuous tasks without causing other 
problems.
   

I would run through command line but I'm not sure how. This is a chat script
anyway, and I'm not sure if I have command line abilities on my production
server.
Also, I was thinking of maybe using a socket server. Are socket servers
allowed by mainstream web hosts or do you need certain privileges to open a
socket and connect to them?
Thanks,
Stephen Craton

 

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


Re: [PHP] password-protecting with PHP, help plz

2004-09-21 Thread Chris Dowell
And after that - go and try to find out a little on your own - contrary 
to a common misconception, it's not the sole purpose of members of this 
list to write all your code for you.

The old favourites RTFM and STFW would serve you well here - there are 
thousands of PHP tutorials that will tell you how to write complex if 
statements, and the PHP Manual has an entire section devoted to handling 
authentication with PHP here: 
http://uk.php.net/manual/en/features.http-auth.php

Hope this helps
Cheers
Chris
John Nichel wrote:
Burhan Khalid wrote:
[snip]
And here is the action page, testing2.php.
if ($_POST['user'] == 'Andrew')  ($_POST['pass'] == 'pass') {
echo Welcome, Andrew.; }
And (shocker!) I got a blank page. So I turned out display errors 
and got this:

Parse error: syntax error, unexpected T_BOOLEAN_AND in 
c:\TSW\pages\testing2.php on line 3

PLEASE ... read the manual on basic syntax.

And read here too.
http://us4.php.net/manual/en/language.control-structures.php#control-structures.if 


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


Re: [PHP] empty variable

2004-09-21 Thread Chris Dowell
Just to clear up, there is no isempty() function - the correct function 
is empty() and its details can be found here: http://uk.php.net/empty

Cheers
Chris
-{ Rene Brehmer }- wrote:
At 01:54 20-09-2004, Chris Mach wrote:
What is the best way to determine if a variable is empty?
I have a feeling there is a better way than the way I'm doing it now...
if ($variable == )

there's 2:
if (isset($variable))
or
if (isempty($variable))
what's most appropriate depends on how the variable is set or not
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] generating a mysql script

2004-09-21 Thread Chris Dowell
If course, if you don't have shell access, phpMyAdmin is all you'll ever 
need

http://www.phpmyadmin.net
Cheers
Chris
Brian V Bonini wrote:
On Mon, 2004-09-20 at 19:37, Stut wrote:
 

On Mon, 20 Sep 2004 16:20:21 -0700, AMC [EMAIL PROTECTED] wrote:
   

Is there a tool that will generate a script that can be run to rebuild a
mysql database? I need to move my database to a different server
 

No need to use PHP which also makes this OT but... 

Dump the data to a compressed file:
shell mysqldump --quick db_name | gzip  db_name.contents.gz
Load it up into new machines db.
shell mysqladmin create db_name
shell gunzip  db_name.contents.gz | mysql db_name
You could also directly transfer it:
shell mysqladmin -h 'other hostname' create db_name
shell mysqldump --opt db_name \
   | mysql -h 'other hostname' db_name
 

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


Re: [PHP] Re: mysql_connect does not connect

2004-09-21 Thread Chris Dowell
Sam,
You're correct - the manual does leave a little bit of a grey area about 
which extension you should use for 4.1.0  MySQL version  4.1.3

However, as you're using 5.0.1 this really shouldn't confuse you to 
quite the extent which it has.

Sam Hobbs wrote:
Curt Zirzow [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 

RTFM.
mysql:
This MySQL extension doesn't support full functionality of MySQL
versions greater than 4.1.0. For that, use MySQLi.
mysqli:
The mysqli extension is designed to work with the version 4.1.3 or
above of MySQL.
   

What the manual says (as quoted) is either not relevant or is not clear.
 

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


Re: [PHP] mysql_connect does not connect

2004-09-21 Thread Chris Dowell
[snippy]
Sam Hobbs wrote:
Um.. you do realize you have more problems than php not being able
to connect to the database.
   

This is the type of unproductive comment that causes problems. The only 
reason you are saying this is because you are desperate to make me wrong. 
You have exhausted reasonable comments and must resort to unreasonable ones. 
That sure is a problem here. 

[/snippy]
On the contrary, Sam - yours is a comment that is more likely to cause 
problems - the inevitable backlash of hatred directed at you is 
founded solely in your mistaken assumption that you alone are correct.

If that's truly the case, then why are you asking a bunch of 
feeble-minded jerks like ourselves for help? We have difficulty enough 
tying our shoelaces.

Since you *have*, misguidedly or otherwise, chosen to come to this list 
for help, you could have the decency to thank everyone for their 
suggestions. You asked for our help and we're trying to supply it - if 
you've tried something already, even if we're just completely and 
utterly wrong, we've still taken time out of our day, solving our 
problems to pay our bills in order to help you solve yours.

Will you at least have the courtesy to explain how you fixed the problem 
- that way we can avoid having this conversation again when someone else 
has the same issue.

Cheers
Chris
p.s. I noticed that you also shouted down Rasmus in a post on the PHP 
Internals list. You say you're primarily a C++ programmer - would you 
try and tell Bjorn Stroustroup to shut up?


I particularly like this, from that list:
[snippy]
This is possible and if so then I agree that it is not a php problem and 
there is not much more for php to do than to give a hint somewhere.

[/do you know, some days I feel like a hairdresser]
Especially given your reaction when Rasmus suggested exactly that
[snippy once more]
Rasmus Lerdorf [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 

I am not sure why you assume this to be a PHP problem.
   

I thought I was being reasonable. I thought I was clear about saying I was 
not sure it is a PHP problem. I was trying to help by helping diagnose a 
problem. If it is not a problem then you could say so in a more reasonable 
manner. If you always react to people this way when they are trying to help 
then you will have an inferior product since you discourage people from 
helping.

I am not assuming; that is why I am asking this question. You really can say 
the same thing except without the emotions. You can simply state the fact 
that as far as you know it is not a PHP problem. It really, really helps to 
keep in mind that it is better to simply state facts. That keeps things less 
emotional and generally keeps things at a more reasonable level.

[/no more snippy]
p.p.s I realise I haven't helped at all, but you're funny and I'm glad 
of the light relief you inadvertently provide.

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


Re: [PHP] fopen problem, 5 line script

2004-09-16 Thread Chris Dowell
Irrelevant, Warren
Mag,
the point is that you're trying to use a function (filesize) that uses 
the stat() system call. This function is not supported using the http 
wrapper to fopen (because HTTP doesn't support it at all)

So regardless of whether you should be using the file name or the handle 
(it's the name, btw), the call will fail because you're trying to stat() 
a file which isn't supported.

Thus filesize() is failing (with a warning), and fread() is then failing 
because filesize() returns false, which evaluates to 0.

Hope this has made things clearer, if not, a quick check of the manual 
entries for stat, filesize and Appendix L 
(http://uk.php.net/manual/en/wrappers.php) may help

Cheers
chris
Vail, Warren wrote:
I thought filesize required the file name, and not the fileptr???
Warren Vail
-Original Message-
From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 15, 2004 10:17 AM
To: php php
Subject: Re: [PHP] fopen problem, 5 line script

* Thus wrote Mag:
 

Hi,
Can someone tell me what I am doing wrong here please?
?php
$fileptr =
fopen(http://www.google.com/index.html,r;);
$contents = fread($fileptr, filesize($fileptr));
...
This is the error I get:
Warning: filesize(): Stat failed for Resource id #1
(errno=2 - No such file or directory) in 
/home/quickxxx/public_html/tpg/ check- remote.php on line 4

Warning: fread(): Length parameter must be greater
than 0. in /
home/quickxxx/public_html/tpg/check-remote.php on line
   

filesize() relies on the fact that the file you opened has support for
stat(). the http wrapper does not have such a thing.
see:
 http://php.net/filesize
 http://php.net/wrappers.http
Curt
 

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


Re: [PHP] File Download Problems

2004-09-16 Thread Chris Dowell
Chances are your 1KB file contains an error message - try changing the 
Content-Type to text/plain or text/html to see what PHP is throwing at you

Cheers
Chris
Marek Kilimajer wrote:
PHP Junkie wrote:
Ave,
I've been having a very nagging and frustrating problem for a while 
and I
hope someone can help me out with this.

I created a simple File Manager application, a lot of you already 
know about
it as you helped me with coding at different stages.

The problem is this: The Download.
When you download a file, it's giving problems sometimes. What is 
happening
is, a 1 KB file downloads instead of the actual file. And thus the file
downloaded is no good. The file uploaded is absolutely perfect. Since 
I have
the web server which contains this website, I'm easily able to check all
these things. When a user uploads a file, it's uploaded absolutely 
perfect.
It's not a 1 KB file.. The whole file is uploaded and it's not 
corrupt. But
when a user downloads the file... Most of the time a 1 KB file is
downloaded.. And its' corrupt of course.

The more frustrating part is, it happens sometimes.. Not everytime. 
It is
happening 90% of the time.. But sometimes it is able to download the 
actual
file. If you try the same file from different locations, 15 times... 
1 out
of 15 times the file will download fine.

I've been doing all sorts of testing to narrow down the problem but I 
don't
know the problem.
This is my download script :

?php
$file = $P/$F;
header(Content-Description: File Transfer);
header(Content-Type: application/force-download);
header(Content-Disposition: attachment; filename=.basename($file));
@readfile($file);
?
Which is called using this link on the main page:
a 
href=\imsafm_user_dl.php?ID=$myrow[ID]P=imsafm/$userF=$myrow[filename]\ 

img src=b_newtbl.png border=0/a
What does the 1 KB file contain? Is it the beginning of the wanted 
file? Remove @ while debuging.
Add header('Content-Lenght: ' . filesize($file));
Check server logs.

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


Re: [PHP] mysql_connect does not connect

2004-09-16 Thread Chris Dowell
All this is irrelevant; while you're still trying to use MySQL 5 with 
mysql_connect() instead of mysqli_connect(), it WILL NEVER WORK

Sort that out first before you start worrying about firewalls - you 
can't test the firewall if you can't ever have a successful test case.

Cheers
Chris
Markus Mayer wrote:
On Thursday 16 September 2004 05:06, Sam Hobbs wrote:
 

It is my understanding that the firewall is not supposed to be relevant. I
   

It is our experience at my employer that the firewall in XP-SP2, as well as 
other firewalls that are available, are very relevant.

 

have not seen anything saying it is supposed to be. 
   

We also have not seen any documentation about problems with such things 
after installing SP2, but we have problems.  Things that worked before don't 
work any more, especially client side things.  Our three small Windoze 
servers have given our Windoze administrator more than enough work recently.

 

If it is true that it 
is not supposed to be relevant, then simply saying it is just causes
confusion. If you had said that the firewall is not supposed to be
relevant, but try disabling it anyway, then I would say that I am totally
able to think like that too. It is reasonable to try things like that to
diagnose a bug.
   

flame blocked by firewall.
 

If you can find something in the MySQL documentation saying that the
firewall needs to be disabled eventhough the server and client are the same
system, then that would sure help. I am not asking you to; I am saying that
that is what would help.
   

SP2 is so new that its effects are still being evaluated by a lot of people.  
At the moment, I think the best place to get information about its effects is 
forums like this one.  Formal documentation will be updated in time as more 
experience is gained.  The info I got from our Windows admin is that with 
SP2, the MS SQL server on one machine was apparenty unaffected, but the MySQL 
on another was.  Dropping the MS Firewall in SP2 allowed connections again.

Client side, SP2 has caused nothing but problems for us to the point where we 
as administrators are now saying to our users it was working before you 
installed SP2, and after you installed SP2 it stopped working, so it's your 
problem.  IE is especially problematic, and when someone calls up and says 
they have a problem with IE and have installed SP2, our response is that we 
no longer support IE and tell the users to install Mozilla, and if they still 
have problems when they try Mozilla, they can call us back.  We haven't heard 
from any of them again, and our help desk girls have always been able to 
quickly sort out the problems users have when they first try Mozilla.

I looked back in this thread and saw that you used Zone Alarm as a firewall.  
You need to allow MySQL connections to localhost, and that regardless of 
which firewall you use.  If you filter such connections out, PHP scripts will 
not be able to connect to your MySQL server.  This is because PHP makes a TCP 
connection to the MySQL server, also when it is running on the same machine 
as you PHP/Apache (at least this is my understanding).  You can of course 
continue refuse all external (that is not from localhost) connections to 
whatever service is running on your machine.  I think something to this 
effect has already been said in this thread, but at the moment I don't want 
to search for the post.

While the flame war in this thread has been amusing to read, it's amusement 
value for me has more or less run out.  My impression is that you still don't 
have the thing working, and the only solution left is to configure your 
firewall to allow connections to your MySQL server from localhost.  If you 
would do this, and it works, please post to the list to reflect this.  My 
experience as an administrator tells me with a 99% certainty that this is 
your problem.

regards
Markus
 

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


Re: [PHP] something like an SID

2004-09-15 Thread Chris Dowell
Try this:
http://uk.php.net/output_add_rewrite_var
Dennis Gearon wrote:
You make a good point, Marek. They CAN open a new window with 
different results. Maybe it's up to each page to keep track of where 
it is at, via form elements alone, instead of through session values. 
Hadn't thought of that, but it must be the only way. Adding and extra 
layer to that might end up being really confusing to programmers for 
my site.

The values for previous forms could just be sent as hidden 
elements(and not kept in the session), until the whole thing is 
collected, then they are all qualified again.

The only thing in the session would be the user's id.
Marek Kilimajer wrote:
Dennis Gearon wrote:
I'd like a value to be passed back from every page, if that page was 
originally passed that value.

The two ways that I can think of it, are:
1/ Javascript with some sort of 'onSubmit()' function which causes a 
minimal form to be submitted via POST or GET
2/ A hidden form value, and make every action on a page be a button, 
which submits a form as above.

3. Define your SID value:
$SID = isset($_REQUEST['var_name']) ? 'var_name=' . 
urlencode($_REQUEST['var_name']) : '';
Write every link as href=page.php??php echo $SID; ?
Something similar for forms.

If no value was received, it would know it was a first access.
NO, I don't think Sessions will do it - I will use this value IN 
PARALELL to Sessions.
NO, I don't think Cookies will do it, since I want the value to be 
different for each
   browser instance and each 'TAB' in each browser instance.

You will fail. User can use right click to open any link in a new 
window and the value will stay the same.

Someone tell me if I'm on the right track, and point me to a link 
that shows how to do:

   My idea 1,
My idea 2,
   or your idea?


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


Re: [PHP] Capturing an Image of a web page

2004-09-15 Thread Chris Dowell
You can try this:
http://open.thumbshots.org/image.pxf?url=http://www.php.net
But I'm not sure how useful it will be to you - it's a database of 
thumbnails, not a tool to dynamically generate them.

[EMAIL PROTECTED] wrote:
Has anyone run across a tool available to PHP that can render an image of
a
entire webpage from a URL, so that it can be reduced to a thumbnail and
stored in a database?
   

I'm sure this has been discussed and solved on/in TheList (Evolte) but
I've just searched the archive and not found it. Probably the solution
wasn't PHP tho, but at least it was automated. Anyway .. you could join
theList and ask there.
Cheers
J
 

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


Re: [PHP] php - no results - display other message

2004-09-15 Thread Chris Dowell
Or alternatively
$result = mysql_query(SELECT * FROM tablename);
if (mysql_num_rows($result))
{
 while ($row = mysql_fetch_row($result))
 {
   // display results
 }
}
else echo No results;
Hope this helps
Cheers
Chris
John Nichel wrote:
Dustin Krysak wrote:
Hi there... I have a simple search page (mysql database), and I can 
get it to display the results no issues, but i was wondering how I 
could display a message stating there were no results, instead of 
just having the field blank. I am familiar with IF and ELSE 
statements, but I am not sure how to test the no result option from 
the results of a SQL query

thanks!
d
Depends on how you're recieving your results...
function doSearch ( $string ) {
$sql = SELECT *.blah, blah
more code;
if ( $result = 
return $result;
} else {
return false;
}
}
if ( $search = doSearch ( $terms ) ) {
// display results
} else {
// display no results found
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Removing strange chars from array (or string)

2004-09-15 Thread Chris Dowell
Zoran
Sounds like your problem is with line endings - your unix (i presume) 
box ends its lines with a newline (\n)

Windows ends lines with a carraige return followed by a newline (\r\n or 
CRLF)

Notepad doesn't recognise a newline on its own as either a valid 
character or a valid line ending, so it displays it as a box

Wordpad is slightly cleverer from the sound of things, and correctly 
interprets your newline characters

trim() probably won't help because it only trims whitespace from the 
ends of the string - it won't strip it from the middle

if you're building up your output line by line, try trim()ming it line 
by line

otherwise you might want to look into regexes to strip repeated newlines
Cheers
chris
Zoran Lorkovic wrote:
Hi
Well, when parsing html page data I want to save is saved in txt file. But when saving 
in txt file I got some strange chars like small square (this I see when open in 
NotePad).
When I try to open in WordPad this strange chars (squares) are recognized as new lines 
so in my file I got many empty lines.
I've try to trim array (string) before saving to file but that didn't help (tried with 
trim, ltrim and rtrim).
Am I missing something?
Regards,
Zoran
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] something like an SID

2004-09-15 Thread Chris Dowell
Perhaps it's something Freudian to do with your chequered past
Just a thought :)
John Holmes wrote:
Subject: Re: [PHP] something like an SID

Anyone else read that as something like an STD ?? and thought we were 
getting more spam to the list!?!? ;)

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


Re: [PHP] mysql_connect does not connect

2004-09-14 Thread Chris Dowell
Sam
Your problem probably does stem from the extension not being installed.
You say you're using (IIRC) mySQL 4.1
This requires you to use the mysqli extension, not the mysql extension
As you're on windows, it's probably just a case of uncommenting the
extension=php_mysqli.dll
line in your php.ini, but I'm not sure as I don't have much experience 
configuring PHP for windows.

Anyway - as far as I can tell from what you've said, that's likely to be 
your problem - your timeout is occurring because the mysql extension 
cannot connect, not because of any firewall issues.

From the manual entry on MySQL (http://www.php.net/mysql):
This MySQL extension doesn't support full functionality of MySQL 
versions greater than 4.1.0. For that, use MySQLi.
If you then look at the entry for MySQLi (http://www.php.net/mysqli), 
you'll see this:

The mysqli extension allows you to access the functionality provided 
by MySQL 4.1 and above.
Then this page 
(http://www.php.net/manual/en/install.windows.extensions.php) about 
installing extension on windows should get you the rest of the way.

Cheers
Chris
Sam Hobbs wrote:
Jason Davidson [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 

Also, a google on the error returns hundreds of results..
http://www.google.ca/search?hl=enie=UTF-8q=Can%27t+connect+to+++MySQL+server+on+%27localhost%27+%2810061%29btnG=Searchmeta=
   


Yes, I could have searched more first. And yes, that search does get an 
abundance of results. However I see no solutions relevant to my problem. 
Many of the solutions say things such as that the extension is not installed 
or that MySQL is not installed.

Many (close to half I think) of the results are pages that have the error, 
so the abundance of results indicates it is a prevalent problem that is 
often not easily solved.

 

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


Re: [PHP] [PHP-GEN] Check Boxes

2004-09-10 Thread Chris Dowell
Try something along these lines:
...
Date: input type=checkbox name=columns[] value=date /
Time: input type=checkbox name=columns[] value=time /
Cost: input type=checkbox name=columns[] value=cost /
Colour: input type=checkbox name=columns[] value=colour /
...
?php
...
mysql_query(SELECT  . implode(',', $_REQUEST['columns']) .  FROM 
tablename);

...
?
This should product a query like
SELECT date,time,colour FROM tablename;
And it's a lot neater than writing a huge chunk of code to generate your 
column list when a little judicious use of built in functions can do it 
all for you.


Cheers
Chris

Gryffyn, Trevor wrote:
You got it right, except you're going to have it blow up on you if
someone doesn't select something
Try these changes:
$a1 = $_POST['ch1'];
$a2 = $_POST['ch2'];
$a3 = $_POST['ch3'];
# Add this bit
If (isset($_POST['ch1')) {
 $collist .= ,$a1;
}
If (isset($_POST['ch2')) {
 if ($collist == ) {
   $collist = $a2;
 } else {
   $collist .= ,$a2;
 }
}If (isset($_POST['ch3')) {
 if ($collist == ) {
   $collist = $a3;
 } else {
   $collist .= ,$a3;
 }
}
# Make slight changes here
if ($collist  ) {
 $query = SELECT $collist FROM form;
 [EMAIL PROTECTED] ($query);
}
Enter_Dateinput type=checkbox name=ch1 value=Enter_Date
Opening_Unitsinput type=checkbox name=ch2 value=Opening_Units
Unit_Consumedinput type=checkbox name=ch3 value=Unit_Consumed

 

-Original Message-
From: balwantsingh [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 18, 2004 5:33 AM
To: [EMAIL PROTECTED]
Subject: [PHP] [PHP-GEN] Check Boxes

balwantsingh wrote:
   

can somebody advise me
i want to use checkboxes on my website, i want that if user 
 

selects some
   

checkboxes (there will be more than 20 checkboxes), 
 

checkbox's value will
be
   

stored in variables and than SELECT query command will be 
 

run using these
   

variables through PHP.  but my problem is that in SELECT 
 

query command
after
   

each column name comma (,) is required and if i use the 
 

same than it is
   

displaying  You have an error in your SQL syntax near 
 

'FROM form' at line
   

1
 

i am using following coding
$a1 = $_POST['ch1'];
$a2 = $_POST['ch2'];
$a3 = $_POST['ch3'];
if ($a1 or $a2 or $a3) {
$query = SELECT $a1, $a2, $a3 FROM form;
[EMAIL PROTECTED] ($query);
}
Enter_Dateinput type=checkbox name=ch1 value=Enter_Date
Opening_Unitsinput type=checkbox name=ch2 value=Opening_Units
Unit_Consumedinput type=checkbox name=ch3 value=Unit_Consumed

balwant
--
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] Array inside Class

2004-09-10 Thread Chris Dowell
From the manual:
In PHP 4, only constant initializers for var variables are allowed. To 
initialize variables with non-constant values, you need an 
initialization function which is called automatically when an object 
is being constructed from the class. Such a function is called a 
constructor (see below).

Cheers
Chris
dirk wrote:
Hello everybody,
can anyone explain to me, why I can't resize an array inside a class?
Sample Code:
?php
class Liste {
  var $input = array (1,2,3);
  var $input2 = array_pad ($input,10, 1);
}
?
Output: 
Parse error: parse error, unexpected '(', expecting ',' or ';' in
/srv/www/htdocs/stundenplan/stpoo.php on line 4

Thanks,
Dirk
 

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