[PHP] Performance

2001-12-13 Thread René Fournier

Is it true that mixing HTML and PHP--switching back and forth with 
?php ?  tags--slows down performance? (I'm using PHP4.) Is it better 
to echo output than to drop out of PHP mode?

And concerning database connections, my ISP asks that I always close a 
MySQL connection with a mysql_close()--which I can understand. But I'm 
curious, if I have to make, say, 10 SELECTs throughout a page (in the 
header, body, and footer), is it perhaps faster to use the mysql_close() 
at the very end of the page (in the bottom of the footer.inc)? In other 
words, is there any disadvantage performance-wise (or stability reason) 
to open and immediately thereafter close mysql connections?

Can anyone recommend an article or two on coding techniques for 
improving PHP and MySQL performance? I don't wan to spend the rest of my 
life optimizing my php code, but if I knew a few basic rules about its 
performance characteristics, I might be able to make better decisions 
when coding. Thanks.

...Rene

---
René Fournier,
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Is PHP up to task?

2001-12-14 Thread René Fournier

(Now that I have your attention... :-)

Here's the situation: All the navigational buttons in the site I'm 
working on have three different states (for mousovers--normal, 
mouseover, onClick). What I don't like: When I mouse over one button, it 
takes a second or two for the page to fetch the mouseover state of the 
button from the server. Now, normally, I would just write a 
preloadimages() function in JavaScript and preload all the button states 
when the pages load. BUT, this is a little harder, since this is a 
fairly big site (or will be) and it's not always the same buttons that 
need to be loaded; they can change from page to page (say, between 
sections, with subnav bars). That being said, I've kept one thing 
simple: All the buttons (and their states) are stored in the same 
directory, and in fact only button images are in that directory (/nav).

So here's what I would like to know: Is it possible for PHP to read the 
contents of a directory--all the files--and then take that array and 
generate some javascript preload() statements? (Of course, I'm sure it 
IS possible, but I would appreciate any pointers you might have before I 
undertake it. Maybe there's even a better way than what I can see!) What 
I was thinking was to preload all the nav buttons and their states in 
the header.inc.

Thanks.

...Rene

---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is PHP up to task?

2001-12-15 Thread René Fournier

What you're saying makes sense--that loading ALL the nav button images 
for the whole site at once is overkill. In this case, however, it really 
isn't, since there are just to 'sets' of nav buttons--the top-level set, 
which needs to be preloaded no matter what page the user is on; and the 
products subsection set, which SHOULD be preloaded, because every visit 
will inevitably visit that section (it is the reason why any visits the 
site). I agree that if there were numerous sub-level 'sets' of nav 
button images, that loading all of them would be inefficient.

...Rene

On Saturday, December 15, 2001, at 02:08  AM, Charles Williams wrote:


 - Original Message -
 From: René Fournier [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Saturday, December 15, 2001 1:27 AM
 Subject: [PHP] Is PHP up to task?


 (Now that I have your attention... :-)

 Here's the situation: All the navigational buttons in the site I'm
 working on have three different states (for mousovers--normal,
 mouseover, onClick). What I don't like: When I mouse over one button, 
 it
 takes a second or two for the page to fetch the mouseover state of the
 button from the server. Now, normally, I would just write a
 preloadimages() function in JavaScript and preload all the button 
 states
 when the pages load. BUT, this is a little harder, since this is a
 fairly big site (or will be) and it's not always the same buttons that
 need to be loaded; they can change from page to page (say, between
 sections, with subnav bars). That being said, I've kept one thing
 simple: All the buttons (and their states) are stored in the same
 directory, and in fact only button images are in that directory 
 (/nav).

 So here's what I would like to know: Is it possible for PHP to read the
 contents of a directory--all the files--and then take that array and
 generate some javascript preload() statements? (Of course, I'm sure it
 IS possible, but I would appreciate any pointers you might have 
 before I
 undertake it. Maybe there's even a better way than what I can see!) 
 What
 I was thinking was to preload all the nav buttons and their states in
 the header.inc.

 Thanks.

 ...Rene

 Rene,

 Of course this is possible.  However, I doubt if it is desirable.  The 
 more
 visitors to your site the larger the load if you load all the graphics,
 because each session would have it's own copy of all the graphics.  It 
 would
 be better if you checked the page being loaded and passed a list of the
 needed graphics needed to a function that would load ONLY those graphics
 needed for said page.  This is not too very difficult and if run on a 
 PHP
 caching server then the overhead is not so bad.  The hard part is 
 getting
 the JS to work correctly (at least for me. hehe. I suck at JS).

 For example. http://clans.acnsnet.com is a package I'm working on that 
 uses
 templates to control the layout.  Each menu item is stored in an SQL 
 backend
 as well as the Template info (location, menu type, state, etc).  I
 already have a function to determine what page is active.  So finding 
 out
 what menu items are visible is simply a matter of comparing the active 
 page
 to the array of menu items.  I can then determin which images I would 
 need
 to load (depending on the template in use).  This way I only load the 
 images
 that are needed, which saves on load time and memory.

 Anyway, have fun.

 chuck


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] OSX Migration Problem

2002-01-16 Thread René Fournier

After some trial and [much] error, I finally have the latest version of 
PHP (4.0.6??) and MySQL running under Mac OSX 10.1.2. And they seem to 
be working... sort of.

The only problem is when I try to load some pages that use the PHP 
Session ID function. Now, these exact pages--the whole site in fact--is 
already running without incident on my ISP (FatCow), and has been for a 
while. So I figure there must be a configuration issue to deal with. In 
any case, here are the errors when the page loads (and that's also 
interesting, it does load). If any of you can shed light on this, I 
would very much appreciate it. Thanks.


Warning: Cannot send session cache limiter - headers already sent 
(output started at 
/Users/rene/Sites/smartslitters/jupiter/europa/header.inc:6) in 
/Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 19

Warning: Unable to save MySQL query result in 
/Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 44

Warning: Supplied argument is not a valid MySQL result resource in 
/Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 45
---

...Rene

--
René Fournier


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Mac OSX !?!?!?

2002-01-16 Thread René Fournier

Can someone PLEASE explain why I get the following error message under 
OSX (PHP+MySQL), but not under Windows ME or Linux?


Warning: Cannot send session cache limiter - headers already sent 
(output started at 
/Users/rene/Sites/smartslitters/jupiter/europa/header.inc:6) in 
/Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 19

Warning: Unable to save MySQL query result in 
/Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 44

Warning: Supplied argument is not a valid MySQL result resource in 
/Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 45
---

After these lines, the pages load fine. I'm using PHP Session ID 
variables (or trying to)--they work fine as I said under other OSes, but 
now break under OSX.

...Rene

---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Mac OSX !?!?!?

2002-01-16 Thread René Fournier

Somebody suggested I post the source--good idea! So here it is... The 
header.inc file, in its entirety:


html
head
titleSite :: Jupiter :: Europa/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
link rel=stylesheet href=../../common/styles.css type=text/css
?php

// DETERMINE THE LANGUAGE FROM THE PARENT DIRECTORY
// GENERATE VARIABLES FOR LANGUAGE, FILENAME AND NAME

$path = explode(/,$PHP_SELF);
if (!$lang) { $lang = $path[sizeof($path)-2]; }
$file = $path[sizeof($path)-1];
$prename = explode(.,$file);
$name = $prename[sizeof($prename)-2];

// SECURITY CHECK

session_start();
if (!$PHPSESSID) { die;
} elseif (!$auth) { die;
} elseif ($auth != $path[sizeof($path)-2]) { die; }

$language = All Languages;
if ($lang == en) { $language = English; }
if ($lang == fr) { $language = FranÁais; }
if ($lang == es) { $language = EspaÒol; }
if ($lang == de) { $language = Deutsch; }
if ($lang == it) { $language = Italiano; }

$priv = 2;

// CONNECT TO DATABASE

$db = mysql_connect(localhost,database,password);
mysql_select_db(database,$db);

// FETCH TABLE NAMES

$listtables = mysql_list_tables(database,$db);

// FETCH SELECTED TABLE DATA

$fields = mysql_list_fields(database, $table, $db);
$columns = mysql_num_fields($fields);

?
script language=JavaScript
!--
function GP_popupConfirmMsg(msg) { //v1.0
   document.MM_returnValue = confirm(msg);
}
//--
/script
/head

body bgcolor=#FF text=#00 link=#00 vlink=#00 
alink=#00 leftmargin=20 topmargin=20 marginwidth=0 
marginheight=0 background=../../common/bg.gif
?php
if ($language) { echo span class=adminnormalgreya 
href=../index.php4Europa/a/span; }
if ($table) { echo span class=adminnormalgrey : /spanspan 
class=adminnormalgreya href=tables.php4Tables/a/span; }
?
pnbsp;


On Wednesday, January 16, 2002, at 06:01  PM, Richard Baskett wrote:

 Kind of hard to say without source code for the session part..  
 Although the
 MySQL warnings, I got those because MySQL does not automatically start 
 in
 OSX, if you know it's started then Im not sure, but if not.. go here to 
 get
 the autostart utility:

 http://www.entropy.ch/software/macosx/mysql/

 This link will have information and a link of where you can download the
 utility.

 Rick


 The human mind is not capable of grasping the Universe. We are like a
 little child entering a huge library. The walls are covered to the 
 ceilings
 with books in many different tongues. The child knows that someone must 
 have
 written these books. It does not know who or how. It does not 
 understand the
 languages in which they are written. But the child notes a definite 
 plan in
 the arrangement of the books---a mysterious order which it does not
 comprehend, but only dimly suspects. - Albert Einstein

 From: René Fournier [EMAIL PROTECTED]
 Date: Wed, 16 Jan 2002 17:50:06 -0700
 To: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: [PHP] Mac OSX !?!?!?

 Can someone PLEASE explain why I get the following error message under
 OSX (PHP+MySQL), but not under Windows ME or Linux?

 
 Warning: Cannot send session cache limiter - headers already sent
 (output started at
 /Users/rene/Sites/smartslitters/jupiter/europa/header.inc:6) in
 /Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 19

 Warning: Unable to save MySQL query result in
 /Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 44

 Warning: Supplied argument is not a valid MySQL result resource in
 /Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 45
 ---

 After these lines, the pages load fine. I'm using PHP Session ID
 variables (or trying to)--they work fine as I said under other OSes, 
 but
 now break under OSX.

 ...Rene

---
René Fournier
[EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: php-list-
 [EMAIL PROTECTED]



 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail mysql-unsubscribe-
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Mac OSX !?!?!?

2002-01-16 Thread René Fournier

Somebody suggested I post the source--good idea! So here it is... The 
header.inc file, in its entirety:


html
head
titleSite :: Jupiter :: Europa/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
link rel=stylesheet href=../../common/styles.css type=text/css
?php

// DETERMINE THE LANGUAGE FROM THE PARENT DIRECTORY
// GENERATE VARIABLES FOR LANGUAGE, FILENAME AND NAME

$path = explode(/,$PHP_SELF);
if (!$lang) { $lang = $path[sizeof($path)-2]; }
$file = $path[sizeof($path)-1];
$prename = explode(.,$file);
$name = $prename[sizeof($prename)-2];

// SECURITY CHECK

session_start();
if (!$PHPSESSID) { die;
} elseif (!$auth) { die;
} elseif ($auth != $path[sizeof($path)-2]) { die; }

$language = All Languages;
if ($lang == en) { $language = English; }
if ($lang == fr) { $language = FranÁais; }
if ($lang == es) { $language = EspaÒol; }
if ($lang == de) { $language = Deutsch; }
if ($lang == it) { $language = Italiano; }

$priv = 2;

// CONNECT TO DATABASE

$db = mysql_connect(localhost,database,password);
mysql_select_db(database,$db);

// FETCH TABLE NAMES

$listtables = mysql_list_tables(database,$db);

// FETCH SELECTED TABLE DATA

$fields = mysql_list_fields(database, $table, $db);
$columns = mysql_num_fields($fields);

?
script language=JavaScript
!--
function GP_popupConfirmMsg(msg) { //v1.0
   document.MM_returnValue = confirm(msg);
}
//--
/script
/head

body bgcolor=#FF text=#00 link=#00 vlink=#00 
alink=#00 leftmargin=20 topmargin=20 marginwidth=0 
marginheight=0 background=../../common/bg.gif
?php
if ($language) { echo span class=adminnormalgreya 
href=../index.php4Europa/a/span; }
if ($table) { echo span class=adminnormalgrey : /spanspan 
class=adminnormalgreya href=tables.php4Tables/a/span; }
?
pnbsp;


On Wednesday, January 16, 2002, at 06:01  PM, Richard Baskett wrote:

 Kind of hard to say without source code for the session part..  
 Although the
 MySQL warnings, I got those because MySQL does not automatically start 
 in
 OSX, if you know it's started then Im not sure, but if not.. go here to 
 get
 the autostart utility:

 http://www.entropy.ch/software/macosx/mysql/

 This link will have information and a link of where you can download the
 utility.

 Rick


 The human mind is not capable of grasping the Universe. We are like a
 little child entering a huge library. The walls are covered to the 
 ceilings
 with books in many different tongues. The child knows that someone must 
 have
 written these books. It does not know who or how. It does not 
 understand the
 languages in which they are written. But the child notes a definite 
 plan in
 the arrangement of the books---a mysterious order which it does not
 comprehend, but only dimly suspects. - Albert Einstein

 From: René Fournier [EMAIL PROTECTED]
 Date: Wed, 16 Jan 2002 17:50:06 -0700
 To: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: [PHP] Mac OSX !?!?!?

 Can someone PLEASE explain why I get the following error message under
 OSX (PHP+MySQL), but not under Windows ME or Linux?

 
 Warning: Cannot send session cache limiter - headers already sent
 (output started at
 /Users/rene/Sites/smartslitters/jupiter/europa/header.inc:6) in
 /Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 19

 Warning: Unable to save MySQL query result in
 /Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 44

 Warning: Supplied argument is not a valid MySQL result resource in
 /Users/rene/Sites/smartslitters/jupiter/europa/header.inc on line 45
 ---

 After these lines, the pages load fine. I'm using PHP Session ID
 variables (or trying to)--they work fine as I said under other OSes, 
 but
 now break under OSX.

 ...Rene

---
René Fournier
[EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: php-list-
 [EMAIL PROTECTED]



 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail mysql-unsubscribe-
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Must results from MySQL fetches always be an Array??

2002-01-25 Thread René Fournier

This is sort of a is there an easier/better way kind of question. No 
error or problem, but I'd like to know how others handle it.

I'm fetching single elements of data from several tables, then piecing 
it together. Here's an example of one element I need to fetch:

$series = mysql_fetch_array(mysql_query(SELECT key2 FROM models WHERE 
lang='$lang' AND recordname='$model',$db));

Now I realize that with this function $series will always be an array, 
even if it contains just one element (which it does). What I'd like to 
know is, can I write that statement so that $series is created just as a 
string? (So that I don't have to write $series = $series[0]; 
immediately afterwards in order to treat $series as a $string.)

...Rene

---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Can I be an ASP with PHP?

2002-06-20 Thread René Fournier

I have a question to which I'm pretty sure the answer will be no, but 
I would like to hope I'm wrong...

I've developed a very simple Content Management tool--called 
Europa--that even retarded monkeys can use to change/update text in 
their web site. It's web-based, user-authenticated (sessions), and runs 
with PHP4 and MySQL.

Now, Europa is pretty much plug and play, so long as the web site is 
getting its text from a MySQL database. There's a web agency in town 
that is interested in Europa for their clients. Their clients want to be 
able to easily and quickly update certain elements of their site without 
begging some outside webmaster. They would really benefit from Europa.

Problem: I don't want to sell Europa, or even install it on someone's 
web server for a one-time fee. I've spent a long time on this little 
tool, and want to continue to improve it. So, I would rather license it 
to companies. They pay a quarterly subscription fee, and get to use 
Europa as it continues to grow and improve.  I'm just a little worried 
about one thing: If I install Europa on their server, and they pay their 
paltry quarterly subscription fee, and then decide they don't need any 
updates, I'm screwed. The value of Europa is much greater than what I 
want to sell subscriptions to it for (not much--I'm not really greedy), 
but I need some kind of control.

The idea: In order for Joe User to update text on his web site, he comes 
to my Europa web site, enters his company name, user ID, password, and 
clicks Login, and--voilà--he sees a handsome list of tables containing 
the text content of his site--which is pulled from a MySQL database 
residing on HIS web site's web host.

And this is the trick: Can PHP somehow fetch MySQL data over the 
Internet? Is this possible? If so, is it necessary for me to resort to 
new, unknown technologies like XML or SOAP, or can I do it with PHP 
alone?

Thanks for your comments.

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




[PHP] Convert a grayscale value to a #RRGGBB hex value

2002-06-24 Thread René Fournier

Anyone know how I might convert a grayscale value, from between 0 to 
100, to hex, such that 0 (black) would be returned as #00, and 100 
(white) as #FF? For example...

function grayscaletohex ($val) {
$hex = $val ... [ a simple operation ]
return $hex;
}

Thanks.

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




[PHP] Convert a grayscale value to a #RRGGBB hex value

2002-06-24 Thread René Fournier

Anyone know how I might convert a grayscale value, from between 0 to 
100, to hex, such that 0 (black) would be returned as #00, and 100 
(white) as #FF? For example...

function grayscaletohex ($val) {
$hex = $val ... [ a simple operation ]
return $hex;
}

Thanks.

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




[PHP] Annoying syntax problem with RTRIM

2002-07-04 Thread René Fournier

echo rtrim($feat,, );

On my local Apache-OSX web server (PHP 4.1.2), this command works fine.
(The reason I use it is that sometimes $feat contains a comma and a 
space at the end of the string, which I want to remove (if it's there) 
before echoing.)

When this same script is run on my ISP (PHP 4.0.6), I get the following 
error message:

bWarning/b:  Wrong parameter count for rtrim() in 
b/u/htdocs/smarts/jupiter/callisto/include/create.inc/b on line 
b216/bbr


Any ideas why?

Thanks.

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




Re: [PHP] Annoying syntax problem with RTRIM

2002-07-04 Thread René Fournier

I did. It didn't help. (That's why I posted this message.)

On Thursday, July 4, 2002, at 10:47  AM, Jason Wong wrote:

 On Friday 05 July 2002 00:41, René Fournier wrote:
 echo rtrim($feat,, );

 On my local Apache-OSX web server (PHP 4.1.2), this command works fine.
 (The reason I use it is that sometimes $feat contains a comma and a
 space at the end of the string, which I want to remove (if it's there)
 before echoing.)

 When this same script is run on my ISP (PHP 4.0.6), I get the following
 error message:

 bWarning/b:  Wrong parameter count for rtrim() in
 b/u/htdocs/smarts/jupiter/callisto/include/create.inc/b on line
 b216/bbr


 Any ideas why?

 RTFM!

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

 /*
 The heart is wiser than the intellect.
 */


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



---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




Re: [PHP] Annoying syntax problem with RTRIM

2002-07-04 Thread René Fournier

Actually I did see the 4.1.0, but mis-read it thinking 4.0.1  (I 
did read the manual, just not carefully enough. (Thank you, Mr. Wong, 
for your helpful reply.))

Anyways, I came up with a workaround until my ISP upgrades PHP:

$str = rtrim($str);
if (substr($str,-1) == ,) { $str = substr($str,0,-1); }

Seems to work okay.

...Rene

On Thursday, July 4, 2002, at 01:45  PM, Paul Roberts wrote:

 string rtrim ( string str [, string charlist])

 Note: The second parameter was added in PHP 4.1.0
 
 ^hint
 get them to upgrade php for you.

 Paul Roberts
 [EMAIL PROTECTED]
 
 - Original Message -
 From: René Fournier [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, July 04, 2002 6:00 PM
 Subject: Re: [PHP] Annoying syntax problem with RTRIM


 I did. It didn't help. (That's why I posted this message.)

 On Thursday, July 4, 2002, at 10:47  AM, Jason Wong wrote:

 On Friday 05 July 2002 00:41, René Fournier wrote:
 echo rtrim($feat,, );

 On my local Apache-OSX web server (PHP 4.1.2), this command works 
 fine.
 (The reason I use it is that sometimes $feat contains a comma and a
 space at the end of the string, which I want to remove (if it's there)
 before echoing.)

 When this same script is run on my ISP (PHP 4.0.6), I get the 
 following
 error message:

 bWarning/b:  Wrong parameter count for rtrim() in
 b/u/htdocs/smarts/jupiter/callisto/include/create.inc/b on line
 b216/bbr


 Any ideas why?

 RTFM!

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

 /*
 The heart is wiser than the intellect.
 */


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



---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


 --
 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] Storing images in MySQL bad idea, performance-wise?

2002-07-08 Thread René Fournier

I'm working on a simple content management system that uses PHP and 
MySQL for updating a web site's text (stored in a MySQL database). (The 
PHP scripts that do the updating (my stuf) live on one web server, the 
actual DB data to be updated (my client's stuff) live on another.) So 
far, I've only had to he able to update the text content of a 
site--therefore, I've only had to bother to store textual data in the 
client's DB. But now the client wants to be able to upload/change/delete 
certain pictures on their web site--using my CMS tool--so I am faced 
with the following problem:

Do I store all such images in the DB? (Which I understand reduces 
performance.)

Or do I--somehow--store the images as files on the client's web server? 
And if so, how? (Because my PHP scripts are being executed on a 
different server.)

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




[PHP] Re: Images in Mysql

2002-07-10 Thread René Fournier

Hi Asaf,

Thanks for the advice. That sounds like a good solution. One thing I was 
wondering about is...  when my PHP script saves the uploaded image to 
the web server, how should the image be named [uniquely]? The problem is 
that if the user specifes the name of the image file, there's a chance 
he'll name another one the same way (and thus overwrite the original). I 
was thinking of maybe a dual approach, where the user gives the image 
file a name, but then the PHP script appends, say, the table name and 
record ID--so as to make the filename unique.

What do you think? Is that how you do it? (Or is there a better way??)

...Rene


On Wednesday, July 10, 2002, at 07:34  AM, Asaf Maruf Ali wrote:

 Hello Rene

 We used a similar approach albeit both our PHP scripts and data were on 
 the
 same server. We however opted to place html links to the images in the 
 MySQL
 db and actual images (GIF's, JPG's)files on the server harddisk.

 It works fine with no performance issues.


 Hope this helps

 Regards
 Asaf Maruf
 PING


 I'm working on a simple content management system that uses PHP and
 MySQL for updating a web site's text (stored in a MySQL database). (The
 PHP scripts that do the updating (my stuf) live on one web server, the
 actual DB data to be updated (my client's stuff) live on another.) So
 far, I've only had to he able to update the text content of a
 site--therefore, I've only had to bother to store textual data in the
 client's DB. But now the client wants to be able to upload/change/delete
 certain pictures on their web site--using my CMS tool--so I am faced
 with the following problem:

 Do I store all such images in the DB? (Which I understand reduces
 performance.)

 Or do I--somehow--store the images as files on the client's web server?
 And if so, how? (Because my PHP scripts are being executed on a
 different server.)

 ...Rene

 ---
 René Fournier,
 [EMAIL PROTECTED]



 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.361 / Virus Database: 199 - Release Date: 5/7/02



---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




[PHP] good article on creating a subscription form/script

2002-07-12 Thread René Fournier

I've looked on php.net, phpbuilder.com, and zend.com, but to no avail. 
Any suggestions?

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




[PHP] GD Graphics Library

2002-08-29 Thread René Fournier

There are several functions in the GD library that I really, really 
want to be able to use on several sites that I develop/manage. 
Unfortunately, the ISP I use, FatCow, doesn't have GD, nor seems 
interested in adding it.

Can anyone recommend a good, cheap ISP (like FatCow) that DOES have GD 
for PHP4? (Or better yet, do you have any suggestions as to how I might 
persuade FatCow to add it??

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




[PHP] How to do a dynamic UPDATE SET

2001-10-01 Thread René Fournier

I'm having a REALLY hard time with something that's probably easy to do (for
someone :-)...

Normally, to perform an update on a table with data from a submitted form, I
would use something like:

  $sql = UPDATE $table SET pet='$pet', name='$name' WHERE id=$id;
  $result = mysql_query($sql);

And it would work.  Of course, if I wanted to update a different table (with
different columns/fields), I would need to only change the SET part of the
SQL (since the value for $table is dynamically generated). For example,

  $sql = UPDATE $table SET car='$car', year='$year' WHERE id=$id;
  $result = mysql_query($sql);

But here's what I want to do now:  I want to use the same two lines of code
for any possible form data that might be submitted--in other words, I don't
want to have to create unique $sql/$result lines for each and every table in
my database.  I want this .php code to accept whatever number and type of
form elements/data submitted, and make the appropropriate SET values.
Anyone know how I can do that?  I actually have tried several things to pass
the form data strcuture (number and names of columns) over to this php code,
but haven't been able to get anything working.  Can anyone help??  Much
thanks if you can..

...Rene

---
Rene Fournier


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] How to do a dynamic UPDATE SET

2001-10-01 Thread René Fournier

Nope, still no go.  Removing the single quotes stops PHP from updating the
fields with $set's literal $fieldname, but still doesn't update the record
with the value (or anything).

===
CODE
===
if ($submit) {
// if there is an ID, then it's an update
  if ($id) {
  $comma = ;
for ($i = 1; $i  $columns; $i++) {
  $fld = mysql_field_name($fields, $i);
  $set .= $comma.$fld=$.$fld;
  $comma = , ;
  }
  $set .=  ;

  echo $set, p;

  // run SQL against the DB
  $sql = UPDATE events SET what=$what WHERE id=$id;
  echo $sql, p;
  $result = mysql_query($sql);
   }
   echo span class=adminnormalRecord updated;
}
===
OUTPUT
===
lang=$lang, record=$record, date=$date, what=$what, link=$link,
location=$location, details=$details

UPDATE events SET lang=$lang, record=$record, date=$date, what=$what,
link=$link, location=$location, details=$details WHERE id=1

Record updated
===


...Rene

---
Rene Fournier
[EMAIL PROTECTED]

 -Original Message-
 From: Vincent [mailto:[EMAIL PROTECTED]]
 Sent: Monday, October 01, 2001 5:49 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP] How to do a dynamic UPDATE SET


 | The result:  PHP updates the values of lang, record, date, what
 (etc.) to
 | [LITERALLY] $lang, $record, $date, etc--NOT the values of those fields
 | submitted by the form.  I'm kinda lost as to what to do...  Any
 | suggestions??

 Ow yea, little mistake of mine, sorry.
 I think removing the single quotes should do the trick.

 Vincent


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Pesky quotes

2001-10-03 Thread René Fournier

A little problem with single quotes messing up an SQL SET statement...

I can type single quotes, double quotes--it seems, any 'special'
character--into a form, and so long as my PHP script tries to INSERT, UPDATE
or DELETE said row into the table, no problem.  But when I try to DUPLICATE
a row that already contains a single quote, the PHP code chokes on it--and
doesn't perform the query operation.  I realize that the code that does the
preprocessing is getting confused by any stray single quote (double quotes
are harmless).  What I don't know is how to get around this problem.  Here's
the code in question:

---
// DUPLICATE
   if ($action == dup) {

$result = mysql_query(SELECT * FROM $table WHERE id=$id,$db);
$myrow = mysql_fetch_array($result);

$comma = ;
echo $priv, br;
for ($i = $priv; $i  $columns; $i++) {
$fld = mysql_field_name($fields, $i);
$set .= $comma.$fld='.$myrow[$i].';
echo $set, br;
$comma = , ;
}

  // run SQL against the DB
  $sql = INSERT $table SET $set;
  $result = mysql_query($sql);

   $affected = $id;
   echo td width=10img border=0 src=../../common/spacer.gif width=10
height=1/tdtd align=center valign=middle bgcolor=#eespan
class=adminnormalgreyRecord duplicated/span/td;
}

---
And here's the echo'd $set:
---
lang='en'
lang='en', record='news.php'
lang='en', record='news.php', buttonname='News and Events'
lang='en', record='news.php', buttonname='News and Events', pagetitle='What
is Happening'
lang='en', record='news.php', buttonname='News and Events', pagetitle='What
is Happening', alttext='Breaking news on new SmartSlitter products and
upgrades, plus a list of trade show's where we will be exhibiting our
machines.'
---

Any help is much appreciated. Thanks!

...Rene

---
Rene Fournier
[EMAIL PROTECTED]


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Should I convert special characters before writing them to a table?

2001-10-04 Thread René Fournier

The reason I ask is, I'm having a problem processing rows in a table that
contain single quotes (specifically, the PHP code I wrote that allows the
user to duplicate a row doesn't work if the a field in the row has a single
quote in it).

Would it be better for me to strip out the single quotes before the rows are
written, replacing them with another special [harmless] character, and just
dynamically swapping that character out for the orginal when the row is
displayed?  Any thoughts?  I just started doing this PHP/MySQL thing a
couple weeks ago, and I realize I have a lot to learn.  Any suggestions
would be much appreciated.

Oh, and by the way, here is the PHP code for duplicating rows that fails to
execute when a field in the row it's processing contains a single quote.

=
// DUPLICATE
   if ($action == dup) {

$result = mysql_query(SELECT * FROM $table WHERE id=$id,$db);
$myrow = mysql_fetch_array($result);

$comma = ;

for ($i = $priv; $i  $columns; $i++) {
$fld = mysql_field_name($fields, $i);
$set .= $comma.$fld='.$myrow[$i].';
$comma = , ;
}

  // run SQL against the DB
  $sql = INSERT $table SET $set;
  $result = mysql_query($sql);

   $affected = $id;
   echo td width=10img border=0 src=../../common/spacer.gif width=10
height=1/tdtd align=center valign=middle bgcolor=#eespan
class=adminnormalgreyRecord duplicated/span/td;
}
=

Thanks.

...Rene

---
Rene Fournier
[EMAIL PROTECTED]


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] array to string

2001-10-19 Thread René Fournier

Just trying to convert an array to string before writing the whole thing
back out to a file.  (Trying to do a simple database-less database, using
text files).

$fcontents = file($name..db);  // THE ENTIRE TABLE
$fcontents[$update] = $updatedstring;  // THE ROW TO BE UPDATED
$fp = fopen($name..db, w+);

But before the next line, I need to convert $fcontents to a string, else
just Array gets written to the text file.  I just can't seem to find the
sure-to-be simple command to do this on php.net or phpbuilder.com, etc.  Any
ideas?

fwrite($fp,$fcontents);
fclose($fp);

Thanks.

...Rene

---
Rene Fournier
[EMAIL PROTECTED]


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] SIMPLE, secure user authentication

2001-10-25 Thread René Fournier

I'm looking for a good (simple) tutorial on user authentication.  I want to
create a login system that's secure, but I don't need all the features that
PHPBuilder's A Complete, Secure User Login System scripts provide.  (I
don't need the the user to be able to register or confirm his account,
change his email or password, etc.)  Basically, I can/will set the usernames
and passwords myself via MySQL.  All I want the login system to do is
securely check against the db and then create a session.

That's the other problem.  I'm a little confused about this cookie
creation/session stuff.  Am I correct in assuming that the way it works is
that I should wrap every bit of PHP code around a isUserAuthenticated()
function?

I suppose what I need is a general tutorial on authentication, assuming the
user of cookies, PHP4 and MySql.  Any ideas??  (Thanks.)

...Rene

---
Rene Fournier
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Best [non-PHP] way to redirect a browser

2001-10-26 Thread René Fournier

This is really I guess a non-PHP question, so please excuse...

What is the most reliable, browser-safe way to redirect the browser from a
default index.html to, say, index.php?  The I'm doing it now is with the
following javascript:

script type=text/javascript language=Javascript
document.location=index.php
/script

And it works, but I wanted to know if any of you are using a better [more
compatible] way of redirecting the browser (say, if it doesn't have
JavaScript (!?)).

...Rene

---
Rene Fournier
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Fatcow and MySQL-Front

2001-10-29 Thread René Fournier

Hi All,

Little problem:  I want to transfer my MySQL database--a collection of 10 or
so tables, with data--to my Fatcow account.  They provide some lame MySQL
tools, but nothing to faciliate moving an existing database, full of data,
to their server.  I tried using MySQL-Front to connect to their server, but
it was rejected for some reason (their tech support acknowledged that
MySQL-Front doesn't work with Fatcow (?)).  Can anyone recommend a way for
me to get my database and data onto Fatcow?  I have asked their Tech
Support, but they weren't very supportive...

Much appreciated.

...Rene


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Fatcow and MySQL-Front

2001-10-30 Thread René Fournier

Sorry, stupid question, but how do I load phpMyAdmin onto Fatcow?  Won't
that be as time-consuming as recreating all the tables in my database by
hand, using their lame tools?  (If there is an easy way, please let me know.
Thanks.)

...Rene

 -Original Message-
 From: Nikola Karoviæ [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, October 30, 2001 1:34 AM
 To: best list in da whole world
 Subject: Re: [PHP] Fatcow and MySQL-Front


 Hi,
 can't you do that with phpMyAdmin. If you dont have that on
 fatcow, you can
 put it your self and then load a database file.
 -
 volim popit, volim zagalamit

 - Original Message -
 From: René Fournier [EMAIL PROTECTED]
 To: Php-General [EMAIL PROTECTED]
 Sent: 30. listopad 2001 00:04
 Subject: [PHP] Fatcow and MySQL-Front


  Hi All,
 
  Little problem:  I want to transfer my MySQL database--a
 collection of 10
 or
  so tables, with data--to my Fatcow account.  They provide some
 lame MySQL
  tools, but nothing to faciliate moving an existing database,
 full of data,
  to their server.  I tried using MySQL-Front to connect to their server,
 but
  it was rejected for some reason (their tech support acknowledged that
  MySQL-Front doesn't work with Fatcow (?)).  Can anyone
 recommend a way for
  me to get my database and data onto Fatcow?  I have asked their Tech
  Support, but they weren't very supportive...
 
  Much appreciated.
 
  ...Rene
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Weird caching problem with PHP4/Apache

2001-10-30 Thread René Fournier

Having successfully uploaded my PHP4+MySQL site finally to Fatcow (and the
MySQL stuff IS there--thanks for the help), I'm now left with making it
actually work online.  One curious problem:

For every page in the site (*.php4), I include three parts, a header.inc
(common to all), a body.inc (unique to each .php4 file), and a footer.inc
(common to all).  One of the things the header.inc file does is generate
select a background image randomly.  Very simple, and it works on my local
machine.  But as soon as I look at the page online, it seems Fatcow
(Apache/Zend?)caches the header.inc file--that is, the results of the php
script inside it, which generates the random background.  I say this because
no matter how many pages I look at, refreshing them, etc., I always get sent
the same original background image.  Even if I replace now the random
background image function in header.inc with the explicit name of a
different file, it STILL displays the same one.  Weird?  Is there some way
to ensure that each PHP4 file/script is interpreted every single time, and
not cached (as it seems)??

...Rene


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Re: Weird caching problem with PHP4/Apache

2001-10-30 Thread René Fournier

Thanks for the help, but I'm afraid it hasn't solved the caching problem, at
least not with respect to the PHP random function...  It's not as if the
entire page get's cached, since there is an SQL query that selects a random
row from a table--and that is random.  But the PHP part of it--that is,
where the background image of a table row is randomly selected--is static.
Refreshing doesn't help, nor does this code, which I put in my header.inc
file:

?php
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past
header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  // always modified
header ('Cache-Control: no-cache, must-revalidate');  // HTTP/1.1
header ('Pragma: no-cache');  // HTTP/1.0
?html
head
titleMy Site/title
META HTTP-EQUIV=Expires CONTENT=0
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
link rel=stylesheet href=../common/styles.css type=text/css
script language=JavaScript
!--


You'll notice that I've got both that header function AND a meta tag, each
of which should tell Apache not to cache, but here's what I think is
happening:  Apache is NOT caching, since the SQL select statements are
running randomly.  I think the cache problem is with PHP/Zend, since I'm
using PHP4.  So...  Is there a way to force PHP to reexecute every time
without configuring the server differently (since I can't)??


 -Original Message-
 From: Julio Nobrega Trabalhando
 [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, October 30, 2001 9:31 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: Weird caching problem with PHP4/Apache


   These lines will do what you asked, but I am unsure if they will resolve
 your problem (since I don't know Fatcow and how they configured
 the server).
 Anyway, here it is:


 header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past
 header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
   // always modified
 header ('Cache-Control: no-cache, must-revalidate');  // HTTP/1.1
 header ('Pragma: no-cache');  // HTTP/1.0

   PS: Got it from the manual, header(); function :-)
   Check the online comments if any problems happen, since there are many
 various flavors of servers and clients...

 --

 Julio Nobrega

 A hora está chegando:
 http://toca.sourceforge.net
 René fournier [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Having successfully uploaded my PHP4+MySQL site finally to
 Fatcow (and the
  MySQL stuff IS there--thanks for the help), I'm now left with making it
  actually work online.  One curious problem:
 
  For every page in the site (*.php4), I include three parts, a
 header.inc
  (common to all), a body.inc (unique to each .php4 file), and a
 footer.inc
  (common to all).  One of the things the header.inc file does is generate
  select a background image randomly.  Very simple, and it works
 on my local
  machine.  But as soon as I look at the page online, it seems Fatcow
  (Apache/Zend?)caches the header.inc file--that is, the results
 of the php
  script inside it, which generates the random background.  I say this
 because
  no matter how many pages I look at, refreshing them, etc., I always get
 sent
  the same original background image.  Even if I replace now the random
  background image function in header.inc with the explicit name of a
  different file, it STILL displays the same one.  Weird?  Is
 there some way
  to ensure that each PHP4 file/script is interpreted every
 single time, and
  not cached (as it seems)??
 
  ...Rene
 



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Re: Weird caching problem with PHP4/Apache -- THE SAGA CONTINUES

2001-10-31 Thread René Fournier

Here's what I've got, starting at the top...

==
?php
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past
header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  // always modified
header ('Cache-Control: no-cache, must-revalidate');  // HTTP/1.1
header ('Pragma: no-cache');  // HTTP/1.0
?html
head
titleTitle/title
META HTTP-EQUIV=Expires CONTENT=0
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1

[SNIP]

?php
function randbg() {
$num_of_bgs = 5;
$the_one = rand(1,$num_of_bgs);
echo bg.$the_one..jpg;
}
?

[SNIP]

td valign=top align=left background=../common/images/bg/?php randbg(); ?
==

Here's why I think it's PHP4:  If I look at these pages on my local machine
(WinME, Apache 1.3.20, PHP4.06 module, MySQL 3.23.14 (not that it matters,
right?)), the randbg() function works as it should--I get a random
background image everytime.  But if I look at these EXACT SAME pages on
Fatcow (Linux/Apache, I believe, PHP4...), the randbg() function executes
the first time, then [seemingly] fails to execute again--it never generates
a different, random bakground.  (Or maybe I'm looking at one hell of a
coincidence :-)

So my question is, who is caching what, where?

...Rene


 -Original Message-
 From: Tamas Arpad [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, October 31, 2001 7:24 AM
 To: René Fournier; Hugh Danaher
 Cc: Php-General
 Subject: Re: [PHP] Re: Weird caching problem with PHP4/Apache


 On Wednesday 31 October 2001 14:48, René Fournier wrote:
  Nope, unfortunately, nothing.  It's a really weird problem.  It's
  like the PHP function I wrote for generating the random image will
  only work the first time.
 I think it is not php that caches it. As I undertsand you wrote a
 script that generates an image, and give it back to the browser in an
 img src=... html tag. Am I right?
 I hope I am, so I continue :))
 Images can be cached in many places (proxies, browser), but
 definietly not in php. Your script that generates in the image and
 should be called every time by the img html tag, won't ever called
 again if the previous image were stored somewhere. You should send
 pragma no-cache and other http headers (many posts were on this
 cache headers topic) from the script that generates and gives back
 the image.
 Or another sollution is that you can call your script with a random
 number or better with the current date and time, so you images's name
 won't be the same, and caches can't give back the old image.
 for example:
 ?php echoimg src=\generatebackground.php?x=.date(YmdHis).
 \;?

   Arpi

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Re: Weird caching problem with PHP4/Apache -- THE SAGA CONTINUES

2001-10-31 Thread René Fournier

Yes!  That's it!  I added that srand function, and it works great.  Thanks!

..Rene

 -Original Message-
 From: Tamas Arpad [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, October 31, 2001 10:58 AM
 To: René Fournier
 Cc: Php-General
 Subject: Re: [PHP] Re: Weird caching problem with PHP4/Apache -- THE
 SAGA CONTINUES


 On Wednesday 31 October 2001 18:18, René Fournier wrote:
  Here's what I've got, starting at the top...
 
  ==
  ?php
  header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in
  the past header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . '
  GMT'); // always modified header ('Cache-Control: no-cache,
  must-revalidate');  // HTTP/1.1 header ('Pragma: no-cache');
// HTTP/1.0 ?html
  head
  titleTitle/title
  META HTTP-EQUIV=Expires CONTENT=0
  meta http-equiv=Content-Type content=text/html;
  charset=iso-8859-1
 
  [SNIP]
 
  ?php
  function randbg() {
  $num_of_bgs = 5;
  $the_one = rand(1,$num_of_bgs);
  echo bg.$the_one..jpg;
  }
  ?
 
  [SNIP]
 
  td valign=top align=left background=../common/images/bg/?php
  randbg(); ? ==
 Ah, so you have bg1.jpg, bg2.jpg and so on till 5.
 And want to show one of them selected by a random value?

 So when you click on browser's refresh button, what happens?
 You always get the same page as before with for example bg1.jpg?

 Do you seed the random number generator (srand()) before you use
 rand() function?

   Arpi

  Here's why I think it's PHP4:  If I look at these pages on my local
  machine (WinME, Apache 1.3.20, PHP4.06 module, MySQL 3.23.14 (not
  that it matters, right?)), the randbg() function works as it
  should--I get a random background image everytime.  But if I look
  at these EXACT SAME pages on Fatcow (Linux/Apache, I believe,
  PHP4...), the randbg() function executes the first time, then
  [seemingly] fails to execute again--it never generates a different,
  random bakground.  (Or maybe I'm looking at one hell of a
  coincidence :-)
 
  So my question is, who is caching what, where?
 
  ...Rene
 
   -Original Message-
   From: Tamas Arpad [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, October 31, 2001 7:24 AM
   To: René Fournier; Hugh Danaher
   Cc: Php-General
   Subject: Re: [PHP] Re: Weird caching problem with PHP4/Apache
  
   On Wednesday 31 October 2001 14:48, René Fournier wrote:
Nope, unfortunately, nothing.  It's a really weird problem.
It's like the PHP function I wrote for generating the random
image will only work the first time.
  
   I think it is not php that caches it. As I undertsand you wrote a
   script that generates an image, and give it back to the browser
   in an img src=... html tag. Am I right?
   I hope I am, so I continue :))
   Images can be cached in many places (proxies, browser), but
   definietly not in php. Your script that generates in the image
   and should be called every time by the img html tag, won't ever
   called again if the previous image were stored somewhere. You
   should send pragma no-cache and other http headers (many posts
   were on this cache headers topic) from the script that
   generates and gives back the image.
   Or another sollution is that you can call your script with a
   random number or better with the current date and time, so you
   images's name won't be the same, and caches can't give back the
   old image. for example:
   ?php echoimg src=\generatebackground.php?x=.date(YmdHis).
   \;?
  
 Arpi
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   To contact the list administrators, e-mail:
   [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Array HELP PLEASE

2001-11-08 Thread René Fournier

(Before you write RTFM, please know that I have checked www.php.net,
zend.com, phpbuilder.com, et all, and--in the eternal words of Bono--I still
haven't found what I'm looking.)

The situation:  I extract an array from a MySQL table. Code:

$models = mysql_fetch_array(mysql_query(SELECT * FROM models WHERE
lang='$lang' AND key1='data' AND key2='$series',$db));

Based on the above criteria, there should be two rows in $modelsrow, with
each row containing about twenty elements.  (A two-dimensional array,
right?)  All I want to do is display the contents of $models.   With the
following...

for ($i = 1; $i = 20; $i++) {
echo $models[$i].p;
}

...I get just one row.  How can I also display the other row?  I've tried
variations of $models[1][2], but I just can't get right syntax.  (Help is
much appreciated. Thanks.)

If you know of a good tutorial on multidimension arrays + mySQL, that would
be nice too.

...Rene


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Array HELP PLEASE

2001-11-08 Thread René Fournier

Oops, guess I posted too soon.  Just figured out the problem myself (use a
do/while...).  Thanks anyways.

 -Original Message-
 From: René Fournier [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, November 08, 2001 3:25 PM
 To: Php-General
 Subject: [PHP] Array HELP PLEASE


 (Before you write RTFM, please know that I have checked www.php.net,
 zend.com, phpbuilder.com, et all, and--in the eternal words of
 Bono--I still
 haven't found what I'm looking.)

 The situation:  I extract an array from a MySQL table. Code:

   $models = mysql_fetch_array(mysql_query(SELECT * FROM models WHERE
 lang='$lang' AND key1='data' AND key2='$series',$db));

 Based on the above criteria, there should be two rows in $modelsrow, with
 each row containing about twenty elements.  (A two-dimensional array,
 right?)  All I want to do is display the contents of $models.   With the
 following...

   for ($i = 1; $i = 20; $i++) {
   echo $models[$i].p;
   }

 ...I get just one row.  How can I also display the other row?  I've tried
 variations of $models[1][2], but I just can't get right syntax.  (Help is
 much appreciated. Thanks.)

 If you know of a good tutorial on multidimension arrays + mySQL,
 that would
 be nice too.

 ...Rene


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Array HELP PLEASE

2001-11-08 Thread René Fournier

Or maybe not. :-) Although I got both rows displaying, they're actually two
long to fit comfortably (w/o horizontally scrolling).  So...  I'd like to
flip the axis of the table, so my header row runs vertically.  But with the
vagaries of html tables, I'm kinda stumped as to how to run the do/while+for
loop.  This is what I've got now (more or less):

fld1fld2fld3
big red house
little  bluedog
longyellow  string

With this code:
===
// MODELS A

echo table border=1 cellpadding=2 cellspacing=0;
echo tr;
for ($i = 6; $i = 25; $i++) {
echo td valign=top align=left
class=deemph.stripslashes($modelsheader[$i])./td;
}
echo /tr;

do {
echo tr;
for ($i = 6; $i = 25; $i++) {
echo td valign=top align=left
class=normal.stripslashes($models[$i])./td;
}
echo /tr;

} while ($models = mysql_fetch_array($result));
echo /table;
=
This is what I WOULD LIKE to have:

fld1big little  long
fld2red blueyellow
fld3house   dog string
==

I can't figure how I would display element 1 of $modelsheader and every
first element of $models, then increment and loop...  That is, I would like
to be able to refer to $models such that $models[0][0] referred to the first
element of the first row and, say, $models[1][0] referred to the first
element of the second row, and so on.



 -Original Message-
 From: René Fournier [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, November 08, 2001 3:39 PM
 To: Php-General
 Subject: RE: [PHP] Array HELP PLEASE


 Oops, guess I posted too soon.  Just figured out the problem myself (use a
 do/while...).  Thanks anyways.

  -Original Message-
  From: René Fournier [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, November 08, 2001 3:25 PM
  To: Php-General
  Subject: [PHP] Array HELP PLEASE
 
 
  (Before you write RTFM, please know that I have checked www.php.net,
  zend.com, phpbuilder.com, et all, and--in the eternal words of
  Bono--I still
  haven't found what I'm looking.)
 
  The situation:  I extract an array from a MySQL table. Code:
 
  $models = mysql_fetch_array(mysql_query(SELECT * FROM models WHERE
  lang='$lang' AND key1='data' AND key2='$series',$db));
 
  Based on the above criteria, there should be two rows in
 $modelsrow, with
  each row containing about twenty elements.  (A two-dimensional array,
  right?)  All I want to do is display the contents of $models.   With the
  following...
 
  for ($i = 1; $i = 20; $i++) {
  echo $models[$i].p;
  }
 
  ...I get just one row.  How can I also display the other row?
 I've tried
  variations of $models[1][2], but I just can't get right syntax.
  (Help is
  much appreciated. Thanks.)
 
  If you know of a good tutorial on multidimension arrays + mySQL,
  that would
  be nice too.
 
  ...Rene
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] How to set file extension php Mac OSX and PHP 4.0.6

2001-12-02 Thread René Fournier

I have successfully installed PHP 4.0.6, and it works! Only problem is 
that Apache only sends files to the PHP module that have a .php 
extension. However, I need to name the files .php4 (long story). As it 
stands, all I see is the actual PHP source, not the output.

Does anyone know how I can change Apache and/or the PHP module to 
recognize .php4 files and execute them as such?

Thanks.

...Rene


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to set file extension php Mac OSX and PHP 4.0.6

2001-12-02 Thread René Fournier

OK, that makes sense--that's what I did under WinME. The only problem is 
that I can't seem to find the httpd.conf file anywhere. At least, 
Sherlock is not returning any results. Do you know which directory 
httpd.conf is in?

...Rene

On Sunday, December 2, 2001, at 01:56  PM, Michael B. Weiner wrote:

 modify the apache configuration file (i.e. httpd.conf) and add it as 
 and AddType, as in the following:

  AddType application/x-httpd-php .php4 .php3 .phtml .php
  AddType application/x-httpd-php-source .phps
 HTH
 --

 René Fournier wrote:

 I have successfully installed PHP 4.0.6, and it works! Only problem is 
 that Apache only sends files to the PHP module that have a .php 
 extension. However, I need to name the files .php4 (long story). As it 
 stands, all I see is the actual PHP source, not the output.

 Does anyone know how I can change Apache and/or the PHP module to 
 recognize .php4 files and execute them as such?

 Thanks.

 ...Rene



 -- Michael B. Weiner, Linux+, Linux+ SME
 Systems Administrator/Partner
 The UserFriendly Network (UFN)
 --
 Linux Registered User #94900  Have you been counted? 
 http://counter.li.org

 PGP: 30 1D CC BA 30 30 63 35  CD 58 E0 89 A9 17 CC C0  8C 55 F7 72

 .Escape the 'Gates' of Hell
  `:::'  ...  ..
   :::  *  `::.::'
   ::: .::  .:.::.  .:: .::  `::. :'
   :::  ::   ::  ::  ::  :::::.
   ::: .::. .::  ::.  `. .:'  ::.
 ...:::.::'   ...
 --





---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] sizeof($array) with a twist

2001-12-04 Thread René Fournier

I'd like to count the number of rows in a 2 dimensional array that have 
the same data in their fifth field. Is there a PHP function that does 
this? Sizeof() appears to lack condition parameters...

...Rene

---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: MySQL ORDER BY or PHP Sort? Oops.

2001-12-03 Thread René Fournier

From: René Fournier [EMAIL PROTECTED]
Date: Mon Dec 03, 2001  06:11:23  PM US/Mountain
To: Benjamin Pflugmann [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED] [EMAIL PROTECTED]
Subject: Re: MySQL ORDER BY or PHP Sort? Oops.

Here is the snippet of code that is presenting a challenge:

---
?php

// FETCH MODELS TECH SPECS

function models ($lang,$db) {
$modelsheader = mysql_fetch_array(mysql_query(SELECT * FROM models 
WHERE lang='$lang' AND key1='header',$db));
$result = mysql_query(SELECT * FROM models WHERE key1='data' ORDER 
BY price ASC,$db);
mysql_close();
include ('../common/models.inc');
}

models($lang,$db);

// CREATE A MULTI-DIMENSIONAL MODELS ARRAYS BASED ON THE NUMBER OF MODEL 
ROWS IN THE TABLE

$i = 0;
do {
$allmodels[$i] = $models;
$i++;
} while ($models = mysql_fetch_array($result));

// NUMBER OF MODELS

$first = 1;
$last = sizeof($allmodels)-1;
$colspan = ($last * 2)+1;

?
---
The problem is, if I sort by the price field, the ordering of the series 
gets mixed up (since low-end models in higher-end series cost more than 
some higher-end models in lower-end series (confused?? I am :-)  If I 
just sort by series, I don't get the prices in order within each series 
(big problem). And if I sort by BOTH series and price, which is the 
logical thing to do, and which many people have kindly suggested (and 
which I have tried), well, it doesn't work, because the series must be 
sorted in a non-alphabetical way.

I've looked at PHP's myriad sorting functions, and well--maybe I need 
more sun (I live in Canada... winter...)--I can't see a 'simple' way to 
do a non-numerical, non-alphabetical (user-defined?) sort on the Series 
fields, then subsort each series by price.

Many thanks for all the help, fellas.

...Rene

On Monday, December 3, 2001, at 05:31  PM, Benjamin Pflugmann wrote:

Hi.

Because you said, Rene, that you already know how to sort according to
one of both criteria, I presume ordering the series column is not the
problem (e.g. because it is an enum or something alike).

Then the solution would simply be to do something like

SELECT * FROM my_table WHERE ... ORDER BY series, price

I.e. simply list the order criteria which work seperately in the ORDER
BY clause. If this is not appliable, please elaborate.

Btw, it is *much* easier to help if you had quoted a (partial) working
query (which include table and column names and so on). Also, how the
series are stored would have been of interest, because this will
influence how the ordering is specified.

Also, I do not understand why you put emphasis on the fact that the
series is sorted in an unusual way if you later say that you already
know how to order by it?! Is this relevant to the problem at all?

Bye,

Benjamin.


On Tue, Dec 04, 2001 at 12:36:34AM +0200, [EMAIL PROTECTED] wrote:

   Well I think mysql doesnt allow you to do this that simple as mysql
doesnt know how you want to sort it exactly. So my suggestion would be to
give a value to each series, eg. Baby = 1,
Genesis=2,Super=3,Predator=4,Millennium=5 and then order by series.

Cheers
Siim Einfeldt

One more thing, very important: I want to specify the Series sort order,
not alphabetically, but by a non-obvious way
(BabyGenesisSuperPredatorMillennium)...

--

I want to select about 25 rows from a table, and sort them by two
criteria. First, by each row's Series field (Baby, Genesis, Super,
Predator, Millennium are the various Series, and the order I'd like
the rows in the array). Within each Series, I'd like the rows sorted by
their Price field, ascending. For example:

Baby $5
Baby $10
Baby $15
Genesis $20
Genesis $35
Genesis $50

...and so on.

Now, I know how to structure my MySQL Select statment such that the rows
it pulls from the table will be either sorted by Price OR by Series, but
not both, in the way I'd like. Does anyone know if it's possibly to do
this in the Select statement itself? (I'd rather do it that way, than
resort in PHP.)

Thanks!

...Rene
[...]

--
[EMAIL PROTECTED]

-
Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail mysql-unsubscribe-
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: MySQL ORDER BY or PHP Sort? Oops.

2001-12-03 Thread René Fournier

You know, in spite of all the good advice I've received, I think that's 
what I'll have to do. I say have to because inserting another field 
into the table creates some complications (long story... related to the 
web admin tool I made for editing the tables). Actually, come to think 
of it, there is an existing field that I could reuse for this purpose. 
Yes, that will work!

Thanks everyone!

...Rene

On Monday, December 3, 2001, at 06:49  PM, Martin Towell wrote:

 can you have another field in your table(s) for a weighting and then 
 sort
 on that?

 otherwise you'll have to use php

 -Original Message-
 From: René Fournier [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, December 04, 2001 12:16 PM
 To: Benjamin Pflugmann; [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: [PHP] Re: MySQL ORDER BY or PHP Sort? Oops.


 From: René Fournier [EMAIL PROTECTED]
 Date: Mon Dec 03, 2001  06:11:23  PM US/Mountain
 To: Benjamin Pflugmann [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED] [EMAIL PROTECTED]
 Subject: Re: MySQL ORDER BY or PHP Sort? Oops.

 Here is the snippet of code that is presenting a challenge:

 ---
 ?php

 // FETCH MODELS TECH SPECS

 function models ($lang,$db) {
   $modelsheader = mysql_fetch_array(mysql_query(SELECT * FROM models
 WHERE lang='$lang' AND key1='header',$db));
   $result = mysql_query(SELECT * FROM models WHERE key1='data' ORDER
 BY price ASC,$db);
   mysql_close();
   include ('../common/models.inc');
 }

 models($lang,$db);

 // CREATE A MULTI-DIMENSIONAL MODELS ARRAYS BASED ON THE NUMBER OF MODEL
 ROWS IN THE TABLE

 $i = 0;
 do {
 $allmodels[$i] = $models;
 $i++;
 } while ($models = mysql_fetch_array($result));

 // NUMBER OF MODELS

 $first = 1;
 $last = sizeof($allmodels)-1;
 $colspan = ($last * 2)+1;

 ?
 ---
 The problem is, if I sort by the price field, the ordering of the series
 gets mixed up (since low-end models in higher-end series cost more than
 some higher-end models in lower-end series (confused?? I am :-)  If I
 just sort by series, I don't get the prices in order within each series
 (big problem). And if I sort by BOTH series and price, which is the
 logical thing to do, and which many people have kindly suggested (and
 which I have tried), well, it doesn't work, because the series must be
 sorted in a non-alphabetical way.

 I've looked at PHP's myriad sorting functions, and well--maybe I need
 more sun (I live in Canada... winter...)--I can't see a 'simple' way to
 do a non-numerical, non-alphabetical (user-defined?) sort on the Series
 fields, then subsort each series by price.

 Many thanks for all the help, fellas.

 ...Rene

 On Monday, December 3, 2001, at 05:31  PM, Benjamin Pflugmann wrote:

 Hi.

 Because you said, Rene, that you already know how to sort according to
 one of both criteria, I presume ordering the series column is not the
 problem (e.g. because it is an enum or something alike).

 Then the solution would simply be to do something like

 SELECT * FROM my_table WHERE ... ORDER BY series, price

 I.e. simply list the order criteria which work seperately in the ORDER
 BY clause. If this is not appliable, please elaborate.

 Btw, it is *much* easier to help if you had quoted a (partial) working
 query (which include table and column names and so on). Also, how the
 series are stored would have been of interest, because this will
 influence how the ordering is specified.

 Also, I do not understand why you put emphasis on the fact that the
 series is sorted in an unusual way if you later say that you already
 know how to order by it?! Is this relevant to the problem at all?

 Bye,

   Benjamin.


 On Tue, Dec 04, 2001 at 12:36:34AM +0200, [EMAIL PROTECTED] wrote:

Well I think mysql doesnt allow you to do this that simple as mysql
 doesnt know how you want to sort it exactly. So my suggestion would be 
 to
 give a value to each series, eg. Baby = 1,
 Genesis=2,Super=3,Predator=4,Millennium=5 and then order by series.

 Cheers
 Siim Einfeldt

 One more thing, very important: I want to specify the Series sort order,
 not alphabetically, but by a non-obvious way
 (BabyGenesisSuperPredatorMillennium)...

 --

 I want to select about 25 rows from a table, and sort them by two
 criteria. First, by each row's Series field (Baby, Genesis, Super,
 Predator, Millennium are the various Series, and the order I'd like
 the rows in the array). Within each Series, I'd like the rows sorted by
 their Price field, ascending. For example:

 Baby $5
 Baby $10
 Baby $15
 Genesis $20
 Genesis $35
 Genesis $50

 ...and so on.

 Now, I know how to structure my MySQL Select statment such that the rows
 it pulls from the table will be either sorted by Price OR by Series, but
 not both, in the way I'd like. Does anyone know if it's possibly to do
 this in the Select statement itself? (I'd rather do it that way, than
 resort in PHP.)

 Thanks

[PHP] Mac OSX and MySQL

2001-12-04 Thread René Fournier

The migration continues...

Now I have to get my mysql database running under MySQL 3.23.46 on OSX 
10.1.1. I've dumped the structure and contents of the database (on 
Windows) into a text file, and now I'd like to recreate it in the new 
enivronment. I think I can use the mysql admin tools via command line 
(but really, what is the syntax for piping a 'dumped' database into a 
new database? mysqladmin create database  dumpeddb.sql??), but one 
question about users...

I have to create a MySQL for my PHP scripts. How do I do this in Mac 
OSX? There are a bunch of command line tools, but I'm not sure which 
one[s] to use.

Thanks.

...Rene

---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Mac OSX and MySQL

2001-12-05 Thread René Fournier

 I have to create a MySQL for my PHP scripts. How do I do this in Mac 
 OSX? There are a bunch of command line tools, but I'm not sure which 
 one[s] to use.

 Not sure I understand this question.  What do you mean by create a 
 MySQL for my PHP?

oops, I meant to write create a MySQL user for my PHP scripts. In other 
words, when my scripts try to connect to the database, they need to 
supply a user id and password (and that must be certain id/pwd to 
correspond with the 'real' online server we're using). So I would like 
to know how to create this user/password under Mac OSX. (Thanks.)


 Thanks.

 ...Rene

 Hope this helps,

 /Rob

 ~
 Robert Alexander, Alpha Geek, Workmate.ca
 WWW Database Applications and Web Hosting
 http://www.workmate.ca   416-823-6599
 mailto:[EMAIL PROTECTED]

 Life's unfair - but root password helps!

 -
 Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail mysql-unsubscribe-
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Dumped OK, Restore NOT

2001-12-05 Thread René Fournier

Little problem with MySQL 3.23.46 under Windows ME. I'm trying to create 
a database from an .sql file (the dumped remains of a functioning 
database--also MySQL). The dumping was easy, but I'm having a problem 
putting it back. I have a dumped file called smarts.sql that starts this 
way:
-

# MySQL dump 8.14
#
# Host: localhostDatabase: smarts
#
# Server version3.23.38

#
# Table structure for table 'about'
#

CREATE TABLE about (
   id smallint(5) unsigned NOT NULL auto_increment,
   lang char(2) default NULL,
   recordname varchar(40) default NULL,
   key1 tinytext,
   key2 tinytext,
   status varchar(10) default NULL,
   title tinytext,
   par1 tinytext,
   PRIMARY KEY  (id)
) TYPE=MyISAM;

#
# Dumping data for table 'about'
#

INSERT INTO about VALUES (1,'en','about'
---(and so on)

This is what I'm doing to try to recreate the database locally:

1. I type mysqladmin create smarts

OK--I see a new directory called smarts (no files in it)

2. I type mysql smarts  smarts.sql

It pauses for a few seconds (seeming to input the file), then returns 
the DOS prompt with no message, error or otherwise. Seems to have 
worked, right? But when I check the 'smarts' database directory, there 
are no files in it. (Incidentally mysqld is running.)

What am I doing wrong??

...Rene

---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Dumped OK, Restore NOT

2001-12-05 Thread René Fournier

That's why I cross-posted there as well. But I've found that posting to 
the mysql list doesn't help, more often than not--perhaps fewer 
subscribers.

Anyways, if any PHP people here are--god forbid--actually using MySQL as 
their database, I would GREATLY appreciate any help in this matter. I've 
thoroughly read the mysqldump chapter in the docs, and gone through 
several tutorials, but have found nothing on actually restoring a 
database from a dumped file--ON Windows.

On Wednesday, December 5, 2001, at 09:49  AM, Kurt Lieber wrote:

 On Wednesday 05 December 2001 08:02 am, you wrote:
 Little problem with MySQL 3.23.46 under Windows ME. I

 This would be an excellent question for the MySQL mailing list.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Dumped OK, Restore NOT

2001-12-05 Thread René Fournier

You know, I tried that, it it STILL didn't work. Then, after remembering 
to reboot my brain, I took a look at the smarts.sql that my ISP kindly 
dumped for me, to see what code/statements it might be missing--and lo 
and behold!--it didn't have a USE database; statement! Adding this one 
wee line made all the difference in the world. Your suggestions(s) work; 
I can now restore my database locally.

Thanks everyone for your help and patience! (And my apologies for 
posting off-topic oh PHP--I've been suitably chastised, and will 
remember to name the subject OT: next time I feel tempted to ignore 
netiquette.)

...Rene

On Wednesday, December 5, 2001, at 10:56  AM, Ernesto wrote:


 You should try:

 mysql -u username -p password database  dump.sql

 Example:

 mysql -u joe -p mypass smarts  smarts.sql


 René Fournier wrote:

 Little problem with MySQL 3.23.46 under Windows ME. I'm trying to 
 create a database from an .sql file (the dumped remains of a 
 functioning database--also MySQL). The dumping was easy, but I'm 
 having a problem putting it back. I have a dumped file called 
 smarts.sql that starts this way:
 -
 # MySQL dump 8.14
 #
 # Host: localhostDatabase: smarts
 #
 # Server version3.23.38
 #
 # Table structure for table 'about'
 #
 CREATE TABLE about (
   id smallint(5) unsigned NOT NULL auto_increment,
   lang char(2) default NULL,
   recordname varchar(40) default NULL,
   key1 tinytext,
   key2 tinytext,
   status varchar(10) default NULL,
   title tinytext,
   par1 tinytext,
   PRIMARY KEY  (id)
 ) TYPE=MyISAM;
 #
 # Dumping data for table 'about'
 #
 INSERT INTO about VALUES (1,'en','about'
 ---(and so on)
 This is what I'm doing to try to recreate the database locally:
 1. I type mysqladmin create smarts
 OK--I see a new directory called smarts (no files in it)
 2. I type mysql smarts  smarts.sql
 It pauses for a few seconds (seeming to input the file), then returns 
 the DOS prompt with no message, error or otherwise. Seems to have 
 worked, right? But when I check the 'smarts' database directory, there 
 are no files in it. (Incidentally mysqld is running.)
 What am I doing wrong??
 ...Rene
---
René Fournier
[EMAIL PROTECTED]





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Performance

2001-12-13 Thread René Fournier

That certainly makes sense on one level, but I think it really comes 
down to the question, what is more compute intensive--echoing the HTML 
while in PHP mode, or context-switching to HTML and back again to PHP? 
(It could be that the difference, if any, is negligible--but I'd like to 
at least know BEFORE I write 100 million lines of otherwise perfect 
code :-)

...Rene


On Thursday, December 13, 2001, at 10:26  AM, Nathan Cassano wrote:


 I have always assumed straight html was faster than function output. My
 logic being that quoted output requires more parsing than straight
 html. But they may be the same speed after a simple optimization pass.

 -Original Message-
 From: René Fournier [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, November 13, 2001 9:05 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: [PHP] Performance


 Is it true that mixing HTML and PHP--switching back and forth with
 ?php ?  tags--slows down performance? (I'm using PHP4.) Is it better
 to echo output than to drop out of PHP mode?


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Command-line PHP script CPU usage goes sky-high, stays there--why?

2007-12-10 Thread René Fournier

Hello,

I have a command-line PHP script--called Listener--that is designed  
to run indefinitely with a predictable CPU usage and memory  
footprint. In a nutshell, it's a multi-client socket server that  
waits for incoming connections, processes incoming data, stores  
results in a MySQL database, and basically gets on with its life. And  
it works. No errors or serious problems to speak of. And I've been  
running it for a couple years on an Xserve dual-G5 2GHz w/ OS X  
Server 10.4.11). Six months ago, the program would run for days, even  
a couple weeks, without a hitch. The only reason I would stop the  
script is for some other purpose, like a software update.


However, the number of socket clients connecting in the past 3-4  
months has steadily increased, and this seems to have exposed (if not  
created) a strange performance issue with PHP 5.2.4, MySQL 5.0.45  
and/or Mac OS X Server 10.4.11. (I say and/or because I am unsure  
where the problem's cause really lies.) Basically, after the script  
has been running for a day or so (processing essentially the amount  
data that used to take two weeks), the CPU usage of the machine goes  
from 30% (normal) to 80-90%. This appears to be irrespective of the  
number of clients connected to the server at the time, but rather the  
amount of time the script has been running (and therefore cumulative  
cycles it's operated, data processed, MySQL queries executed, etc.).  
And the CPU usage stays high, even when the actual load (number of  
clients) decreases. At this time, if I run top, I get the following  
info:


22512 mysqld  91.6%  8:22:12  31   106   125   305M+ 3.20M
260M   475M
17104 php  7.2% 81:14.01   115   145  5.08M  7.80M   
10.9M- 87.5M
22537 Terminal 6.6%  2:59:59  22   176   240  12.3M  21.2M   
18.3M-  236M

[...]

At first I thought, okay, it's MySQL's fault. Maybe a lot of slow- 
running queries. But the slow query log is pretty clean. So maybe  
it's a combination of Mac OS X and MySQL and PHP? I Googled for a  
similar problem, and finally ran across this article:


http://www.shawnhogan.com/2005/10/mysql-problems-on-mac-os-x-server.html

...where the author describes a very similar CPU usage pattern. I  
tried his suggested fixes and they seemed to have helped a little (or  
maybe it's my wishful thinking--hard to tell), since the high CPU  
load issue doesn't appear to happen as soon... But it still happens.


Anyway, I'm really stumped as to what to do next, where to look, etc.  
If I stop the script, and restart it (but not the MySQL itself), CPU  
usage goes back to normal--for about a day or two.


The only thing I thought might be connected is how many short-lived  
PHP child processes Listener creates--around 20-30,000 per day.  
Sounds higher, but on average it's just one every 2-3 seconds.  
Anyway, although the number of child processes isn't concurrent,  
would there be a problem with the number of historical child  
processes in view of ulimits or kern.maxfilesperproc?


Anyway suggestions, tips, or links are much appreciated. Thanks.

...Rene

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



Re: [PHP] Command-line PHP script CPU usage goes sky-high, stays there--why?

2007-12-10 Thread René Fournier




Hi Jim,

I have a server that listens like yours does.  I get 80k - 85k  
connections a day to it.


When I first started it, I was only getting about 3k of connections  
aday.  Then I upped the
listening pattern and it tanked.  I noticed that all my mail/web/db  
connections just sat there.


When I investigated, I found that the number of connections to the  
server was being overloaded.  So
I increased the kern.maxfilesperproc setting to 32000.  All the  
problems went away.


I have about have the horse power you do, running OpenBSD 4.1, and  
it runs great now as my
listener / web / ftp / mail / named / database / spam filter /  
etc...


One question about the listener program, does it maintain a  
connection to the DB or does it
open/close a connection upon each socket connection?  If it does  
the latter, you might look into
using a constant connection rather then opening/closing on a per  
connection basis.


Thanks for the reply. (Not many people seem to be doing what I'm  
doing in the way I'm doing it... so I really appreciate the feedback.)


I don't think the kern.maxfilesperproc setting is a problem. I'm  
currently set to 102400 per Shawn Hogan's advice. And my Listener  
program only receives ~1000 connections per day. However, each  
connection involves multiple MySQL queries, often as many as 50 or so  
per connection each day. So perhaps your second observation applies.  
MySQL is showing ~ 1,500 connections per hour. And I'm using  
mysql_connect() in Listener. I will see if using mysql_pconnect(),  
and reducing the number of connections helps.


My.cnf's max connections, presently at 100, may have been too low in  
view using mysql_connect(). If mysql_pconnect() doesn't improve  
things, maybe I should bump up max_connections to 500?


..Rene

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



Re: [PHP] Command-line PHP script CPU usage goes sky-high, stays there--why?

2007-12-10 Thread René Fournier


On 10-Dec-07, at 4:42 PM, Tom Rogers wrote:



Put a usleep(1000) in the listen while() loop and give the cpu a
break.


Good advice, but I've already been doing that. The thing is, when the  
script first starts up, the CPU rarely exceeds 30%, even when many  
clients (200+) are simultaneously connected and sending data. When a  
few clients are connected, CPU is typically below 10%. Again, it's  
only after 24-48 hours that, all of a sudden, CPU usage increases by  
40-50%. And it stays high until I stop the script and restart it.


One question I have though is, is there actually any benefit to using  
mysql_pconnect(), since the script simply loops? My understanding is  
that pconnect only benefits if a script would otherwise be using  
mysql_connect repeatedly--and this script doesn't, since it calls  
mysql_[p]connect() just once, in the start tof execution.


...Rene

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



Re: [PHP] Command-line PHP script CPU usage goes sky-high, stays there--why?

2007-12-10 Thread René Fournier

On 10-Dec-07, at 5:20 PM, Jim Lucas wrote:


Tom Rogers wrote:

Hi,

Tuesday, December 11, 2007, 6:42:18 AM, you wrote:
RF Hello,

Put a usleep(1000) in the listen while() loop and give the cpu a
break.



This makes me think about asking if you have to short of a timeout  
on your receiving connection?


One second on stream_socket_server(), with a 900 second timeout  
stream_socket_accept().


What are you using to setup your connection?  fsockopen() or  
stream_socket_server() ?


here is a snippet of what I have

[...]

Thanks for sharing your code. Seems pretty similar to mine at first  
glance.


I don't have a timeout set on the *_recvfrom() call.  I just wait  
until the next connection comes in.


You don't need to use mysql_pconnect(), especially if you are  
using, what in essence is, a daemon.


Yeah, after thinking about it, that's what I figured. Thanks for  
confirming though.



Just don't open and close the connection constantly, leave it open.


Yes, I just open it once at the top of the script. And that's it.

Also, make sure you are not using an array that you are not re- 
initializing through each iteration
of the loop.  If the array keeps getting bigger, PHP might $*% on  
itself.  Always re-initialize

arrays to clean them up.

Hope some of this helps!


All good advice. I will check my arrays, although I don't think this  
is a problem since I monitor the scripts memory usage with  
memory_get_usage() and memory_get_peak_usage(), and it never tops 3MB  
(max allocated is 16MB). There are a few little parts to the daemon.  
One thing I'm doing that could be problematic is running an include 
(); on a couple files each time a socket has new data (this allows me  
to adjust the processing logic on the fly without having to start the  
script and wait for clients to reconnect)--but I can see this being  
expensive in terms of performance and resources. Actually, I wonder  
if THAT is not what's starving the script of resources over time-- 
each fread() involves several includes(); I'll have to look into that...


FWIW, here's the stripped-down skeleton of the server:
As always, constructive criticism is very welcome.

?php

$socket = stream_socket_server(tcp://127.0.0.1:9876, $errno, $errstr);

if ($socket) {

$master[] = $socket;
$read = $master;
$write = $master;   

while (1) {

$read = $master;
$write = $master;   
$mod_fd = stream_select($read, $_w = NULL, $_e = NULL, 1);

if ($mod_fd === FALSE) {
break;
}

for ($i = 0; $i  $mod_fd; ++$i) {
if ($read[$i] === $socket) {// NEW SOCKET

$conn = stream_socket_accept($socket, 900);
$master[] = $conn;
$key_num = array_search($conn, $master, TRUE);

} else {

$sock_data = fread($read[$i], 32768);

if (strlen($sock_data) === 0) { // 
CONNECTION GONE

$key_to_del = array_search($read[$i], 
$master, TRUE);
fclose($read[$i]);  
unset($master[$key_to_del]);

} elseif ($sock_data === FALSE) {   
// CONNECTION BROKEN

$key_to_del = array_search($read[$i], 
$master, TRUE);
fclose($read[$i]);
unset($master[$key_to_del]);

} else {
// READ INCOMING DATA

// include (somefiles);
// include (somefiles);
// include (somefiles);
// [ ... ]

}
}
}
}
}

?

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



Re: [PHP] Command-line PHP script CPU usage goes sky-high, stays there--why?

2007-12-11 Thread René Fournier
That makes sense, but I'm not sure I really want to do this, since  
it's fairly important that Listener continue listening without  
interruption.


I also don't think it's probably necessary, since from what I read,  
I'm not really pushing the envelope in terms of real load. Right now,  
I might have max ~250 clients connected, each sending 5-20 kb / day  
of data. It's not much data, nor many concurrent connections. If  
Jim's Listener handles 80-85k connections per day, then mine should  
be able to do 250 concurrently easily, and 2000 cumulative per day  
without a hitch.


Did I mention, I'm on Mac OS X Server 10.4.11? Shouldn't matter, but  
anyway.


On 10-Dec-07, at 5:48 PM, Jochem Maas wrote:


Jim Lucas wrote:

Tom Rogers wrote:

Hi,


...

Also, make sure you are not using an array that you are not re- 
initializing through each iteration
of the loop.  If the array keeps getting bigger, PHP might $*% on  
itself.  Always re-initialize

arrays to clean them up.


even then he may still have creeping memory ... in which it might  
be possible to have a mother process that
spawns and watchs a child process .. the child process is the  
actual deamon, the child could then keep a track
of it's own memory usage and then kill itself when it gets too  
big ... the mother in turn would automatically
spawn a new child deamon process upon seeing it's child has  
committed suicide.


does that make sense?

--
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] Bug in stream_socket_server()?

2007-12-11 Thread René Fournier
If you want a high speed socket server, use the low-level sockets  
instead (socket_create/bind/listen). The stream_socket_server version  
appears to have internal fixed 8k buffers that will overflow if you  
don't keep up by reading.


This is a serious problem if you an application that reads the socket  
for messages and then, say, saves the result in a database. The delay  
while it is busy processing means you can't read the data in time  
unless you get involved in muti-threading.


With the the low-level functions, the OS quietly buffers TCP/IP  
packets so there is no problem (tested on Windows XP Professional).


( http://php.oregonstate.edu/manual/en/function.stream-socket- 
server.php#67837 )



Has anyone confirmed this? I am doing tests with a stripped-down  
multi-client socket server, wonder if this issue is causing some of  
the problems I've seen.


...Rene

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



[PHP] Pushing the limits of stream_socket_server() and stream_select()

2007-12-11 Thread René Fournier
Just curious what people found the limits to be with  
stream_socket_server(), in terms of maximum concurrent connections,  
packet sizes, etc. I'm am presently stress-testing a multi-client  
socket server and am finding I can sometimes break it with as few as  
100 concurrent connections, and always break it with [precisely] 252  
connections--with a variety of errors getting thrown:


Client-side (100 connections, sometimes):
	PHP Warning:  stream_socket_client(): unable to connect to tcp:// 
192.168.0.41: (Operation timed out) in /Tuning/client.php on line 3
	PHP Notice:  fwrite(): send of 68 bytes failed with errno=32 Broken  
pipe in /Tuning/client.php on line 14


Server-side error ( 252+ connections, every time):
	PHP Warning:  stream_select(): supplied argument is not a valid  
stream resource in /Tuning/server.php on line 15


Interestingly, the above server-side error only occurs when 252  
clients are connected. At 251, it's okay. At 252, it generates the  
above PHP Warning. (Which really is strange. Anyone have any ideas?)


If anyone is interested, I will post the sample code I'm using, in  
case--perish the thought--the problem is self-inflicted. :-)


...Rene

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



Re: [PHP] Pushing the limits of stream_socket_server() and stream_select()

2007-12-11 Thread René Fournier

On 11-Dec-07, at 4:32 PM, René Fournier wrote:

Just curious what people found the limits to be with  
stream_socket_server(), in terms of maximum concurrent connections,  
packet sizes, etc. I'm am presently stress-testing a multi-client  
socket server and am finding I can sometimes break it with as few  
as 100 concurrent connections, and always break it with [precisely]  
252 connections--with a variety of errors getting thrown:


Client-side (100 connections, sometimes):
	PHP Warning:  stream_socket_client(): unable to connect to tcp:// 
192.168.0.41: (Operation timed out) in /Tuning/client.php on  
line 3
	PHP Notice:  fwrite(): send of 68 bytes failed with errno=32  
Broken pipe in /Tuning/client.php on line 14


Server-side error ( 252+ connections, every time):
	PHP Warning:  stream_select(): supplied argument is not a valid  
stream resource in /Tuning/server.php on line 15


Interestingly, this 251 connection limit does not appear to be  
obviously system-related (I am running Mac OS X 10.4.11). I can run  
two instances of server.php and have each client.php spawn 175  
connections (350 total concurrent to the machine), with no problem.


Interestingly, the above server-side error only occurs when 252  
clients are connected. At 251, it's okay. At 252, it generates the  
above PHP Warning. (Which really is strange. Anyone have any ideas?)


If anyone is interested, I will post the sample code I'm using, in  
case--perish the thought--the problem is self-inflicted. :-)


...Rene



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



[PHP] Re: Mac OS X Server limits... was [PHP] Pushing the limits of stream_socket_server() and stream_select()

2007-12-11 Thread René Fournier
OK, having done more digging, this bizarre 251-255 connections per  
socket limit seems to be an OS X thing. (Linux people, any comments?)  
At least that's I've read: http://www.macgeekery.com/tips/ 
configuration/mac_os_x_network_tuning_guide_revisited#comment-1433


So... Do any Mac OS  X gurus out there know how to increase OS X  
Server's (10.4.11) maximum connections per socket value? There seems  
to no such setting in sysctl or ulimit. Any ideas? Anyone? Anyone?


...Rene

On 11-Dec-07, at 4:55 PM, René Fournier wrote:


On 11-Dec-07, at 4:32 PM, René Fournier wrote:

Just curious what people found the limits to be with  
stream_socket_server(), in terms of maximum concurrent  
connections, packet sizes, etc. I'm am presently stress-testing a  
multi-client socket server and am finding I can sometimes break it  
with as few as 100 concurrent connections, and always break it  
with [precisely] 252 connections--with a variety of errors getting  
thrown:


Client-side (100 connections, sometimes):
	PHP Warning:  stream_socket_client(): unable to connect to tcp:// 
192.168.0.41: (Operation timed out) in /Tuning/client.php on  
line 3
	PHP Notice:  fwrite(): send of 68 bytes failed with errno=32  
Broken pipe in /Tuning/client.php on line 14


Server-side error ( 252+ connections, every time):
	PHP Warning:  stream_select(): supplied argument is not a valid  
stream resource in /Tuning/server.php on line 15


Interestingly, this 251 connection limit does not appear to be  
obviously system-related (I am running Mac OS X 10.4.11). I can run  
two instances of server.php and have each client.php spawn 175  
connections (350 total concurrent to the machine), with no problem.


Interestingly, the above server-side error only occurs when 252  
clients are connected. At 251, it's okay. At 252, it generates the  
above PHP Warning. (Which really is strange. Anyone have any ideas?)


If anyone is interested, I will post the sample code I'm using, in  
case--perish the thought--the problem is self-inflicted. :-)


...Rene



--
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] Command-line PHP script CPU usage goes sky-high, stays there--why?

2007-12-19 Thread René Fournier


On 11-Dec-07, at 2:13 PM, Per Jessen wrote:


René Fournier wrote:


However, the number of socket clients connecting in the past 3-4
months has steadily increased, and this seems to have exposed (if not
created) a strange performance issue with PHP 5.2.4, MySQL 5.0.45
and/or Mac OS X Server 10.4.11. (I say and/or because I am unsure
where the problem's cause really lies.) Basically, after the script
has been running for a day or so (processing essentially the amount
data that used to take two weeks), the CPU usage of the machine goes
from 30% (normal) to 80-90%.


Have you tried stracing it to see what's really happening when the  
load

goes that high?


Good advice, since I think there's nothing left for me to do but  
inspect the MySQL process.


Incidentally, I've made some changes to the script a week ago, which  
has seemed to improve the situation somewhat. Now, the script has run  
for nearly 7 days without interruption or high CPU load. Problem  
solved? Again this morning, I noticed CPU went up to 90% and is  
staying there. (Previously, this would happen after 1-2 days.)


The number of distinct MySQL connections remains low, since the  
script (which runs in a loop, with a sleep(1) and a timeout on the  
stream_socket_select()), only creates one MySQL connection in the  
beginning. All MySQL queries run through that.


The script has run for 6-7 days, during which time it's executed 2.7  
million queries (mostly SELECTs) and created 105,198 external, short- 
lived child processes (each lasts about a second or two, then closes  
after mysql_close())--I don't think this is an issue.


Memory usage seems okay. By the end of 7 days, the script's memory  
usage has peaked at 4MB (out of 16MB max). Typically it's around 3MB.  
MySQL memory usage doesn't seem to be a constraint. I'm using my- 
huge.cnf, and the nature of the queries is fairly regular. I would  
say that the database structure is not an issue (though I could be  
wrong!)--everything is pretty well normalized and indexed. I'm  
logging slow queries, non-indexed SELECTs, etc.


I'm really not sure what to try next. ps -aux shows MySQL as hogging  
the CPU, not PHP or Terminal:


PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
342 mysqld 83.3% 16:13:19 33 125 139 435M 4.75M 439M 539M
385 Terminal 4.7% 5:36:35 22 184 251 20.1M 33.5M 28.8M+ 256M
1190 php 4.3% 3:13:33 1 15 148 6.51M 8.15M 12.1M 89.0M
0 kernel_tas 1.3% 2:02:40 47 2 619 5.00M- 0B 219M- 1.26G-

It's really strange and strangely consistent. The script will run for  
a few million cycles, whereupon MySQL suddenly uses 50% more CPU. But  
for what?


I'm looking at tutorials on ktrace and kdump to see what I can learn  
from MySQL. I wonder if I would have this problem under Linux...


...Rene 

[PHP] Got a makestringsafe_for_filename() function?

2005-06-22 Thread René Fournier
I imagine some of you have written a nice little function for taking an 
arbitrary user-input string, and sanitizing and cleaning it for us as a 
UNIX (Mac OSX) filename...


Would you mind sharing it? Thanks.

René

---
René Fournier
www.renefournier.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] array_search() with preg_match?

2005-06-23 Thread René Fournier

I need to search an array for a string, with a twist. E.g.:

$array = array(0 = 'this sky is blue', 1 = 'pencils are orange', 2 = 
'I like green apples', 3 = 'strawberries are red');


$key = array_search('green', $array);

With the above code, nothing will be returned, but I would like it to 
return 2 for the key containing green. Any suggestions?


...René

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



[PHP] Accessing data posted from a different URL

2006-03-20 Thread René Fournier
I have a script that periodically sends an email that includes  form  
post to a script, which is meant to do something with the posted data.


My problem is that apparently some PHP security measure is not  
permitting the externally posted data to be access via $_POST. I  
assume this is due to cross-site scripting issues, but in this case,  
I want to do just that. Any ideas?


...Rene

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



Re: [PHP] Accessing data posted from a different URL

2006-03-20 Thread René Fournier

Hmm, perhaps I didn't explain clearly. To put it another:

1. A script sends an email to a user with sign-in details.
2. The user clicks a [submit] button in the email message called  
Quick Sign In
3. A web browsers opens to http://www.website.com/signin.php (from  
the form method=post action=http://www.website.com/sign.php; in  
the email)

4. Signin.php looks for $_POST[signindetails] and auto-fills the form.

Except the form post is not posting signindetails...


On 20-Mar-06, at 2:57 PM, Jay Blanchard wrote:


[snip]
I have a script that periodically sends an email that includes  form
post to a script, which is meant to do something with the posted data.

My problem is that apparently some PHP security measure is not
permitting the externally posted data to be access via $_POST. I
assume this is due to cross-site scripting issues, but in this case,
I want to do just that. Any ideas?
[/snip]

http://www.php.net/curl





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



Re: [PHP] Accessing data posted from a different URL

2006-03-20 Thread René Fournier

On 20-Mar-06, at 3:05 PM, Jay Blanchard wrote:


[snip]
Hmm, perhaps I didn't explain clearly. To put it another:

1. A script sends an email to a user with sign-in details.
2. The user clicks a [submit] button in the email message called
Quick Sign In
3. A web browsers opens to http://www.website.com/signin.php (from
the form method=post action=http://www.website.com/sign.php; in
the email)
4. Signin.php looks for $_POST[signindetails] and auto-fills the  
form.


Except the form post is not posting signindetails...
[/snip]

Have you tried print_r($_POST) ?


Yes. And to answer a few other questions: The script, the email, the  
server—everything is on the same computer, running on top  of the  
same Apache/PHP installation (v 4.3.11). The form is essentially:


form method=POST target=SI action=http:// 
www.website.cominput type=hidden name=signindetails  
value=serialized and htmlentitized array values...input  
type=submit name=submit value=Fill/form


I've narrowed it down a little farther:

1. If I copy the form from the email into the destination php page  
(ProcessSignin.php), and click Submit, it works—I get can see the  
$_POST[signindetails]


2. If I copy the form from the email into the original php page  
(MakeandSendSignin.php), and click Submit (with  
action=ProcessSignIn.php), it works—I can see the $_POST 
[signindetails]


3. ONLY if I click the Submit FROM the email—email client Mac OS X  
Mail.app or Outlook Excell—does it fail. The destination php page  
(ProcessSignin.php) appears, but print_r($_POST) reveals no $_POST 
[signindetails].


So, it appears that the email clients are stripping the POST data on  
Submit.


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



Re: [PHP] Accessing data posted from a different URL

2006-03-20 Thread René Fournier


On 20-Mar-06, at 4:40 PM, Richard Lynch wrote:


On Mon, March 20, 2006 5:04 pm, René Fournier wrote:

form method=POST target=SI action=http://
www.website.cominput type=hidden name=signindetails
value=serialized and htmlentitized array values...input


What does this value actually look like?

How long is it?

Is mail wrapping it to 72 characters with a newline, thereby breaking
the data up?

Though you would still get some POST data, just not what you  
thought...



Actually, neither the form, nor the data seems to matter. I've copied  
in simple forms from elsewhere, and the only determining factor so  
far is:


If the form is submitted from a web browser, the POSTed data IS  
available/visible (print_r) in the new web page.
If the form--that is, any form--is submitted from an email client  
(any email client), the POSTed data IS NOT available/visible in the  
new web page.


So... I can think of three explanations:
1. The email client (Mail or Outlook Express) is stripping the POST  
data on Submit.
2. The web browser (Safari, Firefox) is stripping incoming POST data  
if it's coming from outside the application.
3. PHP somehow knows if the form data is being POSTed from inside the  
web browser or not (and fails on the latter).


Weird.

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



[PHP] Multi-threaded port listener

2006-04-28 Thread René Fournier
Anyone find any good tutorials, code samples, etc. on such a thing?  
Basically, I want to write server (in PHP) that listeners on a  
particular port, and spins off a thread/process (essentially, execute  
a separate script) for each incoming connection. There won't be a lot  
of data to process, but there will be many simultaneous connections— 
upwards of 1000s of connections (each spun off as seperate threads).


...Rene





[PHP] Possible?

2006-04-28 Thread René Fournier

Simple problem: Many client apps need to send data to a server.

By default each client will open a persistent TCP socket connection  
to a common IP address:port (10.10.10.10:1234) and write to it (which  
the server will save/log, etc.).


My question is, what should be ready to listen at the IP:port? I was  
thinking of writing a PHP command-line socket server that listens at  
that port. But there will be a potentially huge number of clients  
connecting simultaneously (1000s), not transmitting a lot of data per  
se, but a lot of connections... Anyway, instead I thought writing a  
simple PHP script—say, listener.php—that gets executed by the web  
server and enters a socket_read loop until the client terminates the  
connection (set_time_limit(0)).


Does this sound like a good way to do it? This way, Apache handles  
all the connections, and PHP is instantiated each time, but without  
having to fork processes, etc, and without having to do PHP CLI.


Anyway, I've started looking at this, but I'm not quite sure if it's  
even possible. I mean, can something send a request to Apache, and  
continue to write data along that TCP socket? Normally, HTTP requests  
include GET or POST for such data, but this is not a a web browser  
that's opening the connection.


Hope I'm somewhat clear. Just struggling through some options  
here Anyway, thanks in advance for any suggestions.


...Rene





Re: [PHP] Possible?

2006-04-28 Thread René Fournier
Anyway, I've started looking at this, but I'm not quite sure if  
it's even possible. I mean, can something send a request to  
Apache, and continue to write data along that TCP socket?  
Normally, HTTP requests include GET or POST for such data, but  
this is not a a web browser that's opening the connection.
Hope I'm somewhat clear. Just struggling through some options  
here Anyway, thanks in advance for any suggestions.

...Rene


 each client will open a persistent TCP socket connection to a
 common IP address:port (10.10.10.10:1234)

(If you want simultaneous connections, each TCP connection will be  
to a different port.)


Well, not if the client (actually, it's a pre-programmed physical  
device) is set to always open a socket connection to  
10.10.10.10:1234... right?


But rather than write a client and a server application from  
scratch, why not just use HTTP POSTs?


I'm not writing the client, I just need to make a server that can  
accept numerous simultaneous incoming socket connections, and  
maintain them.


Maybe stream_select() as someone suggested? I suppose my question  
would be, can a single PHP socket server script, executed from the  
command-line, maintain 1000s of concurrent connections (there is not  
a lot of data incoming, btw)?


...Rene



[PHP] PHPMailer inserting unwanted spaces

2005-12-29 Thread René Fournier
Has anyone encountered this? I am composing an HTML email with  
PHPMailer, and for some reason PHPMailer is inserted spaces  
periodically, which breaks the formatting. I've looked through the  
docs, but can only find a setting for Word Wrap (which is set to 0).


...Rene

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



Re: [PHP] PHPMailer inserting unwanted spaces

2006-01-03 Thread René Fournier
Actually, I can send the example messages but here is another  
description of the same problem. (So PHPMailer is inserting line  
breaks, not spaces—or something is...)


http://sourceforge.net/tracker/index.php? 
func=detailaid=1267539group_id=26031atid=385708



On 30-Dec-05, at 5:37 AM, Lam Cheuk Hin wrote:


Can You Write The Strings/Text?

On 12/30/05, René Fournier [EMAIL PROTECTED] wrote:


Has anyone encountered this? I am composing an HTML email with
PHPMailer, and for some reason PHPMailer is inserted spaces
periodically, which breaks the formatting. I've looked through the
docs, but can only find a setting for Word Wrap (which is set to 0).

...Rene

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





--
lch2003


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



[PHP] String format best practice

2005-03-29 Thread René Fournier
I need to output a Hex value, e.g.:
686E8AF8
In the following format:
68 6E 8A F8
In other words, separated by spaces. Now I realize there are a million 
ways to do this, but I would like a suggestion on which you think is 
the most efficient? Incidentally, I'm starting with a decimal value 
(23602210718), so maybe sprintf would be a direct way?

...Rene

Best regards,
René Fournier
---
René Fournier
GPS Police.NET
31, 1339 - 40th Ave NE
Calgary, AB  T2E 8N6
Canada
Tel +1 (403) 250.
Fax +1 (403) 291-2997
www.gpspolice.net
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Sprintf?

2005-03-29 Thread René Fournier
I need to go from
1754210747 (decimal)
to
17 54 21 a7 47 (hex per character)
Basically, reformat the string for each character, converting it to 
Hex, and spacing after each two characters. Sprintf?

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


Re: [PHP] Re: Create MDB File

2005-03-31 Thread René Fournier
Coincidentally, I also need a way to read a table from MySQL and write 
it out to an .MDB file on-the-fly (from within a PHP script).

The CSV export idea isn't an option in this case.
Has anyone found a way to create an MDB file (with a single table) from 
PHP?

...Rene

On 28-Mar-05, at 7:18 PM, Rory Browne wrote:
MDB suggests Access, so why not simply create a CSV, or some other
generic format file from your MySQL, and import it into access, using
COM/OLE, and save it as an MDB file.
On Mon, 28 Mar 2005 22:14:07 +0100, Shaun 
[EMAIL PROTECTED] wrote:
Thanks for your reply,
but this only works on Windows. I need a program that will create an 
MDB
file on the fly from a query on the MySQL database...

Johannes Findeisen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Sorry,
i forgot that link:
http://www.convert-in.com/sql2acc.htm
On Monday 28 March 2005 22:46, Johannes Findeisen wrote:
Hello,
i had the same problem some years ago. At this time i have set up 
all
tables in Access and wrote a script which reads from MySQL and 
inserts
into
the MDB file via the ODBC connector. This works but is much work 
when
your
database is very big.

2 Years ago i had the same problem but it must go as fast as 
possible so

i
decided to buy a converteer since i didn't find anything free. They 
are
working very good. I don't know where i have buyed them but i think
there
is only one company which delivers this software.
Regards
Johannes
On Monday 28 March 2005 22:08, Shaun wrote:
Hi,
Does anyone know if its possible to create an MDB file from a Mysql
database using a PHP script, I have only managed to find Access to
Mysql
conversion programs so far...
Thanks for your help
--
# Johannes Findeisen
--
# Johannes Findeisen
--
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


[PHP] Can this code go faster?

2005-04-26 Thread René Fournier
I've looked in the docs and don't see anything for this per se...
I need to convert a binary number of arbitrary length to a signed 
integer.
This is how I'm doing it now:

CODE

function bin2int ($bin) {
if (substr($bin,0,1) == 1) {
$val = 0 - bindec(substr($bin,1));  // NEGATIVE
} else {
$val = bindec(substr($bin,1));  // POSITIVE
}
}
echo bin2int(1101).'br /';
echo bin2int(10001101);
OUTPUT

13
-13
As you can see, if the most-significant bit is 1, then the rest of the 
value is negative. If the first bit is 0, then the rest is positive. Is 
there a better, faster (execution-wise) way of doing this? Maybe a more 
built-in function of PHP I missed? It's something that my script will 
be doing thousands of times, so I am concerned about speed.

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


[PHP] PHP cli on Mac OSX

2003-07-30 Thread René Fournier
Hello,

I installed Entropy package of PHP on my 10.2.6 OSX 
(http://www2.entropy.ch/download/Entropy-PHP-4.3.2-5.dmg), which states 
that it includes PHP command line. But when I go to Terminal and type 
PHP somescript.php4, it returns Command not found.

What am I missing?

...Rene

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


[PHP] Sockets tutorial problem in Mac OSX

2003-07-31 Thread René Fournier
Hello,

I'm just getting my feet wet with a Dev Shed sockets tutorial 
(http://www.devshed.com/Server_Side/PHP/SocketProgramming/page5.html).  
I am having a little problem with one of the tutorial code samples, 
which should socket_write some text back to the client--except it's not 
doing that.  Here's the snippet:



// write a welcome message to the client
$welcome = Roll up, roll up, to the greatest show on earth!\n? ;
socket_write($spawn, $welcome, strlen ($welcome)) or die(Could not send
connect string\n);
// keep looping and looking for client input
do
{
// read client input
$input = socket_read($spawn, 1024, 1) or die(Could not read input\n);
if (trim($input) != )
{
echo Received input: $input\n;
// if client requests session end
if (trim($input) == END)
{
// close the child socket
// break out of loop
socket_close($spawn);
break;
}
// otherwise...
else
{
// reverse client input and send back
$output = strrev($input) . \n;
socket_write($spawn, $output . ? , strlen (($output)+2)) or die(Could
not write output\n);
echo Sent output:  . trim($output) . \n;
}
}
} while (true);



And the output to the Telnet client:
[Valhalla:~] rene% telnet 192.168.0.77 1234
Trying 192.168.0.77...
Connected to 192.168.0.77.
Escape character is '^]'.
Roll up, roll up, to the greatest show on earth!
? Hello, this is a test.
END
Connection closed by foreign host.
[Valhalla:~] rene%


Server output:
% /usr/local/php/bin/php -q socket3.php4
Waiting for connections...
Received connection request
Received input: Hello, this is a test.
Sent output: .tset a si siht ,olleH
Received input: END
Socket terminated
This is almost exactly the same code as that used in the very first 
example, with the obvious addition of debug messages and a do-while 
loop [Valhalla:~] rene%

According to the tutorial, the client should see the string reversed, 
but that's not happening... In the previous tutorial example it did 
reverse and output to the client, and the code looks identical, save 
for the do...while loop. Here's what the tutorial says should happen:



Here's the output of a sample session:
$ telnet 192.168.1.99 1234
Trying 192.168.1.99...
Connected to medusa.
Escape character is '^]'.
Roll up, roll up, to the greatest show on earth!
? Look Ma...all backwards
sdrawkcab lla...aM kooL
? jack frost
tsorf kcaj
? END
Connection closed by foreign host.
And here are the corresponding debug messages generated on the server:
$ /usr/local/bin/php -q server.php
Waiting for connections...
Received connection request
Received input: Look Ma...all backwards
Sent output: sdrawkcab lla...aM kooL
Received input: jack frost
Sent output: tsorf kcaj
Received input: END
Socket terminated


Any ideas?

...Rene

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


[PHP] Yet another socket question...

2003-07-31 Thread René Fournier
Is it normal for a socket server to output all the echo'd messages only 
after the socket terminates? According to the source code, I would 
think that during its execution any echo text; commands would output 
to Terminal, but in practice (at least under Mac OSX), it's only after 
the Socket terminates that those messages appear. Is this normal?

...Rene

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


Re: [PHP] Yet another socket question...

2003-07-31 Thread René Fournier
On Thursday, July 31, 2003, at 02:45  PM, Chris Shiflett wrote:

--- René_Fournier [EMAIL PROTECTED] wrote:
Is it normal for a socket server to output all the echo'd
messages only after the socket terminates?
Can you explain what situation you're trying to describe? For example, 
echo
does not write to a socket, so there's more going on than you're 
telling us.
I know, but I'm not talking about writing to the socket, just echoing 
to the local Server command line. I would expect the echo'd text to 
appear in the server terminal window as the script runs--but it only 
appears when the server terminates. Here's the code:

?

set_time_limit (0);
$host = 192.168.0.77;
$port = 1234;
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die(Could not 
create
socket\n);
$result = socket_bind($socket, $host, $port) or die(Could not bind to
socket\n);
$result = socket_listen($socket, 3) or die(Could not set up socket
listener\n);

echo Waiting for connections...\n;

$spawn = socket_accept($socket) or die(Could not accept incoming
connection\n);
echo Received connection request\n;

$welcome = Welcome!\n ;
socket_write($spawn, $welcome, strlen ($welcome)) or die(Could not send
connect string\n);
$input = socket_read($spawn, 1024) or die(Could not read input\n);
socket_write($spawn, strrev($input), strlen ($input)) or die(Could not 
send\n);
socket_close($spawn);

socket_close($socket);
echo Socket terminated\n;
?



(Now I start the server:)
[Valhalla:~] rene% /usr/local/php/bin/php socket5.php4


(In another terminal window:)
[Valhalla:~] rene% telnet 192.168.0.77 1234
Trying 192.168.0.77...
Connected to 192.168.0.77.
Escape character is '^]'.
Welcome!

(Now, even though the server is running and a socket is connected, the 
server window does not echo Waiting for connections)



In the client window, I type:
 Hello world
dlrow olleHConnection closed by foreign host.
[Valhalla:~] rene%
(Now something happens in the server window:)
[Valhalla:~] rene% /usr/local/php/bin/php socket5.php4
Waiting for connections...
Received connection request
Socket terminated
 [Valhalla:~] rene%




(But when you look at the source code, shouldn't the Waiting for 
connections display as soon as the server is running, or at least when 
I try to telnet to it? Why would it wait until terminated??)



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


[PHP] The stupidest question of the month.

2003-07-17 Thread René Fournier
(Okay, now you're prepared...)

I need to write a little program that opens and maintains a TCP socket 
connection to a server across the Internet. This little program would 
wait for messages from the server it's connected to, then record those 
messages and send a kinda of acknowledgment Got it.

I've written a fair amount of PHP scripts for web sites, but nothing 
that would run in the background, independently say of a web browser or 
server. In other words, I don't really know what I'm doing, or where to 
start. I've looked at PHP.net's socket docs, but everything seems to 
scream experimental, use at own risk, etc. This little program, while 
operationally simple, needs to be very reliable. For example, if the 
socket connection dies for some reason, it would know to open a new 
one. Or if the server doesn't acknowledge my little program's periodic 
Hey, you still there-type pings, it would close the connection and 
reopen a new one. (In fact, at the end of this message I'll list the 
basic operation and flow of the little program as stated by the company 
running the server to which I would connect.)

In any case, what I want to know is, can this be done with PHP on a 
run-of-the-mill PHP-savvy ISP? Or would I need something more 
configurable? Would I need to learn C and compile a UNIX program to do 
this? Any ideas where to start? Resources, links? Anything would be 
much appreciated Thanks very much in advance.

Here is how the little program should function, according to the 
Company:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

The following describes the basic operation and flow needed within the 
DC:

Setup and open tcp socket using IP address and port number13
Send a Password_DS to the DS
Send a Resend_DS to the DS
Enter infinite loop:
Wait for messages from the DS
Upon receipt of a Send_DS from the DS
Store message contents appropriately
Send a Send_DS_Ack to the DS
Send message contents to other CSP applications
Upon receipt of a Ping_DS
Respond with a Ping_DS_Ack
Upon receipt of a Status_DS
Respond with a Status_DS_Ack
If needed, send message to other CSP process(es)
Periodically, send a Ping_DS to the DS
If the Ping_DS transmit fails
Clean-up and restart the socket connection
If a Ping_DS_Ack is not received from the DS
Clean-up and restart the socket connection
In this sequence, the data formats for the messages must follow the 
requirements
shown earlier. I.e., the Startup_DS message must include the correct 
client type;
the Send_DS_Ack messages must include the hostID and sequenceID data, 
etc. The
data contents received by the DC will usually be formatted and 
forwarded to
other CSP-internal procedures for further processing.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

...Rene

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


[PHP] Socket programming with PHP risky?

2003-07-21 Thread René Fournier
I've noticed in the PHP docs EXPERIMENTAL is marked over all the 
socket functions. Would it be risky to develop a PHP socket app using 
those functions? It seems they could change with the next release and 
my app would instantly stop working.

On the other hand, I've found a lot of tutorials extolling PHP's socket 
functions, and since I know PHP a bit now I would rather use it for my 
TCP socket application than learn C and implement it there.

What do you think?

...Rene

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


[PHP] str_replace() problem

2003-03-31 Thread René Fournier
I am performing a str_replace() on a large string, and everything works 
fine, except that two of the elements I'm searching for (and replacing) 
have the same first letters. To keep it the issue clear, here's a 
simple example of what I'm talking about:

Blue
Blueberry
Now, if I use:

str_replace(Blue,Red,$paragraph);
str_replace(Blueberry,Strawberry,$paragraph);
...all occurrences of Blueincluding Blueberrywill be replaced with 
Red. The result will be something like:

Red
Redberry
...But what I want is...

Red
Strawberry
 I need str_replace to somehow only search for a complete occurrence of 
each item. How do I do that? I've read the docs, and I just can't see 
any examples.

Thanks.

...Rene

---
Ren Fournier,
[EMAIL PROTECTED]
Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com
SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Tricky sorting problem

2002-10-30 Thread René Fournier
(Well, at least it's tricky for me... :-)

I need to sort an array based on three numbers that are situated in the 
middle of each array element. For example:

$list[] is an array, and contains the following [unsorted] elements:

Super-S862-030.jpg
Super-S1162-040.jpg
Super-S874-010.jpg
Super-S1174-020.jpg

I want to sort $list based on those last three numbers, just before the 
extension, so that the new sort order is:

Super-S874-010.jpg
Super-S1174-020.jpg
Super-S862-030.jpg
Super-S1162-040.jpg

I tried writing my own sort function--but can't seem to get anywhere 
with it:

function cmp ($a,$b) {
	if (substr($a,-5,2) == substr($b,-5,2)) return 0;
	return (substr($a,-5,2)  substr($b,-5,2)) ? -1 : 1 ;
	}

usort($list,cmp);



Any ideas? (Thanks.)

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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



Re: [PHP] Tricky sorting problem

2002-10-30 Thread René Fournier
It works! Thanks.

On Wednesday, October 30, 2002, at 10:50  AM, @ Edwin wrote:


...and the 2 should be 3 :)

- E

Marek Kilimajer [EMAIL PROTECTED] wrote:


the -5 should be -7

René Fournier wrote:


(Well, at least it's tricky for me... :-)

I need to sort an array based on three numbers that are situated in
the middle of each array element. For example:

$list[] is an array, and contains the following [unsorted] elements:

Super-S862-030.jpg
Super-S1162-040.jpg
Super-S874-010.jpg
Super-S1174-020.jpg

I want to sort $list based on those last three numbers, just before
the extension, so that the new sort order is:

Super-S874-010.jpg
Super-S1174-020.jpg
Super-S862-030.jpg
Super-S1162-040.jpg

I tried writing my own sort function--but can't seem to get anywhere
with it:

function cmp ($a,$b) {
if (substr($a,-5,2) == substr($b,-5,2)) return 0;
return (substr($a,-5,2)  substr($b,-5,2)) ? -1 : 1 ;
}

usort($list,cmp);



Any ideas? (Thanks.)

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada





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




---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




[PHP] Is there an ISP that supports GD Library 2.0?

2002-10-31 Thread René Fournier
I'm going to need it for a site I'm working on
Any suggestions are much appreciated.


---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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




[PHP] Removing duplicates in multi-dimensional array

2002-11-14 Thread René Fournier
I'm finding this one hard to approach...

I have a two-dimensional array, containing customer contact 
information. Looks like:

$myarray[0][0] = Microsoft;
$myarray[0][1] = Bill;
$myarray[0][2] = 123-1234;

$myarray[1][0] = Apple;
$myarray[1][1] = Steve;
$myarray[1][2] = 456-1234; 

$myarray[2][0] = Oracle;
$myarray[2][1] = Larry;
$myarray[2][2] = 987-4321;

$myarray[3][0] = Pixar;
$myarray[3][1] = Steve;
$myarray[3][2] = 456-1234; 

What I want to do is remove records that have the same fax number, so 
that each fax number occurs only once. For example,  $myarray[1][2] and 
$myarray[3][2] are the same--I would like to remove/unset one of them.

I know that array_unique() will do this for one-dimensional arrays, but 
I'm kinda stuck here, since the repeating element is in the second 
dimension. Any ideas how I might do this?

Thanks.

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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



[PHP] How to implode multi-dimensional arrays?

2002-11-14 Thread René Fournier
The docs don't seem to discuss this... Or maybe I'm looking in the 
wrong place. Anyway, I want to convert a multidimensional array back to 
the tab-delimited format it began as (\t separating fields, \n 
seperating records/rows)...  Any ideas???

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


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



[PHP] Simple array question

2003-10-22 Thread René Fournier
Is there a simple way to return the key (name) of one element in an 
array? I looked up key() in the docs, but there are no examples or 
notes...

Thanks.

...Rene

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


[PHP] Check mysq_field_type, display appropriate FORM element

2003-10-22 Thread René Fournier
Hello everyone,

I'm upgrading my simple CMS app, and would like to add a [simple] 
function to itwhich I'm finding is no so simple (at least for me). To 
illustrate:

The user clicks Edit on a particular table row. The CMS then fetches 
that row from the table and begins displaying the value of each field 
in a form (which the user can then edit and at then click Update) . 
So far, so good.

What I want to add is a function that will, depending on the field type 
(text, set, enum), display the field value as either a textarea or 
selectoption. For example, for a field called status, which is of 
type ENUM, and can contain the values Online or Offline, I want 
this CMS function to return something like selectoption... along 
with the allowed values, with the active one selected.

Beyond this, I'd like to extend this check_field_type function to 
handle fields that contain links to images, etc. But this is where I 
need to start.

Thanks.

...Rene

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


[PHP] Tricky variable syntax...

2003-10-27 Thread René Fournier
I'm trying to refer to a variable using $$, but with a twist. So far,
this works:
	echo 'temp file: '.$$fld.'br';

In this case, $fld equals img_photo (although it could be anything).
The above statement could have thus been echo 'file name:
'.$img_photo.'br'; with the same results. So here I actually echo
the value of the variable $img_photo. This is what I want.

But here's my problem:
	echo 'file name: '.$$fld_name.'br';

What I want to do is echo the value of $img_photo_name. But how can I
refer to it?
Thanks.

...Rene

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


[PHP] Copying an uploaded file...

2003-10-29 Thread René Fournier
I'm trying to get a little upload script working... But I can't seem to 
copy the tmp file to my local web directory (btw, do I really need to 
specify the path, or can I just use a filename, and the file will be 
written to the same directory as the PHP script??).  Anyway, here is 
the code:

$realname = $_FILES['userfile']['name'];
if(copy($_FILES['userfile']['tmp_name'],
'/Users/rene/Sites/renefournier/titan/res/'.$realname)) {
echo $realname.' uploaded';
} else {
echo $realname.' could not be uploaded';
}
echo 'br';
echo name: .$_FILES[$fld]['name'];
echo 'br';
echo type: .$_FILES[$fld]['type'];
echo 'br';
echo size: .$_FILES[$fld]['size'];
echo 'br';
echo tmp: .$_FILES[$fld]['tmp_name'];
echo 'br';
Here is the output:

could not be uploaded
name: web_share.gif
type: image/gif
size: 13370
tmp: /var/tmp/phpNqigbO


Thanks for any ideas.

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


Re: [PHP] Copying an uploaded file...

2003-10-29 Thread René Fournier
Thanks John. I've simplified and improved the quote per your  
suggestions, but still no dice. (I'[m running OS X 10.2.8.) Here is the  
code:

 // MOVE FILE
 if  
(move_uploaded_file($_FILES['userfile']['tmp_name'],$_FILES['userfile'][ 
'name'])) {
 echo Success!;
 } else {
 echo NO!!!;
 }

 Here are the results:

 NO!!!
 Array ( [img_photo] = Array ( [name] =  
apache_pb.gif [type] = image/gif [tmp_name] =  
/var/tmp/phpvnTFqr [error] = 0 [size] = 2326   
   )  )

Should the tmp directory maybe be set elsewhere? (If so, how can that  
be done? I've looked at the httpd.conf file, but there is no entry for  
upload tmp directory.)

Many thanks in advance.

...Rene

On Wednesday, October 29, 2003, at 12:41 PM, John Nichel wrote:

René Fournier wrote:
I'm trying to get a little upload script working... But I can't seem  
to copy the tmp file to my local web directory (btw, do I really need  
to specify the path, or can I just use a filename, and the file will  
be written to the same directory as the PHP script??).  Anyway, here  
is the code:
$realname = $_FILES['userfile']['name'];
if(copy($_FILES['userfile']['tmp_name'],
'/Users/rene/Sites/renefournier/titan/res/'.$realname)) {
echo $realname.' uploaded';
} else {
echo $realname.' could not be uploaded';
}
PHP has built in functions to move the temp file for you

http://us3.php.net/manual/en/function.move-uploaded-file.php

echo 'br';
echo name: .$_FILES[$fld]['name'];
echo 'br';
echo type: .$_FILES[$fld]['type'];
echo 'br';
echo size: .$_FILES[$fld]['size'];
echo 'br';
echo tmp: .$_FILES[$fld]['tmp_name'];
echo 'br';
Do you know about print_r?

pre
?php print_r ( $_FILES ); ?
/pre
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
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] Copying an uploaded file...

2003-10-29 Thread René Fournier
Thanks John. I've simplified and improved the quote per your  
suggestions, but still no dice. (I'[m running OS X 10.2.8.) Here is the  
code:

 // MOVE FILE
 if  
(move_uploaded_file($_FILES['userfile']['tmp_name'],$_FILES['userfile'][ 
'name'])) {
 echo Success!;
 } else {
 echo NO!!!;
 }

 Here are the results:

 NO!!!
 Array ( [img_photo] = Array ( [name] =  
apache_pb.gif [type] = image/gif [tmp_name] =  
/var/tmp/phpvnTFqr [error] = 0 [size] = 2326   
   )  )

Should the tmp directory maybe be set elsewhere? (If so, how can that  
be done? I've looked at the httpd.conf file, but there is no entry for  
upload tmp directory.)

Many thanks in advance.

...Rene

On Wednesday, October 29, 2003, at 12:41 PM, John Nichel wrote:

René Fournier wrote:
I'm trying to get a little upload script working... But I can't seem  
to copy the tmp file to my local web directory (btw, do I really need  
to specify the path, or can I just use a filename, and the file will  
be written to the same directory as the PHP script??).  Anyway, here  
is the code:
$realname = $_FILES['userfile']['name'];
if(copy($_FILES['userfile']['tmp_name'],
'/Users/rene/Sites/renefournier/titan/res/'.$realname)) {
echo $realname.' uploaded';
} else {
echo $realname.' could not be uploaded';
}
PHP has built in functions to move the temp file for you

http://us3.php.net/manual/en/function.move-uploaded-file.php

echo 'br';
echo name: .$_FILES[$fld]['name'];
echo 'br';
echo type: .$_FILES[$fld]['type'];
echo 'br';
echo size: .$_FILES[$fld]['size'];
echo 'br';
echo tmp: .$_FILES[$fld]['tmp_name'];
echo 'br';
Do you know about print_r?

pre
?php print_r ( $_FILES ); ?
/pre
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
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] Copying an uploaded file...

2003-10-29 Thread René Fournier
I've added a path, but still no success

On Wednesday, October 29, 2003, at 05:11 PM, John Nichel wrote:

René Fournier wrote:
Thanks John. I've simplified and improved the quote per your   
suggestions, but still no dice. (I'[m running OS X 10.2.8.) Here is  
the  code:
 // MOVE FILE
 if   
(move_uploaded_file($_FILES['userfile']['tmp_name'],$_FILES['userfile' 
][ 'name'])) {
 echo Success!;
 } else {
 echo NO!!!;
 }
 Here are the results:
Give it a path for the file to be moved too...

if(move_uploaded_file($_FILES['userfile']['tmp_name'],  
/path/to/save/ . $_FILES['userfile']['name'])) {

 NO!!!
 Array ( [img_photo] = Array ( [name] =   
apache_pb.gif [type] = image/gif [tmp_name]  
=  /var/tmp/phpvnTFqr [error] = 0 [size] =  
2326  )  )
Should the tmp directory maybe be set elsewhere? (If so, how can that  
 be done? I've looked at the httpd.conf file, but there is no entry  
for  upload tmp directory.)
Many thanks in advance.
...Rene
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
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] Copying an uploaded file...

2003-10-30 Thread René Fournier
Ah, man, I just found my problem, and do I ever feel stupid... Thought 
I'd share it to highlight the it's right in front of one's nose 
feeling:

copy($_FILES['userfile']['tmp_name']...

...was a sample code snippet. I had just copied and pasted it without 
changing the userfile partand since there was no 'userfile' in my 
form, it would never have worked. Using my own variable pointer $fld 
works. Thus:

copy($_FILES[$fld]['tmp_name'].

...works. And that is all.

In any case, thanks for the suggestions.

...Rene

On Wednesday, October 29, 2003, at 11:28 PM, John Nichel wrote:

Ren Fournier wrote:
I've added a path, but still no success
Does your webserver (Apache?) have write permission to the directory 
you're trying to move the file too?

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com

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


[PHP] mysql_field_type() ...

2003-11-03 Thread René Fournier
...will say if a field is of type ENUM, but not its possible values 
(including default). Does anyone know how I can fetch possible values 
of a field type of ENUM?

Thanks.

...Rene

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


[PHP] Sweet PHP backup / dump function for MySQL database

2003-11-04 Thread René Fournier
Right now, I'm using phpMyAdmin to periodically backup/dump a client 
MySQL database to a textfile (from which one can simply restore the 
database if it ever got corrupted). I'm also working on a super-simple 
CMS for the client to use themselves. I would like the client to also 
be able to easily backup his web site's MySQL database to a textfile 
and have that textfile emailed to whatever address he specifies. Sort 
of a two step approach:

Enter email _
 Backup and send database  (click)
I imagine someone somewhere has written a very nice function for doing 
this, which might take a few parameters, such as database, destination 
email address, etc. The main thing is that the function include 
complete inserts, extended inserts, backquotes, etc.

Anyone have a sweet function like this they wanna share, and in so 
doing make the world a better place?  :-)

...Rene

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


[PHP] GD question

2003-11-16 Thread René Fournier
I want to write a function the creates a new image composited from a 
3x3 tile. The idea is that the center tile will be a photo, and the 
surrounding eight images will constitute a border and shadow to the 
composited image. So... The eight border/shadow images will always be 
the same, but the center image will be unique.

Anyways, I've been playing with GD functions for a little while, and 
would appreciate any suggestions on how to accomplish this. I haven't 
been able to find a good tutorial on this kind of thing 
specificallycompositing tiles of images into a single image.

Any ideas?

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


[PHP] Problems with imagejpeg

2003-12-27 Thread René Fournier
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 happening though. Here's what I've got  
($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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] HELP! -- Problem with imagejpeg()

2003-12-27 Thread René Fournier
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] regular expressions

2004-04-09 Thread René Fournier
I'm trying to 'clean up' some text that is extracted from a web 
directory, and I need to use (I think) preg_replace or ereg_replace, 
etc. I've read a bunch of tutorials, but none of them seem to cover the 
particular thing I want to do. Here's an example of text I need to 
process:

-

J.  Smith   ( More Info )
map
driving directions
add to My Directory
update or remove
Did you go to High School with J.  Smith?
 
B. Dixon   ( More Info )
map
driving directions
add to My Directory
update or remove
Did you go to High School with B. Dixon?

M.  Jones   ( More Info )
map
driving directions
add to My Directory
update or remove
Did you go to High School with M.  Jones?

-

The above is a string. I want to eliminate, for example, all the lines 
that say Did you... ?, but I don't know how to refer to them because 
they are each a little different (because of the name). I know regular 
expressions can do this, but I can't seem to wrap my mind around the 
necessary arguments... This being my first foray into regex. I've 
written feeble stuff like:

$result = ereg_replace(Did you go\[a-zA-Z]\?,,$result);

But of course it doesn't work. Any ideas?  Thanks.

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


[PHP] Socket client application

2004-04-13 Thread René Fournier
Hi,

I've gone through several good PHP sockets tutorials, but all of them 
seem to focused on making socket servers. What I actually need to do is 
write a socket client. There's an app runnning on a distant server that 
accepts incoming TCP connections at such-and-such an IP address and 
port, and then responds to various commands and issues standard 
responses, etc.---I need to build the app that talks to it.

Now maybe I'm missing something really obvious, but I can't find any 
tutorials on what such a socket client app might look like. The client 
I need to build must maintain the connection once started.

Any ideas??

...Rene

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


[PHP] Socket Server problem

2004-04-15 Thread René Fournier
I'm working through Ori Staub's excellent Socket Server tutorial 
(http://www.zend.com/zend/tut/tutorial-staub3.php), but can't get the 
sample server working. I've read the user comments and fixed a couple 
things, but still, no dice. Here's the error I receive:

[Valhalla:~/Sites/test] rene% /usr/local/php/bin/php s9.php
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30
PHP Notice:  Undefined variable:  client in 
/Users/rene/Sites/test/s9.php on line 30

...and then it just hangs. Since I'm so new to sockets, and probably 
don't yet grasp the concepts perfectly, I'm a little lost where to 
start. Any ideas?

Here's my code:

?

// VARIABLES
set_time_limit(0);
$server_ip = 192.168.0.200;
$server_port = 7000;
$max_clients = 10;
// Array will hold client info
$clients = Array();
// Create TCP stream socket
$sock = socket_create(AF_INET,SOCK_STREAM,0);
// Bind the socket
socket_bind($sock,$server_ip,$server_port) or die('Could not bind to 
address');

// Start listening...
socket_listen($sock);
// Loop
while (true)
{
// Setup clients listen socket for reading
$read[0] = $sock;
for ($i = 0; $i  $max_clients; $i++)
{
if ($client[$i]['sock'] != null) $read[$i+1] = $client[$i]['sock'];
}
// Set up a blocking call to socket_select()
$ready = socket_select($read,$null=null,$null=null,$null=null);


// If a new connection is being made add it to the client array
if (in_array($sock,$read))
{
$cur_conn = count($client);
for ($i = 0; $i  $cur_conn; $i++)
{
if ($client[$i]['sock'] == null)
{
$client[$i]['sock'] = socket_accept($sock);
break;
} elseif ($i == $max_clients - 1)
print (too many clients);
}
if (--$ready = 0)
continue;
} // end if in_array



// If a client is trying to write, deal with it
$cur_conn = count($client);
for ($i = 0; $i  $cur_conn; $i++) // for each client
{
if (in_array($client[$i]['sock'],$read))
{
$input = socket_read($client[$i]['sock'],1024);
if ($input == null) { // Zero length string meaning 
disconnected
unset($client[$i]);
}   
if ($input == 'exit') { // requested disconnect
socket_close($client[$i]['sock']);
} elseif ($input) { // strip whitespace and writeback 
to user
$output = ereg_replace([ 
\t\n\r],,$input).chr(0);
$socket_write($client[$i]['sock'],$output);
}
} else {
// Close the socket
socket_close($client[$i]['sock']);
unset($client[$i]);
}
}
} // end while

// Close the master sockets
socket_close($sock);

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


[PHP] Socket server with multiple connections

2004-04-23 Thread René Fournier
I've gone through a few good socket client and server tutorials (such 
as http://www.devshed.com/c/a/PHP/Socket-Programming-With-PHP/), and 
have got the samples working. What I'm trying to do now is write a 
simple Socket Server that will accept multiple connections, do its 
thing, and keep running.

This Zend tutorial (http://www.zend.com/zend/tut/tutorial-staub3.php) 
does explain the concepts pretty well, but I cannot for the life of me 
get the sample code to run. The user comments noticed a couple typos, 
and other errors, which I've fixed, but still... no dice. I'm running 
PHP Version 4.3.4 on Mac OSX 10.2.8. Here's the error message:

--
[Valhalla:~/Sites/sockets/test] rene% /usr/local/php/bin/php s9.php
PHP Notice:  Undefined offset:  0 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  0 in /Users/me/Sites/sockets/test/s9.php on 
line 20
PHP Notice:  Undefined offset:  1 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  1 in /Users/me/Sites/sockets/test/s9.php on 
line 20
PHP Notice:  Undefined offset:  2 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  2 in /Users/me/Sites/sockets/test/s9.php on 
line 20
PHP Notice:  Undefined offset:  3 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  3 in /Users/me/Sites/sockets/test/s9.php on 
line 20
PHP Notice:  Undefined offset:  4 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  4 in /Users/me/Sites/sockets/test/s9.php on 
line 20
PHP Notice:  Undefined offset:  5 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  5 in /Users/me/Sites/sockets/test/s9.php on 
line 20
PHP Notice:  Undefined offset:  6 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  6 in /Users/me/Sites/sockets/test/s9.php on 
line 20
PHP Notice:  Undefined offset:  7 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  7 in /Users/me/Sites/sockets/test/s9.php on 
line 20
PHP Notice:  Undefined offset:  8 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  8 in /Users/me/Sites/sockets/test/s9.php on 
line 20
PHP Notice:  Undefined offset:  9 in 
/Users/me/Sites/sockets/test/s9.php on line 20

Notice: Undefined offset:  9 in /Users/me/Sites/sockets/test/s9.php on 
line 20
--
Here my code:
--
?

// VARIABLES
set_time_limit(0);
$server_ip = 192.168.0.200;
$server_port = date(i).000;


// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die(Could not 
create
socket\n);

// bind socket to port
$result = socket_bind($socket, $server_ip, $server_port) or die(Could 
not bind to
socket\n);

// start listening for connections
$result = socket_listen($socket, 3) or die(Could not set up socket
listener\n);
echo Waiting for connections...\n;

// accept incoming connections
// spawn another socket to handle communication
$spawn = socket_accept($socket) or die(Could not accept incoming
connection\n);
echo Received connection request\n;

// write a welcome message to the client
$welcome = Welcome to the Server!\n .chr(0);
socket_write($spawn, $welcome, strlen ($welcome)) or die(Could not send
connect string\n);
// keep looping and looking for client input
do
{
// read client input
$input = socket_read($spawn, 1024) or die(Could not read 
input\n);

if (trim($input) != )
{
  echo Received input: $input\n;

  // if client requests session end
  if (trim($input) == END)
  {
// close the child socket
// break out of loop
socket_close($spawn);
break;
  }
  // otherwise...
  else
  {
// reverse client input and send back
$output = strtoupper($input);
socket_write($spawn, $output) or die(Could
not write output\n);
echo Sent output:  . trim($output) . \n;
  }
}
} while (true);

// close primary socket
socket_close($socket);
echo Socket terminated\n;

?
---
Any ideas?

...Rene

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


[PHP] Constant questions

2004-05-12 Thread René Fournier
Hi,

I have two questions involving Constants.

1. I want to refer to a refer to a Constant by its value (which is 
unique), and return its name. E.g.,:

define (SEND_DS,1);
define (SEND_DS_ACK,2);
define (RESEND_DS,3);
define (STARTUP_DS,12);
For example, if I receive 3, I would like to echo RESEND_DS--the 
name of the constant. Is there a simply way to do this? Or am I better 
using an Associative Array (which is what I was thinking)? Then I could 
such refer to an element by its key or value (both of which are 
unique). I suppose this more of a performance/elegance issue, than 
outright problem. Just curious what you think.

2. Let's say I have a Constant called MY_NAME, the value of which is 
Rene, and I pass it to a function, such as:

function example ($val) {
echo ???;
}
example (MY_NAME);

Such that the output will be MY_NAME. If I echo $val, the output will 
be Rene. But I want to see the constants Name, not Value. Any ideas?

Thanks.

...Rene

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


  1   2   >