Re: [PHP] 2 Questions.
On Sun, 2008-09-14 at 03:42 +0200, Jochem Maas wrote: Yo Dan, your back! guess the honeymoon is well and truly over then ;-) Daniel Brown schreef: On Sat, Sep 13, 2008 at 8:14 PM, tedd [EMAIL PROTECTED] wrote: While you might think an order number should be something else, keep in mind that an order is simply an order. It is a point in time where a customer has agreed to purchase something and you have accepted and have cleared that purchase for that payment through some sort of purchasing scheme. One of the best schemes for developing a unique order number that is not only unique to the system, but is also readily human-readable would be to use an auto_increment value appended to a date string. For example: ?php $today = date(Ymd); $increment = $numberFromDB; // This routine would depend on your database (MySQL, PostgreSQL, etc.) $orderNumber = $today.-.$increment; ? From the above, you'd get an order number similar to 20080913-1048. This means that it's not only unique, regardless of how many orders come through in the same second, but ordering by time and date is easier, and on paper, you can easily tell when an order was placed. a handy trick, I would suggest this belong in the display layer of the app not in the DB. I was originally taught DB stuff from someone who was hot in FoxPro in the 80's ... back then it was normal to encode all sorts of info into unique identifiers (much like the way you describe) for the simple reasons of lack of disk space, cpu power and screen space ... these days best practice is generally accepted to be that a unique identifier is purely that and no more ... adding 'cruft' to a UID pollutes it and I would hazard to call it data-bastardization[tm] ... the date can (and should) be stored as a seperate field, output from the DB can always be displayed as you described. I think I see what your problem is. Basically, you've set the tables up in the wrong way. Every order system I've used has one table for the orders, one for the customers, and one for the items attached to an order. This makes management a lot easier, and you get to use those auto_increment values you so need. From what you've been saying I'm guessing this is a custom built system, so hopefully it shouldn't be too hard to change now if it's not finished. If it's something you have purchased to use... well, I'd look for something else... Ash www.ashleysheridan.co.uk
Re: [PHP] 2 Questions.
Tom Shaw schreef: -Original Message- From: Tom Shaw [mailto:[EMAIL PROTECTED] Sent: Saturday, September 13, 2008 9:52 PM To: 'Jochem Maas' Subject: RE: [PHP] 2 Questions. iamjochem wrote: My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. have your simple wrapper do something like: $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1; with regard to generating the query. if your wrapper doesn't generate the SQL then you'll have to parse the given SQL and rewrite it ... good luck with that. I'm not sure if my wrapper is a good place for the sql but I bet it's worth investigating further. I like the web site iamjokem. Im not sure if that's a jokem too but I couldn't figure it out... it's jochem not jokem, so technically there's no joke. but you could say the 'site' is my answer to the social grid. or maybe a reaction to all the twitter like nonsense, or maybe just the fact that everyone seems to think the answer is out there, when really the only answer is 'in here' take the red pill/door. it's the only choice ;-) .. generating SQL is pretty easy, give a function a list of fields as an array and a table name (you can then build the function out to include order by and where clause generation. here is a very simple concept function (I wouldn't bother using it as is): function genSQL($fields, $table, $where, $order) { $fnames = array(); foreach ($fields as $f) $fnames[] = $tablename.'_'.$f; return 'SELECT '.join(', ', $fnames). FROM $tablename $where $order; } I should have mentioned that I use a *normalized* database wharehousing pattern where each row represents a distinct item being purchased. There could be fifty rows corresponding to a single order transaction like what you would see in something like an itunes music purchase. So using the auto increment id would not work to differentiate between orders. Another user mentioned microtime. whoa, race car hey? let's have a race. normalized smormalized. every order related system I've looked at, built or worked with made a clear distinction between an **order** and an **orderline**, all you seem to have is an order line ... who do they belong to? are you replicating the customer details and shipping address in each row? (if so I hardly call that normalized) use generators or sequences or 'auto increment ids' or whatever your DB calls it, dump the timestamp/microtime nonsense, and rework you DB schema to incorporate order **and** orderline entities ... and use a required foreign key in each orderline to reference the relevant order. with regard to iTunes store, steve jobs can go shove it ... but I'll wadger my soul that the guys that built it know the difference between an order and an order line and that they use both concepts. so you understand your DB model was wrong/incomplete? and that timestamps of any granularity should not be used as UIDs? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 2 Questions.
That's cool thanks. I agree with you too it's mankind's folly. But regarding the db question, I got the idea from CakePHP which solves the problem of having to prefix your columns ie user_name etc etc. I think you can use another built in php database function num_fields() and hook into the meta data and then you would have to manually build the information into array. I'm not sure but I'm going to hack around with it a little and see what happens. Thanks Thomas -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Sunday, September 14, 2008 4:50 AM To: Tom Shaw Cc: 'PHP General' Subject: Re: [PHP] 2 Questions. Tom Shaw schreef: -Original Message- From: Tom Shaw [mailto:[EMAIL PROTECTED] Sent: Saturday, September 13, 2008 9:52 PM To: 'Jochem Maas' Subject: RE: [PHP] 2 Questions. iamjochem wrote: My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. have your simple wrapper do something like: $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1; with regard to generating the query. if your wrapper doesn't generate the SQL then you'll have to parse the given SQL and rewrite it ... good luck with that. I'm not sure if my wrapper is a good place for the sql but I bet it's worth investigating further. I like the web site iamjokem. Im not sure if that's a jokem too but I couldn't figure it out... it's jochem not jokem, so technically there's no joke. but you could say the 'site' is my answer to the social grid. or maybe a reaction to all the twitter like nonsense, or maybe just the fact that everyone seems to think the answer is out there, when really the only answer is 'in here' take the red pill/door. it's the only choice ;-) .. generating SQL is pretty easy, give a function a list of fields as an array and a table name (you can then build the function out to include order by and where clause generation. here is a very simple concept function (I wouldn't bother using it as is): function genSQL($fields, $table, $where, $order) { $fnames = array(); foreach ($fields as $f) $fnames[] = $tablename.'_'.$f; return 'SELECT '.join(', ', $fnames). FROM $tablename $where $order; } I should have mentioned that I use a *normalized* database wharehousing pattern where each row represents a distinct item being purchased. There could be fifty rows corresponding to a single order transaction like what you would see in something like an itunes music purchase. So using the auto increment id would not work to differentiate between orders. Another user mentioned microtime. whoa, race car hey? let's have a race. normalized smormalized. every order related system I've looked at, built or worked with made a clear distinction between an **order** and an **orderline**, all you seem to have is an order line ... who do they belong to? are you replicating the customer details and shipping address in each row? (if so I hardly call that normalized) use generators or sequences or 'auto increment ids' or whatever your DB calls it, dump the timestamp/microtime nonsense, and rework you DB schema to incorporate order **and** orderline entities ... and use a required foreign key in each orderline to reference the relevant order. with regard to iTunes store, steve jobs can go shove it ... but I'll wadger my soul that the guys that built it know the difference between an order and an order line and that they use both concepts. so you understand your DB model was wrong/incomplete? and that timestamps of any granularity should not be used as UIDs? -- 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] 2 Questions.
Can anybody give me any good reasons not to use a time stamp as an order number in my shopping cart. It seems to me that the number is guaranteed to be random and it saves having to make an extra time column to keep track of the order. The only small concern I have is the chance that somebody orders at the exact same time as somebody else but the chance of that has got to be incredibly small but possible. My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. Cheers Thomas Shaw [EMAIL PROTECTED]
Re: [PHP] 2 Questions.
On Sat, 2008-09-13 at 17:38 -0500, Tom Shaw wrote: Can anybody give me any good reasons not to use a time stamp as an order number in my shopping cart. It seems to me that the number is guaranteed to be random and it saves having to make an extra time column to keep track of the order. The only small concern I have is the chance that somebody orders at the exact same time as somebody else but the chance of that has got to be incredibly small but possible. My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. Cheers Thomas Shaw [EMAIL PROTECTED] Well, I think you answered the first part of your question yourself there! Although remotely small, it is entirely possible for two people to do something at the same time on your site. Why don't you use an auto_increment column in your table instead? There are plenty of functions in PHP to retrieve the auto_insert value (although generally different for each type of database you connect to, I only know how to do it in MySQL and MSSQL) This way, you let the database deal with the unique ID's as it's something the databases are very suited to, and you can then use the auto_insert ID in place of the value you would normally generate in PHP. Ash www.ashleysheridan.co.uk
Re: [PHP] 2 Questions.
Tom Shaw schreef: Can anybody give me any good reasons not to use a time stamp as an order number in my shopping cart. It seems to me that the number is guaranteed to be random and it saves having to make an extra time column to keep track of the order. The only small concern I have is the chance that somebody orders at the exact same time as somebody else but the chance of that has got to be incredibly small but possible. 1. order number are often *required* (for accounting purposes) to be consecutive 2. the chance is small, yet it is there ... agravated by the fact that most orders are placed during a concentrated period of the day. I have no idea what you mean by 'extra time column' and/or using it to keep track of an order... but most DBMSs have the ability to auto store a timestamp into a field when the given record is created. oh ... timestamps are hardly random. My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. have your simple wrapper do something like: $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1; with regard to generating the query. if your wrapper doesn't generate the SQL then you'll have to parse the given SQL and rewrite it ... good luck with that. Cheers Thomas Shaw [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 2 Questions.
I should have mentioned that I use a *normalized* database wharehousing pattern where each row represents a distinct item being purchased. There could be fifty rows corresponding to a single order transaction like what you would see in something like an itunes music purchase. So using the auto increment id would not work to differentiate between orders. Another user mentioned microtime. -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Saturday, September 13, 2008 6:06 PM To: Tom Shaw Cc: 'PHP General' Subject: Re: [PHP] 2 Questions. Tom Shaw schreef: Can anybody give me any good reasons not to use a time stamp as an order number in my shopping cart. It seems to me that the number is guaranteed to be random and it saves having to make an extra time column to keep track of the order. The only small concern I have is the chance that somebody orders at the exact same time as somebody else but the chance of that has got to be incredibly small but possible. 1. order number are often *required* (for accounting purposes) to be consecutive 2. the chance is small, yet it is there ... agravated by the fact that most orders are placed during a concentrated period of the day. I have no idea what you mean by 'extra time column' and/or using it to keep track of an order... but most DBMSs have the ability to auto store a timestamp into a field when the given record is created. oh ... timestamps are hardly random. My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. have your simple wrapper do something like: $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1; with regard to generating the query. if your wrapper doesn't generate the SQL then you'll have to parse the given SQL and rewrite it ... good luck with that. Cheers Thomas Shaw [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions.
At 5:38 PM -0500 9/13/08, Tom Shaw wrote: Can anybody give me any good reasons not to use a time stamp as an order number in my shopping cart. It seems to me that the number is guaranteed to be random and it saves having to make an extra time column to keep track of the order. The only small concern I have is the chance that somebody orders at the exact same time as somebody else but the chance of that has got to be incredibly small but possible. opinion based upon experience While time stamp is usually unique, it isn't always -- don't assume it will be unique. An order number should be a unique auto increment id (i.e., sequential) in your table. It should be representative of the customer's order -- it should contain the customer id; shipping/billing address; what the customer ordered (all items ordered); the time-date of the transaction; authorization code provided by the clearing house; and payment amount -- and basically nothing else (i.e., No credit card information). While you might think an order number should be something else, keep in mind that an order is simply an order. It is a point in time where a customer has agreed to purchase something and you have accepted and have cleared that purchase for that payment through some sort of purchasing scheme. It makes no difference if your dB is normalized, or relational, or some stock-boy working in a warehouse, or a phone order operator pressing an Done button. It is simply an order number. While you might think a microtime stamp would work, a unique auto increment id will work better. /opinion based upon experience My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. I'm not sure if I understand your question, but I'll try to answer what I think you are asking. Regardless of the dB, I find it best to have a configuration file that contains and defines all the variables re the dB (i.e., db_name, db_user, db_password, db_tablewhatever, and so on). That way, all you have to do is to include that file in your scripts. If you want to change something, you can change it in just one file. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions.
On Sat, Sep 13, 2008 at 8:14 PM, tedd [EMAIL PROTECTED] wrote: While you might think an order number should be something else, keep in mind that an order is simply an order. It is a point in time where a customer has agreed to purchase something and you have accepted and have cleared that purchase for that payment through some sort of purchasing scheme. One of the best schemes for developing a unique order number that is not only unique to the system, but is also readily human-readable would be to use an auto_increment value appended to a date string. For example: ?php $today = date(Ymd); $increment = $numberFromDB; // This routine would depend on your database (MySQL, PostgreSQL, etc.) $orderNumber = $today.-.$increment; ? From the above, you'd get an order number similar to 20080913-1048. This means that it's not only unique, regardless of how many orders come through in the same second, but ordering by time and date is easier, and on paper, you can easily tell when an order was placed. -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions.
At 8:26 PM -0400 9/13/08, Daniel Brown wrote: On Sat, Sep 13, 2008 at 8:14 PM, tedd [EMAIL PROTECTED] wrote: While you might think an order number should be something else, keep in mind that an order is simply an order. It is a point in time where a customer has agreed to purchase something and you have accepted and have cleared that purchase for that payment through some sort of purchasing scheme. One of the best schemes for developing a unique order number that is not only unique to the system, but is also readily human-readable would be to use an auto_increment value appended to a date string. For example: ?php $today = date(Ymd); $increment = $numberFromDB; // This routine would depend on your database (MySQL, PostgreSQL, etc.) $orderNumber = $today.-.$increment; ? From the above, you'd get an order number similar to 20080913-1048. This means that it's not only unique, regardless of how many orders come through in the same second, but ordering by time and date is easier, and on paper, you can easily tell when an order was placed. Nice to see you back my friend -- I was worried. An auto-increment field in a table is unique. While it doesn't include any time/date information, it is automatically assigned when the transaction is confirmed (i.e., INSERT). I've used both, but usually when I need a time/date stamp, I add that somewhere else in the table. However, these are just differences in style and not that one is better than the other. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions.
Tom Shaw schreef: I should have mentioned that I use a *normalized* database wharehousing pattern where each row represents a distinct item being purchased. There could be fifty rows corresponding to a single order transaction like what you would see in something like an itunes music purchase. So using the auto increment id would not work to differentiate between orders. Another user mentioned microtime. whoa, race car hey? let's have a race. normalized smormalized. every order related system I've looked at, built or worked with made a clear distinction between an **order** and an **orderline**, all you seem to have is an order line ... who do they belong to? are you replicating the customer details and shipping address in each row? (if so I hardly call that normalized) use generators or sequences or 'auto increment ids' or whatever your DB calls it, dump the timestamp/microtime nonsense, and rework you DB schema to incorporate order **and** orderline entities ... and use a required foreign key in each orderline to reference the relevant order. with regard to iTunes store, steve jobs can go shove it ... but I'll wadger my soul that the guys that built it know the difference between an order and an order line and that they use both concepts. -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Saturday, September 13, 2008 6:06 PM To: Tom Shaw Cc: 'PHP General' Subject: Re: [PHP] 2 Questions. Tom Shaw schreef: Can anybody give me any good reasons not to use a time stamp as an order number in my shopping cart. It seems to me that the number is guaranteed to be random and it saves having to make an extra time column to keep track of the order. The only small concern I have is the chance that somebody orders at the exact same time as somebody else but the chance of that has got to be incredibly small but possible. 1. order number are often *required* (for accounting purposes) to be consecutive 2. the chance is small, yet it is there ... agravated by the fact that most orders are placed during a concentrated period of the day. I have no idea what you mean by 'extra time column' and/or using it to keep track of an order... but most DBMSs have the ability to auto store a timestamp into a field when the given record is created. oh ... timestamps are hardly random. My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. have your simple wrapper do something like: $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1; with regard to generating the query. if your wrapper doesn't generate the SQL then you'll have to parse the given SQL and rewrite it ... good luck with that. Cheers Thomas Shaw [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 2 Questions.
-Original Message- From: Tom Shaw [mailto:[EMAIL PROTECTED] Sent: Saturday, September 13, 2008 9:52 PM To: 'Jochem Maas' Subject: RE: [PHP] 2 Questions. iamjochem wrote: My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. have your simple wrapper do something like: $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1; with regard to generating the query. if your wrapper doesn't generate the SQL then you'll have to parse the given SQL and rewrite it ... good luck with that. I'm not sure if my wrapper is a good place for the sql but I bet it's worth investigating further. I like the web site iamjokem. Im not sure if that's a jokem too but I couldn't figure it out... -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Saturday, September 13, 2008 8:35 PM To: Tom Shaw Cc: 'PHP General' Subject: Re: [PHP] 2 Questions. Tom Shaw schreef: I should have mentioned that I use a *normalized* database wharehousing pattern where each row represents a distinct item being purchased. There could be fifty rows corresponding to a single order transaction like what you would see in something like an itunes music purchase. So using the auto increment id would not work to differentiate between orders. Another user mentioned microtime. whoa, race car hey? let's have a race. normalized smormalized. every order related system I've looked at, built or worked with made a clear distinction between an **order** and an **orderline**, all you seem to have is an order line ... who do they belong to? are you replicating the customer details and shipping address in each row? (if so I hardly call that normalized) use generators or sequences or 'auto increment ids' or whatever your DB calls it, dump the timestamp/microtime nonsense, and rework you DB schema to incorporate order **and** orderline entities ... and use a required foreign key in each orderline to reference the relevant order. with regard to iTunes store, steve jobs can go shove it ... but I'll wadger my soul that the guys that built it know the difference between an order and an order line and that they use both concepts. -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Saturday, September 13, 2008 6:06 PM To: Tom Shaw Cc: 'PHP General' Subject: Re: [PHP] 2 Questions. Tom Shaw schreef: Can anybody give me any good reasons not to use a time stamp as an order number in my shopping cart. It seems to me that the number is guaranteed to be random and it saves having to make an extra time column to keep track of the order. The only small concern I have is the chance that somebody orders at the exact same time as somebody else but the chance of that has got to be incredibly small but possible. 1. order number are often *required* (for accounting purposes) to be consecutive 2. the chance is small, yet it is there ... agravated by the fact that most orders are placed during a concentrated period of the day. I have no idea what you mean by 'extra time column' and/or using it to keep track of an order... but most DBMSs have the ability to auto store a timestamp into a field when the given record is created. oh ... timestamps are hardly random. My second question is I've designed a very simple Postgres database wrapper. The methods are exactly what you would assume to see in any db wrapper a pg_query, pg_fetch_array. My question is in the db wrapper, is there an easy way to always include the table name as an index in all my pg_fetch_array returned results? The reason I ask is when designing my tables I'm delegated to prefixing my column names i.e. users_name instead of just name or forum_posts instead of just posts to make sure there's no collision. have your simple wrapper do something like: $sql = SELECT foo AS {$tablename}_foo FROM {$tablename} WHERE 1; with regard to generating the query. if your wrapper doesn't generate the SQL then you'll have to parse the given SQL and rewrite it ... good luck with that. Cheers Thomas Shaw [EMAIL PROTECTED] -- 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] 2 Questions: Static variables and the nature of the online manual
Hello, I got this e-mail address from the Add note¹ page within the php.net website. I was going to post something that was a question and I realised I was in the wrong place :) I have 2 basic questions and I¹m sorry if they may seem too basic. I¹m a bit new to php. The first question has to do with the static variables. I understand how this works from the examples, but there is something that I cannot seem to find clearly stated anywhere on that page. The example: ?php function Test() { static $a = 0; echo $a; $a++; } ? Of course works (I¹ve tested it on my server), but it is still obscure to me, according to general programming principles, since I¹m still assigning zero (0) to $a on each call to the Test function. How does this exactly work when the static word is found? Is there and index that keeps track of each call to the function ignoring any assignment in subsequent calls to the function? Why doens¹t this work when you assign an expression result to the variable? The second question has to do with the online manual. I¹ve found several things on that manual specified in comments and not in the actual manual part of it. What is the nature of the manual? Contributions from voluteers? Is there any official manual I can buy that documents everything about the language from the source? Or any official company that maintains the language and that possibly offers support as well? Many thanks in advance for your time.
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
Svevo Romano schreef: Hello, I got this e-mail address from the ŒAdd note¹ page within the php.net website. I was going to post something that was a question and I realised I was in the wrong place :) I have 2 basic questions and I¹m sorry if they may seem too basic. I¹m a bit new to php. The first question has to do with the static variables. I understand how this works from the examples, but there is something that I cannot seem to find clearly stated anywhere on that page. The example: ?php function Test() { static $a = 0; the preceding line is only run on the first call to the function. echo $a; $a++; } ? Of course works (I¹ve tested it on my server), but it is still obscure to me, according to general programming principles, since I¹m still assigning zero (0) to $a on each call to the Test function. How does this exactly work when the static word is found? Is there and index that keeps track of each call to the function ignoring any assignment in subsequent calls to the function? Why doens¹t this work when you assign an expression result to the variable? do something like function Test() { static $a; if (!isset($a)) $a = 0; if ($a % 2) $a = $a * 2; echo $a++; } The second question has to do with the online manual. I¹ve found several things on that manual specified in comments and not in the actual manual part of it. What is the nature of the manual? Contributions from voluteers? Is there any official manual I can buy that documents everything about the language from the source? Or any official company that maintains the language and that possibly offers support as well? php.net/ is the official manual. recommended to read it in english so your looking at the latest version (not always the case in other languages). user notes/comments are exactly that - notes, tips, gotcha's, examples related to whatever is documented on a given manual page. occasionally some of the best user notes are merged into the official documentation. Many thanks in advance for your time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
Hi there, Many thanks for your answer. I've also gone through your example and it took me 10 minutes to understand how the operator precedence was working there. Was expecting 1 on the first call :) But this is not the point. You've nailed my question very preciseley in your first answer: 'the preceding line is only run on the first call to the function'. My only question is (at it is related to the nature of the online manual): how do you know it and I don't? This thing is the only logical explanation to the fact the $a doesn't get initialized again to 0 in any subsequent call to the function, but it's not written anywhere in the manual page. And it seems the most important statement in my opinion, that justifies what I see as an exception to a normal flow. Hope all this makes sense. Thanks, S In 4/3/08 13:14, Jochem Maas, [EMAIL PROTECTED] ha scritto Svevo Romano schreef: Hello, I got this e-mail address from the ŒAdd note¹ page within the php.net website. I was going to post something that was a question and I realised I was in the wrong place :) I have 2 basic questions and I¹m sorry if they may seem too basic. I¹m a bit new to php. The first question has to do with the static variables. I understand how this works from the examples, but there is something that I cannot seem to find clearly stated anywhere on that page. The example: ?php function Test() { static $a = 0; the preceding line is only run on the first call to the function. echo $a; $a++; } ? Of course works (I¹ve tested it on my server), but it is still obscure to me, according to general programming principles, since I¹m still assigning zero (0) to $a on each call to the Test function. How does this exactly work when the static word is found? Is there and index that keeps track of each call to the function ignoring any assignment in subsequent calls to the function? Why doens¹t this work when you assign an expression result to the variable? do something like function Test() { static $a; if (!isset($a)) $a = 0; if ($a % 2) $a = $a * 2; echo $a++; } The second question has to do with the online manual. I¹ve found several things on that manual specified in comments and not in the actual manual part of it. What is the nature of the manual? Contributions from voluteers? Is there any official manual I can buy that documents everything about the language from the source? Or any official company that maintains the language and that possibly offers support as well? php.net/ is the official manual. recommended to read it in english so your looking at the latest version (not always the case in other languages). user notes/comments are exactly that - notes, tips, gotcha's, examples related to whatever is documented on a given manual page. occasionally some of the best user notes are merged into the official documentation. Many thanks in advance for your time.
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
On Tue, Mar 4, 2008 at 7:16 AM, Svevo Romano [EMAIL PROTECTED] wrote: The second question has to do with the online manual. I¹ve found several things on that manual specified in comments and not in the actual manual part of it. What is the nature of the manual? Contributions from voluteers? Is there any official manual I can buy that documents everything about the language from the source? Or any official company that maintains the language and that possibly offers support as well? We (the PHP community) maintain the manual through registered CVS accounts. As Jochem said, php.net is the official manual - there is no official manual to buy, and no way for a company to document everything about the language. This is because, believe it or not, the language changes multiple times per day, with added functionality all the time. The best a company could do is document everything on a specific version but by the time that task is complete, the version documented would be obsolete. The comments are just posts by whomever feels like typing and submitting. It's generally a tips and tricks sort of thing, and is an excellent source, but an unofficial source. -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
I would hazard a guess that the 'static' keyword and functionality comes from ANSI C. I just pulled The C Programming Language by Kernighan and Ritchie from the book case and it is described there in it. Essential book, by the way, IMHO. -- -David. When the power of love overcomes the love of power, the world will know peace. -Jimi Hendrix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
Just one word, Thanks :) S In 4/3/08 16:22, David Giragosian, [EMAIL PROTECTED] ha scritto I would hazard a guess that the 'static' keyword and functionality comes from ANSI C. I just pulled The C Programming Language by Kernighan and Ritchie from the book case and it is described there in it. Essential book, by the way, IMHO. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
On Tue, Mar 4, 2008 at 11:12 AM, Svevo Romano [EMAIL PROTECTED] wrote: Still, I jusy wonder how Jochem knew that the line is only executed the first time a function is called while this info is not available on the online manual. It's maybe all about how close you are to the community and how many degrees are between yourself and the source? Check the section Using static variables in the Variable Scope entry here: http://us.php.net/manual/en/language.variables.scope.php I mean, I understand the manual is maintained by the community, but I suppose the language is developed by a small core of programmers that participate to the general discussion to some extent... Actually, a good portion of us who maintain the manual maintain the code, as well. Everything about the language, from the core engine to web scripting support, is handled entirely by the community. That's the beauty of open source. I'm just trying to figure out the shape of the landscape. I tend to start from the bigger picture before getting into details. :) And welcome to the community, Svevo! -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
Hi Daniel, Many thanks to you as well. I really appreciate your effort in answering my queries guys. It means I'll do my best with books and the online manual. And today I've probably found the best resource. The community! Still, I jusy wonder how Jochem knew that the line is only executed the first time a function is called while this info is not available on the online manual. It's maybe all about how close you are to the community and how many degrees are between yourself and the source? I mean, I understand the manual is maintained by the community, but I suppose the language is developed by a small core of programmers that participate to the general discussion to some extent... I¹m just trying to figure out the shape of the landscape. I tend to start from the bigger picture before getting into details. :) Cheers In 4/3/08 16:00, Daniel Brown, [EMAIL PROTECTED] ha scritto On Tue, Mar 4, 2008 at 7:16 AM, Svevo Romano [EMAIL PROTECTED] wrote: The second question has to do with the online manual. I¹ve found several things on that manual specified in comments and not in the actual manual part of it. What is the nature of the manual? Contributions from voluteers? Is there any official manual I can buy that documents everything about the language from the source? Or any official company that maintains the language and that possibly offers support as well? We (the PHP community) maintain the manual through registered CVS accounts. As Jochem said, php.net is the official manual - there is no official manual to buy, and no way for a company to document everything about the language. This is because, believe it or not, the language changes multiple times per day, with added functionality all the time. The best a company could do is document everything on a specific version but by the time that task is complete, the version documented would be obsolete. The comments are just posts by whomever feels like typing and submitting. It's generally a tips and tricks sort of thing, and is an excellent source, but an unofficial source.
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
Svevo Romano schreef: Hi there, Many thanks for your answer. I've also gone through your example and it took me 10 minutes to understand how the operator precedence was working there. Was expecting 1 on the first call :) But this is not the point. You've nailed my question very preciseley in your first answer: 'the preceding line is only run on the first call to the function'. My only question is (at it is related to the nature of the online manual): how do you know it and I don't? This thing is the only logical explanation to the fact the $a doesn't get initialized again to 0 in any subsequent call to the function, but it's not written anywhere in the manual page. And it seems the most important statement in my opinion, that justifies what I see as an exception to a normal flow. can't remember where I picked up the meaning/working of 'static' - I think I just worked it out by trial and error, or I read about it sometime on this list :-) the manual does talk about statics: http://php.net/static notice you can type 'http://php.net/FOO' to go straight to certain docs, replace FOO with a function name, extension name, core concept, or whatever ... if nothing is found you get a 'did you mean ?' type page otherwise you go directly to the relevant manual page. Hope all this makes sense. Thanks, S In 4/3/08 13:14, Jochem Maas, [EMAIL PROTECTED] ha scritto Svevo Romano schreef: Hello, I got this e-mail address from the ŒAdd note¹ page within the php.net website. I was going to post something that was a question and I realised I was in the wrong place :) I have 2 basic questions and I¹m sorry if they may seem too basic. I¹m a bit new to php. The first question has to do with the static variables. I understand how this works from the examples, but there is something that I cannot seem to find clearly stated anywhere on that page. The example: ?php function Test() { static $a = 0; the preceding line is only run on the first call to the function. echo $a; $a++; } ? Of course works (I¹ve tested it on my server), but it is still obscure to me, according to general programming principles, since I¹m still assigning zero (0) to $a on each call to the Test function. How does this exactly work when the static word is found? Is there and index that keeps track of each call to the function ignoring any assignment in subsequent calls to the function? Why doens¹t this work when you assign an expression result to the variable? do something like function Test() { static $a; if (!isset($a)) $a = 0; if ($a % 2) $a = $a * 2; echo $a++; } The second question has to do with the online manual. I¹ve found several things on that manual specified in comments and not in the actual manual part of it. What is the nature of the manual? Contributions from voluteers? Is there any official manual I can buy that documents everything about the language from the source? Or any official company that maintains the language and that possibly offers support as well? php.net/ is the official manual. recommended to read it in english so your looking at the latest version (not always the case in other languages). user notes/comments are exactly that - notes, tips, gotcha's, examples related to whatever is documented on a given manual page. occasionally some of the best user notes are merged into the official documentation. Many thanks in advance for your time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
Ok Jochem, It makes a lot of sense. Now I know what I can expect from the manual and what kind of approach I should have. I hope to contribute as well in the future. Many thanks, S In 4/3/08 16:11, Jochem Maas, [EMAIL PROTECTED] ha scritto Svevo Romano schreef: Hi there, Many thanks for your answer. I've also gone through your example and it took me 10 minutes to understand how the operator precedence was working there. Was expecting 1 on the first call :) But this is not the point. You've nailed my question very preciseley in your first answer: 'the preceding line is only run on the first call to the function'. My only question is (at it is related to the nature of the online manual): how do you know it and I don't? This thing is the only logical explanation to the fact the $a doesn't get initialized again to 0 in any subsequent call to the function, but it's not written anywhere in the manual page. And it seems the most important statement in my opinion, that justifies what I see as an exception to a normal flow. can't remember where I picked up the meaning/working of 'static' - I think I just worked it out by trial and error, or I read about it sometime on this list :-) the manual does talk about statics: http://php.net/static notice you can type 'http://php.net/FOO' to go straight to certain docs, replace FOO with a function name, extension name, core concept, or whatever ... if nothing is found you get a 'did you mean ?' type page otherwise you go directly to the relevant manual page. Hope all this makes sense. Thanks, S In 4/3/08 13:14, Jochem Maas, [EMAIL PROTECTED] ha scritto Svevo Romano schreef: Hello, I got this e-mail address from the ŒAdd note¹ page within the php.net website. I was going to post something that was a question and I realised I was in the wrong place :) I have 2 basic questions and I¹m sorry if they may seem too basic. I¹m a bit new to php. The first question has to do with the static variables. I understand how this works from the examples, but there is something that I cannot seem to find clearly stated anywhere on that page. The example: ?php function Test() { static $a = 0; the preceding line is only run on the first call to the function. echo $a; $a++; } ? Of course works (I¹ve tested it on my server), but it is still obscure to me, according to general programming principles, since I¹m still assigning zero (0) to $a on each call to the Test function. How does this exactly work when the static word is found? Is there and index that keeps track of each call to the function ignoring any assignment in subsequent calls to the function? Why doens¹t this work when you assign an expression result to the variable? do something like function Test() { static $a; if (!isset($a)) $a = 0; if ($a % 2) $a = $a * 2; echo $a++; } The second question has to do with the online manual. I¹ve found several things on that manual specified in comments and not in the actual manual part of it. What is the nature of the manual? Contributions from voluteers? Is there any official manual I can buy that documents everything about the language from the source? Or any official company that maintains the language and that possibly offers support as well? php.net/ is the official manual. recommended to read it in english so your looking at the latest version (not always the case in other languages). user notes/comments are exactly that - notes, tips, gotcha's, examples related to whatever is documented on a given manual page. occasionally some of the best user notes are merged into the official documentation. Many thanks in advance for your time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] 2 Questions: Static variables and the nature of the online manual
-Mensagem original- De: Svevo Romano [mailto:[EMAIL PROTECTED] Hi there, Many thanks for your answer. I've also gone through your example and it took me 10 minutes to understand how the operator precedence was working there. Was expecting 1 on the first call :) But this is not the point. You've nailed my question very preciseley in your first answer: 'the preceding line is only run on the first call to the function'. My only question is (at it is related to the nature of the online manual): how do you know it and I don't? This thing is the only logical explanation to the fact the $a doesn't get initialized again to 0 in any subsequent call to the function, but it's not written anywhere in the manual page. And it seems the most important statement in my opinion, that justifies what I see as an exception to a normal flow. Hope all this makes sense. Thanks, S me You can use http://bugs.php.net/report.php to report a documentation bug and they'll change the docs :) Thiago /me -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
At 4:12 PM + 3/4/08, Svevo Romano wrote: Hi Daniel, Many thanks to you as well. I really appreciate your effort in answering my queries guys. It means I'll do my best with books and the online manual. And today I've probably found the best resource. The community! Still, I jusy wonder how Jochem knew that the line is only executed the first time a function is called while this info is not available on the online manual. It's maybe all about how close you are to the community and how many degrees are between yourself and the source? I mean, I understand the manual is maintained by the community, but I suppose the language is developed by a small core of programmers that participate to the general discussion to some extent... I'm just trying to figure out the shape of the landscape. I tend to start from the bigger picture before getting into details. :) Cheers Maybe he did the way I do -- and that is by writing code to investigate these things. Nothing teaches you better than writing code. It takes all you think you know and either confirms it or makes you relearn it. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
On Tue, March 4, 2008 6:16 am, Svevo Romano wrote: Hello, I got this e-mail address from the Add note¹ page within the php.net website. I was going to post something that was a question and I realised I was in the wrong place :) I have 2 basic questions and I¹m sorry if they may seem too basic. I¹m a bit new to php. The first question has to do with the static variables. I understand how this works from the examples, but there is something that I cannot seem to find clearly stated anywhere on that page. The example: ?php function Test() { static $a = 0; echo $a; $a++; } ? Of course works (I¹ve tested it on my server), but it is still obscure to me, according to general programming principles, since I¹m still assigning zero (0) to $a on each call to the Test function. How does this exactly work when the static word is found? Is there and index that keeps track of each call to the function ignoring any assignment in subsequent calls to the function? Why doens¹t this work when you assign an expression result to the variable? It's not an assignment, it's an initialization, and, yes, the compiler does keep track and doesn't do that after the first time. *THIS* would be what you describe: function Test(){ static $a; $a = 0; echo $a; $a++; } The second question has to do with the online manual. I¹ve found several things on that manual specified in comments and not in the actual manual part of it. What is the nature of the manual? Contributions from voluteers? The manual is contributions from volunteers who have been blessed by the other volunteers (viz) to edit the manual. The Notes is from anybody on the planet with a web browser that can beat the CAPTCHA. Is there any official manual I can buy that documents everything about the language from the source? Or any official company that maintains the language and that possibly offers support as well? There is nothing you can buy that's more official (nor more complete) than the on-line manual. You can buy support from Zend, which is a separate company run by two guys who happen to be core developers; You can probably buy support elsewhere as well. PS If you can find a language with a better manual, I'd like to see it... :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
On Tue, March 4, 2008 10:12 am, Svevo Romano wrote: Still, I jusy wonder how Jochem knew that the line is only executed the first time a function is called while this info is not available on the online manual. It's maybe all about how close you are to the community and how many degrees are between yourself and the source? That's how it works in C. And Perl. And Modula-2. And Ada. And Pascal. And even Lisp. . . . After you've learned a couple computer languages, the rest are mostly about differences and gotchas rather than learning something new. Ok, except the Lisp/Scheme/Prolog stuff, where you have to think inside-out. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
On Tue, Mar 4, 2008 at 5:05 PM, Richard Lynch [EMAIL PROTECTED] wrote: After you've learned a couple computer languages, the rest are mostly about differences and gotchas rather than learning something new. Ok, except the Lisp/Scheme/Prolog stuff, where you have to think inside-out. :-) You hit that nail right on the head! For those who don't know, Lisp, though spelled with an L, is actually pronounced *Gasp*. ;-P -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] 2 Questions: Static variables and the nature of the online manual
Cheers Thiago, In fact this was going to be my next question. I think I will report a documentation bug, just because, after all the discussion we had today, I realize that this is quite a common behaviour in other languages, but for somebody new to languages, being them programming or scripting ones, the fact that the $a=0 line doesn't get executed on subsequent calls isn't so obvious. In other words, from the standpoint of someone that is relatively new to the details (at least), the flow is: 'ok, I do appreciate that the engine keeps memory of the value of that variable declared as static after the function ends, but assigning a value to it at the very beginning of the function seems like the next time the function is going to be called, it will assaign that value again and again...and again'. And I guess the manual wants to be as clear as possible, considering that the examples are often 'foo 'and '$a' related :P In other words I think that it is indeed targeted to beginners as wel, isn't it? Thanks for all the valuable info btw. :) In 4/3/08 16:59, Thiago Pojda, [EMAIL PROTECTED] ha scritto -Mensagem original- De: Svevo Romano [mailto:[EMAIL PROTECTED] Hi there, Many thanks for your answer. I've also gone through your example and it took me 10 minutes to understand how the operator precedence was working there. Was expecting 1 on the first call :) But this is not the point. You've nailed my question very preciseley in your first answer: 'the preceding line is only run on the first call to the function'. My only question is (at it is related to the nature of the online manual): how do you know it and I don't? This thing is the only logical explanation to the fact the $a doesn't get initialized again to 0 in any subsequent call to the function, but it's not written anywhere in the manual page. And it seems the most important statement in my opinion, that justifies what I see as an exception to a normal flow. Hope all this makes sense. Thanks, S me You can use http://bugs.php.net/report.php to report a documentation bug and they'll change the docs :) Thiago /me -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 Questions: Static variables and the nature of the online manual
Yes Richard, In fact I know ActionScript and JavaScript and I'm trying to nail the peculiarities of php. I totally agree. I am not used to use ' - ' to call a method if you know what I mean, but the rest is quite familiar, phew! :) Aside from that, this was just one of the things I could not really understand properly: I could understand the effects, not the reasons behind the effects, if it makes any sense. I think the manula is lacking a couple of lines. One funny thing: in the Welling Thomson - PHP and MySQL Web Development book, at some point this thing is mentioned. They promised they would explain the concept in full detail in chapter 5 and, in chap 5, they kinda forgot to do it.. hehe All the best. In 4/3/08 22:05, Richard Lynch, [EMAIL PROTECTED] ha scritto On Tue, March 4, 2008 10:12 am, Svevo Romano wrote: Still, I jusy wonder how Jochem knew that the line is only executed the first time a function is called while this info is not available on the online manual. It's maybe all about how close you are to the community and how many degrees are between yourself and the source? That's how it works in C. And Perl. And Modula-2. And Ada. And Pascal. And even Lisp. . . . After you've learned a couple computer languages, the rest are mostly about differences and gotchas rather than learning something new. Ok, except the Lisp/Scheme/Prolog stuff, where you have to think inside-out. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
1. I'm not the original poster (I wasn't asking a question) 2. don't post me or anyone else 'offlist' unless asked 3. WTF are you talking about? 4. if you say 'First' then that assumes there is a 'Second' coming. (that's sounds kinda funny given it was just Easter) suresh kumar wrote: First, If u want to search work richard hassed .first split the word as richard and hassed by using split() and store it in array.and use select like command to search individual word stored in array.this type of searching is followed in google. A.suresh --- Jochem Maas [EMAIL PROTECTED] wrote: don't know if someone mentioned it already but i was digging around in the docs for something completely different and bumped into this: preg_grep() [http://php.net/preg_grep] and I thought of your question, might be just what your looking for. I can't remember having come across this func before - learn something new every day :-) Ryan A wrote: Hi, Like the subject says; I have two questions: 1) Is it possible to detect JavaScript via php... and yes I do know that JS is client side while PHP is server...but how else to do it? The reason I ask is before serving an AJAX page I would like to make sure JS is enabled, if not, serve the other normal page... I am sure I am not the first person to come accross this little problem, how did you solve it? I have seen some suggestions on google like having a hidden form field and using js to put a value in it, if it exists when the form is sent then JS is on..if not, its not... but that method is not the best in an AJAX situation...right? 2) How can I search in an array for a particular word? eg: in an array movie I have this kind of data: movie_name= some movie cast= Jim Carrey, Richard Pryor, Eddie Murphy I want to search on either Richard or Richard Pryor (must be case insensitive too) something like a SELECT with a LIKE %% statement I have been fooling around with in_array() but not getting anywhere fast. am I on the right track? Links, code examples or advise would be as alwaysappreciated. Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
don't know if someone mentioned it already but i was digging around in the docs for something completely different and bumped into this: preg_grep() [http://php.net/preg_grep] and I thought of your question, might be just what your looking for. I can't remember having come across this func before - learn something new every day :-) Ryan A wrote: Hi, Like the subject says; I have two questions: 1) Is it possible to detect JavaScript via php... and yes I do know that JS is client side while PHP is server...but how else to do it? The reason I ask is before serving an AJAX page I would like to make sure JS is enabled, if not, serve the other normal page... I am sure I am not the first person to come accross this little problem, how did you solve it? I have seen some suggestions on google like having a hidden form field and using js to put a value in it, if it exists when the form is sent then JS is on..if not, its not... but that method is not the best in an AJAX situation...right? 2) How can I search in an array for a particular word? eg: in an array movie I have this kind of data: movie_name= some movie cast= Jim Carrey, Richard Pryor, Eddie Murphy I want to search on either Richard or Richard Pryor (must be case insensitive too) something like a SELECT with a LIKE %% statement I have been fooling around with in_array() but not getting anywhere fast. am I on the right track? Links, code examples or advise would be as alwaysappreciated. Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
Ryan A wrote: 1) Is it possible to detect JavaScript via php... and yes I do know that JS is client side while PHP is server...but how else to do it? The reason I ask is before serving an AJAX page I would like to make sure JS is enabled, if not, serve the other normal page... I am sure I am not the first person to come accross this little problem, how did you solve it? The way I do this is to serve the 'notmal page' first, but with the following snippet of JS in it... script language=javascript !-- location.href = '/url/for/ajax/page.php'; -- /script That way if they have JS enabled they'll get sent to the AJAX page. If not they stay on the 'normal page'. 2) How can I search in an array for a particular word? eg: in an array movie I have this kind of data: movie_name= some movie cast= Jim Carrey, Richard Pryor, Eddie Murphy I want to search on either Richard or Richard Pryor (must be case insensitive too) something like a SELECT with a LIKE %% statement I have been fooling around with in_array() but not getting anywhere fast. am I on the right track? Links, code examples or advise would be as alwaysappreciated. You should be able to craft some combination of array_walk and a custom function that checks each element with stristr to do what you need. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
Hey Stut, Thanks for replying. --- The way I do this is to serve the 'notmal page' first, but with the following snippet of JS in it... script language=javascript !-- location.href = '/url/for/ajax/page.php'; -- /script--Makes sense and pretty easy, this was suggested a while back, since you have supported itI think I'll start using this method.--- You should be able to craft some combination of array_walk and a custom function that checks each element with stristr to do what you need. -Actually, I solved this thanks to Richard from the list who suggested strpos, a function I had never usedbefore ( Tedd from the list gave me the same suggestion as you to use stristr, I didnt want to use stristr as its a bit expensive esp with a really large array) the problem I ran into was that strpos is a php5 functionbut reading the user contributed articles on strpos at thephp site I got the code that does exactly that in 2-3 linesCheers! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 2 questions: Search in array and detect JS
[snip] script language=javascript !-- location.href = '/url/for/ajax/page.php'; -- /script [/snip] My only concern with this method is that it constitutes an exit trap... For example, if a user connects to your index page from, say, Google they will be redirected over to your Ajax page... All good, except if they click Back to return to the SE page they will immediately bounce back to your Ajax page Something to consider might be: noscript Sorry! This page requires Javascript to function properly! Please enable it or get a decent browser /noscript !-- Normal page functions -- I haven't tested it so there is a chance it's fiction :) Of course, if web standards aren't a concern it makes no difference HTH Dan --- http://chrome.me.uk -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: 15 April 2006 14:26 To: php Cc: Stut Subject: Re: [PHP] 2 questions: Search in array and detect JS Hey Stut, Thanks for replying. --- The way I do this is to serve the 'notmal page' first, but with the following snippet of JS in it... script language=javascript !-- location.href = '/url/for/ajax/page.php'; -- /script--Makes sense and pretty easy, this was suggested a while back, since you have supported itI think I'll start using this method.--- You should be able to craft some combination of array_walk and a custom function that checks each element with stristr to do what you need. -Actually, I solved this thanks to Richard from the list who suggested strpos, a function I had never usedbefore ( Tedd from the list gave me the same suggestion as you to use stristr, I didnt want to use stristr as its a bit expensive esp with a really large array) the problem I ran into was that strpos is a php5 functionbut reading the user contributed articles on strpos at thephp site I got the code that does exactly that in 2-3 linesCheers! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ NOD32 1.1490 (20060415) Information __ This message was checked by NOD32 antivirus system. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 2 questions: Search in array and detect JS
Something to consider might be: noscript Sorry! This page requires Javascript to function properly! Please enable it or get a decent browser /noscript !-- Normal page functions -- I haven't tested it so there is a chance it's fiction :) Of course, if web standards aren't a concern it makes no difference Dan It works and if you want it to validate, just enclose the paragraph in p/p, like so: noscript p Sorry! This page requires Javascript to function properly! Please enable it or get a decent browser. /p /noscript To bad that php within those tags is read regardless or we would have an easy way to detect js. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 2 questions: Search in array and detect JS
How about ?php $js = true; ? noscript ?php $js = false; ? /noscript ?php if ($js){ // whizzy Ajax code (or file include) } else { // generic warning (or include non-JS base file) } ? I know that would work but does it give the desired effect? Dan --- http://chrome.me.uk -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: 15 April 2006 15:10 To: Chrome; 'Ryan A'; 'php' Cc: 'Stut' Subject: RE: [PHP] 2 questions: Search in array and detect JS Something to consider might be: noscript Sorry! This page requires Javascript to function properly! Please enable it or get a decent browser /noscript !-- Normal page functions -- I haven't tested it so there is a chance it's fiction :) Of course, if web standards aren't a concern it makes no difference Dan It works and if you want it to validate, just enclose the paragraph in p/p, like so: noscript p Sorry! This page requires Javascript to function properly! Please enable it or get a decent browser. /p /noscript To bad that php within those tags is read regardless or we would have an easy way to detect js. tedd -- http://sperling.com __ NOD32 1.1490 (20060415) Information __ This message was checked by NOD32 antivirus system. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
In your script, $js will be false false! Chrome wrote: How about ?php $js = true; ? noscript ?php $js = false; ? /noscript ?php if ($js) { // whizzy Ajax code (or file include) } else { // generic warning (or include non-JS base file) } ? I know that would work but does it give the desired effect? Dan --- http://chrome.me.uk -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: 15 April 2006 15:10 To: Chrome; 'Ryan A'; 'php' Cc: 'Stut' Subject: RE: [PHP] 2 questions: Search in array and detect JS Something to consider might be: noscript Sorry! This page requires Javascript to function properly! Please enable it or get a decent browser /noscript !-- Normal page functions -- I haven't tested it so there is a chance it's fiction :) Of course, if web standards aren't a concern it makes no difference Dan It works and if you want it to validate, just enclose the paragraph in p/p, like so: noscript p Sorry! This page requires Javascript to function properly! Please enable it or get a decent browser. /p /noscript To bad that php within those tags is read regardless or we would have an easy way to detect js. tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 2 questions: Search in array and detect JS
Yep just realised my half-witted mistake (and what tedd was getting at) Sorry about that Dan --- http://chrome.me.uk -Original Message- From: cajbecu [mailto:[EMAIL PROTECTED] Sent: 15 April 2006 15:40 To: Chrome Cc: 'tedd'; 'Ryan A'; 'php'; 'Stut' Subject: Re: [PHP] 2 questions: Search in array and detect JS In your script, $js will be false false! Chrome wrote: How about ?php $js = true; ? noscript ?php $js = false; ? /noscript ?php if ($js) { // whizzy Ajax code (or file include) } else { // generic warning (or include non-JS base file) } ? I know that would work but does it give the desired effect? Dan --- http://chrome.me.uk -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: 15 April 2006 15:10 To: Chrome; 'Ryan A'; 'php' Cc: 'Stut' Subject: RE: [PHP] 2 questions: Search in array and detect JS Something to consider might be: noscript Sorry! This page requires Javascript to function properly! Please enable it or get a decent browser /noscript !-- Normal page functions -- I haven't tested it so there is a chance it's fiction :) Of course, if web standards aren't a concern it makes no difference Dan It works and if you want it to validate, just enclose the paragraph in p/p, like so: noscript p Sorry! This page requires Javascript to function properly! Please enable it or get a decent browser. /p /noscript To bad that php within those tags is read regardless or we would have an easy way to detect js. tedd __ NOD32 1.1490 (20060415) Information __ This message was checked by NOD32 antivirus system. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
js is client-side, php server side... it can't work fabien Chrome wrote: How about ?php $js = true; ? noscript ?php $js = false; ? /noscript ?php if ($js) { // whizzy Ajax code (or file include) } else { // generic warning (or include non-JS base file) } ? I know that would work but does it give the desired effect? Dan --- http://chrome.me.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
for js detection, you can use that in a previous page : script type=text/javascript document.write('a href=ajax-page.htmlpage/a'); /script noscripta href=simple-page.htmlpage/a/noscript it is simple, and work fine. no need to have cookies enable -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
Hey, Thanks for replying. for js detection, you can use that in a previous page : script type=text/javascript document.write('a href=ajax-page.htmlpage/a'); /script noscripta href=simple-page.htmlpage/a/noscript it is simple, and work fine. no need to have cookies enable-Nice, most of the methods discussed focuses on the fact that you are sending this person from a previous page,eg:index.php to- contact_us.phpbut what if you are using AJAX on the first page (eg: index.php)then isnt the location.href = '/url/for/ajax/index2/page.php'; the best solution?Cheers!Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
On 4/14/06, Ryan A [EMAIL PROTECTED] wrote: The reason I ask is before serving an AJAX page I would like to make sure JS is enabled, if not, serve the other normal page... I am sure I am not the first person to come accross this little problem, how did you solve it? Dan eluded to a big problem here, regarding the potential exit trap of redirecting a user to a different page. However there's even more at stake--this solution would require you to manage *two* versions of your page. Come on, we can do better than that... What you should do is create your normal page as is, and then write your javascript to attach itself to whatever things you want to AJAXify on that page. Research unobtrusive javascript, it should get you in the right direction. The idea is, you build your page to function normally without any javascript. Then you attempt to hook up the javascript via your page's onload event (there are other methods too I believe, Google it). If javascript is enabled, then the javascript will be hooked in; if not, then no AJAX will be loaded, but your page will still function as needed. HTH, John W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 2 questions: Search in array and detect JS
Hi, Like the subject says; I have two questions: 1) Is it possible to detect JavaScript via php... and yes I do know that JS is client side while PHP is server...but how else to do it? The reason I ask is before serving an AJAX page I would like to make sure JS is enabled, if not, serve the other normal page... I am sure I am not the first person to come accross this little problem, how did you solve it? I have seen some suggestions on google like having a hidden form field and using js to put a value in it, if it exists when the form is sent then JS is on..if not, its not... but that method is not the best in an AJAX situation...right? 2) How can I search in an array for a particular word? eg: in an array movie I have this kind of data: movie_name= some movie cast= Jim Carrey, Richard Pryor, Eddie Murphy I want to search on either Richard or Richard Pryor (must be case insensitive too) something like a SELECT with a LIKE %% statement I have been fooling around with in_array() but not getting anywhere fast. am I on the right track? Links, code examples or advise would be as alwaysappreciated. Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
Ryan: First question. Technically no, you can't detect js from php. However, I read where one can detect if a user has cookies on by sending a cookie and then reading it back. And considering that you can send a cookie via js, you could do that. However, that would mean that the user had to have both js and cookies on. Second question. Unless I don't understand the problem, simply use a loop and stristr(). See; http://www.weberdev.com/stristr HTH's tedd --- At 7:24 PM +0200 4/14/06, Ryan A wrote: Hi, Like the subject says; I have two questions: 1) Is it possible to detect JavaScript via php... and yes I do know that JS is client side while PHP is server...but how else to do it? The reason I ask is before serving an AJAX page I would like to make sure JS is enabled, if not, serve the other normal page... I am sure I am not the first person to come accross this little problem, how did you solve it? I have seen some suggestions on google like having a hidden form field and using js to put a value in it, if it exists when the form is sent then JS is on..if not, its not... but that method is not the best in an AJAX situation...right? 2) How can I search in an array for a particular word? eg: in an array movie I have this kind of data: movie_name= some movie cast= Jim Carrey, Richard Pryor, Eddie Murphy I want to search on either Richard or Richard Pryor (must be case insensitive too) something like a SELECT with a LIKE %% statement I have been fooling around with in_array() but not getting anywhere fast. am I on the right track? Links, code examples or advise would be as alwaysappreciated. Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
On Fri, 2006-04-14 at 13:34, tedd wrote: Ryan: First question. Technically no, you can't detect js from php. However, I read where one can detect if a user has cookies on by sending a cookie and then reading it back. And considering that you can send a cookie via js, you could do that. However, that would mean that the user had to have both js and cookies on. It is probably a better to approach this backwards. So load the non JS page, and within it detect if javascript is enabled, in which case perform a javascript based redirect to the Ajax enabled page. Second question. Unless I don't understand the problem, simply use a loop and stristr(). stripos() is a better candidate since you are only looking for the string and it skips the extra processing of stristr(). Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions: Search in array and detect JS
Hey Tedd / Robert, Thanks for replying. -- Tedd: However, I read where one can detect if a user has cookies on by sending a cookie and then reading it back. And considering that you can send a cookie via js, you could do that. However, that would mean that the user had to have both js and cookies on.- Yep, two things to worry about instead of one. Tedd: Second question. Unless I don't understand the problem, simply use a loop and stristr().-stristr() is a bit expensive, was not too sure if I wanted to use that because I will be lookingin a array of hundreds of movies (maybe even thousands)-- Robert:It is probably a better to approach this backwards. So load the non JS page, and within it detect if javascript is enabled, in which case perform a javascript based redirect to the Ajax enabled page.-Hmmm, makes sense and I have not used this method beforewill def check it out.-- stripos() is a better candidate since you are only looking for the string and it skips the extra processing of stristr().--I am more familier with strstr and stristr but will give stripos a look-see too..Thanks,Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 2 questions - PHP site Automatic search and slow display
Hi, I have to questions which are pretty unrelated except that both of them are in PHP. (1) I am using a class to send email, 3 different kinds (text, html, text+html attachement) no problem there, but I am giving the client the option to mail all his members/clients at the same time...I have set the timeout to +30 everytime it loops so each email has enough time to go through even if its a couple of thousand, heres my problem: I want to display a message after each mail has gone through eg: after the first mail it says: Mail #1: Sent the after the second mail Mail #2: Sent etc etc something like a progress bar...but for now, it waits then loads the whole page at a go instead of one by one. I have looked at the manual and the closest I can come up with is to use sleep() but even then am not getting the display like that and its of course slowing down the sending of mail. Next I looked at buffering...which is not really for my needs either... Any ideas? (2) We are developing a developer site and its going to be php powered and very php related, we want to have that php function search facility that php.net has eg: you type http://php.net/mail and it shows you the mail functions page... I searched the php.net site but I couldnt find any reference to how they are doing that... I know it probably has mod_rewrite which takes the variable to a search script...right? any ideas? or is it somewhere on the php.net site that i have not looked? URL? Thanks, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions - PHP site Automatic search and slow display
Keep in mind that we have a show source button on every php.net page so you can see how everything is done. Here is the source for the code that handles the error redirection: http://www.php.net/source.php?url=/error.php -Rasmus On Sun, 29 Feb 2004, Ryan A wrote: Hi, I have to questions which are pretty unrelated except that both of them are in PHP. (1) I am using a class to send email, 3 different kinds (text, html, text+html attachement) no problem there, but I am giving the client the option to mail all his members/clients at the same time...I have set the timeout to +30 everytime it loops so each email has enough time to go through even if its a couple of thousand, heres my problem: I want to display a message after each mail has gone through eg: after the first mail it says: Mail #1: Sent the after the second mail Mail #2: Sent etc etc something like a progress bar...but for now, it waits then loads the whole page at a go instead of one by one. I have looked at the manual and the closest I can come up with is to use sleep() but even then am not getting the display like that and its of course slowing down the sending of mail. Next I looked at buffering...which is not really for my needs either... Any ideas? (2) We are developing a developer site and its going to be php powered and very php related, we want to have that php function search facility that php.net has eg: you type http://php.net/mail and it shows you the mail functions page... I searched the php.net site but I couldnt find any reference to how they are doing that... I know it probably has mod_rewrite which takes the variable to a search script...right? any ideas? or is it somewhere on the php.net site that i have not looked? URL? Thanks, -Ryan -- 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] 2 questions
- Original Message - From: Thomas Hochstetter [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, August 24, 2003 12:54 AM Subject: RE: [PHP] 2 questions The register globals is on with the live server, and off at home (my version is 4.3.2, the other is 4.1.2). does that matter? yes, it does matter .. Show me the snippet where u regestering/getting the session variables if possible. Thanks for the other tip, shall try that ... Thomas - Original Message - From: Thomas Hochstetter [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, August 23, 2003 5:33 PM Subject: [PHP] 2 questions Hi guys. I have two questions for you today: 1. Weired login problem I am developinig a site for a conference where i have a login page for members. This page is called index.php and includes different types of modules, according to the type of user logged on. The problem is now following: i have a login function hidden in a class, this function registers a bunch of variables. After the user has submited the details, index.php (which calls the session_start()) calls the login function. Then i check whether a session variable is present ($_SESSION['name']). If yes, we include the members area, otherwise we include the login table again. Now: on my test server (XP/Apache/php4.3.2) all is well. However, on the real server (Linux/Apache/php4.0.x) it just includes the login table anyway, even if the login was successful. I then have to click on the menu link again to include the member script. Why is that? Check your register_globals setting in both ur test server and real server and let me know. 2. Save a large amount of text to a file On the same page i have some type of cms going. The admin users can change txt files which relate to text on some of the general pages. I have now found that it is only transmits a certain amount of text via GET to the function that writs to the files. Is there a restriction on passing text via url? If yes (which will be the case), how could i do this otherwise? Use POST instead of GET method... POST method allows u to even extend the size of data being posted. Hope this helps... Thanks so long... Thomas P.S: this list still rocks -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post -- 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] 2 questions
Hi guys. I have two questions for you today: 1. Weired login problem I am developinig a site for a conference where i have a login page for members. This page is called index.php and includes different types of modules, according to the type of user logged on. The problem is now following: i have a login function hidden in a class, this function registers a bunch of variables. After the user has submited the details, index.php (which calls the session_start()) calls the login function. Then i check whether a session variable is present ($_SESSION['name']). If yes, we include the members area, otherwise we include the login table again. Now: on my test server (XP/Apache/php4.3.2) all is well. However, on the real server (Linux/Apache/php4.0.x) it just includes the login table anyway, even if the login was successful. I then have to click on the menu link again to include the member script. Why is that? 2. Save a large amount of text to a file On the same page i have some type of cms going. The admin users can change txt files which relate to text on some of the general pages. I have now found that it is only transmits a certain amount of text via GET to the function that writs to the files. Is there a restriction on passing text via url? If yes (which will be the case), how could i do this otherwise? Thanks so long... Thomas P.S: this list still rocks -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions
- Original Message - From: Thomas Hochstetter [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, August 23, 2003 5:33 PM Subject: [PHP] 2 questions Hi guys. I have two questions for you today: 1. Weired login problem I am developinig a site for a conference where i have a login page for members. This page is called index.php and includes different types of modules, according to the type of user logged on. The problem is now following: i have a login function hidden in a class, this function registers a bunch of variables. After the user has submited the details, index.php (which calls the session_start()) calls the login function. Then i check whether a session variable is present ($_SESSION['name']). If yes, we include the members area, otherwise we include the login table again. Now: on my test server (XP/Apache/php4.3.2) all is well. However, on the real server (Linux/Apache/php4.0.x) it just includes the login table anyway, even if the login was successful. I then have to click on the menu link again to include the member script. Why is that? Check your register_globals setting in both ur test server and real server and let me know. 2. Save a large amount of text to a file On the same page i have some type of cms going. The admin users can change txt files which relate to text on some of the general pages. I have now found that it is only transmits a certain amount of text via GET to the function that writs to the files. Is there a restriction on passing text via url? If yes (which will be the case), how could i do this otherwise? Use POST instead of GET method... POST method allows u to even extend the size of data being posted. Hope this helps... Thanks so long... Thomas P.S: this list still rocks -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post -- 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] 2 questions
The register globals is on with the live server, and off at home (my version is 4.3.2, the other is 4.1.2). does that matter? Thanks for the other tip, shall try that ... Thomas - Original Message - From: Thomas Hochstetter [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, August 23, 2003 5:33 PM Subject: [PHP] 2 questions Hi guys. I have two questions for you today: 1. Weired login problem I am developinig a site for a conference where i have a login page for members. This page is called index.php and includes different types of modules, according to the type of user logged on. The problem is now following: i have a login function hidden in a class, this function registers a bunch of variables. After the user has submited the details, index.php (which calls the session_start()) calls the login function. Then i check whether a session variable is present ($_SESSION['name']). If yes, we include the members area, otherwise we include the login table again. Now: on my test server (XP/Apache/php4.3.2) all is well. However, on the real server (Linux/Apache/php4.0.x) it just includes the login table anyway, even if the login was successful. I then have to click on the menu link again to include the member script. Why is that? Check your register_globals setting in both ur test server and real server and let me know. 2. Save a large amount of text to a file On the same page i have some type of cms going. The admin users can change txt files which relate to text on some of the general pages. I have now found that it is only transmits a certain amount of text via GET to the function that writs to the files. Is there a restriction on passing text via url? If yes (which will be the case), how could i do this otherwise? Use POST instead of GET method... POST method allows u to even extend the size of data being posted. Hope this helps... Thanks so long... Thomas P.S: this list still rocks -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 2 Questions Re: Anonymous Functions
I'm extracting a list of items from an XML document using PHP. The desired items are the attributes of different occurances of a specific element within the document; the code will not need a callback for character data or for closing tags. $list = new Array(); function start_tag($p_id, $element, $attribs) { global $list; if ($element = 'building') $list[] = $attribs['address']; return true; } //.. snip .. snip .. xml_set_element_handler($parser, 'start_tag', create_function ('','')); //.. snip .. snip .. Two questions: 1. create_function ('',''); works just fine, but I was wondering if there was a proper way to declare a void anonymous function? 2. If I were to place the parser related code within it's own function to increase readability of the script, how would start_tag be rewritten as an inline anonymous function? I've tried several ideas but I'm not sure how to handle $location and it's change in scope. Thanks in advance, -Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions !
Justin French wrote: I'm sure there's a way to check the owner of a file, but not (from what i know) a way to check who apache is running as. On linux ps aux | grep httpd will list as the first item the user the apache processes are running as. Ignore the one with root. On other unices the parameters to ps may vary. Regards Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions !
on 02/03/03 7:51 AM, Vincent M. ([EMAIL PROTECTED]) wrote: Hello, I didn't find in the doc how to: - Know the full path of the current directory. Like /var/www/to/the/path http://www.php.net/manual/en/reserved.variables.php#reserved.variables.serve r - Know under which user work apache, to know when I create a file whose file it is... the file is always owned by whatever user apache is... so really you'd have to try a chown or chmod on the file, to see if you can correct it... really, you don't need to KNOW who it's owned by, you need to SET IT to your preference of owner and/or permissions. I'm sure there's a way to check the owner of a file, but not (from what i know) a way to check who apache is running as. Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 2 questions !
Hello, I didn't find in the doc how to: - Know the full path of the current directory. Like /var/www/to/the/path - Know under which user work apache, to know when I create a file whose file it is... Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mail via php. 2 questions...
The first problem I cannot solve on my own: I get the mail content from a cookie. Quite a big cookie since it is a collection of 30 - 40 form values from another page. When recieving the mail, the content come in ONE long string, and in some places with a \BR\. Of course, i dont want this to be printed (but I want the function, a line break). So, how can I get a line break in my javascript cookie (yeah, I have already tried \n). The second problem: I want the mail to be sent automatically when the visitor have filled in all the forms in the document and goes to the next document. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 2 questions about PHP download
Is it possible to use the PHP-extentions for Apahce with the PHP for the CGI version, while the version number matches? What is the md5-hash beneath the download for? Regards, Sumarlidi E. Dadason SED - Graphic Design _ Tel: 896-0376, 461-5501 E-mail: [EMAIL PROTECTED] website: www.sed.is -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 2 questions about PHP download
Is it possible to use the PHP-extentions for Apahce with the PHP for the CGI version, while the version number matches? Yes What is the md5-hash beneath the download for? To verify that the file you download (from a mirror, for example) matches the official tarball from www.php.net and hasn't been modified in some way. Check it with md5sum from the command line. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 2 questions about performance...
Is it in-efficient to use shuffle()? I have a simple 6 element array with 6 strings (URLs to images) and I'm using shuffle() to display all of them in random order upon each page load. The images take a long time (of course is relative, it's mere seconds) but when I remove the call to shuffle, they appear much much faster... Also, is there an efficient number or limit of queries one should call in a singular PHP page? On average, I'll make 7-10 seperate queries to display a page (a graphics related portal and content management system)... I have a singular database connection (with mysql_pconnect()) and use that same connection throughout the script. Sometimes it appears to load quickly, than other times it doesn't, and I'm afraid that as more and more content get put into the databases, the slower it will perform. user authentication navigation (link definitions) form dropdowns (dynamic selects) banner rotation (2 sets, big and small) activity tracker headline or story retrieval comments Joseph E. Sheble a.k.a. Wizaerd Wizaerd's Realm Canvas, 3D, Graphics, ColdFusion, PHP, and mySQL http://www.wizaerd.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]
Re: [PHP] 2 questions about performance...
simplest answer is find out yourself. every machine will depending on config and hardware will be difffernet. ?php function mtime() { $mtime = microtime(); $mtime = str_replace('.', '', $mtime); $mtime = explode(' ', $mtime); $mtime = $mtime[1] . $mtime[0]; return($mtime); } class debug { function debug() { $this-start = mtime(); } function reset() { $all_vars = get_object_vars($this); foreach($all_vars as $pos = $val) if ($pos != 'error') unset($this-$pos); } function time($text = '') { $this-break = mtime(); $time = ($this-break - $this-start) / 10; echo number_format($time, 4) .' '. $text ."br\n"; $this-start = $this-break; } } $debug = new debug; //--- $debug-time('start'); // code snippit $debug-time('end'); ? works great or me. you can find out exactly where your code is slowing you down, only thing is now to find out how to improve that :) -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 [EMAIL PROTECTED] ""Joe Sheble (Wizaerd)"" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Is it in-efficient to use shuffle()? I have a simple 6 element array with 6 strings (URLs to images) and I'm using shuffle() to display all of them in random order upon each page load. The images take a long time (of course is relative, it's mere seconds) but when I remove the call to shuffle, they appear much much faster... Also, is there an efficient number or limit of queries one should call in a singular PHP page? On average, I'll make 7-10 seperate queries to display a page (a graphics related portal and content management system)... I have a singular database connection (with mysql_pconnect()) and use that same connection throughout the script. Sometimes it appears to load quickly, than other times it doesn't, and I'm afraid that as more and more content get put into the databases, the slower it will perform. user authentication navigation (link definitions) form dropdowns (dynamic selects) banner rotation (2 sets, big and small) activity tracker headline or story retrieval comments Joseph E. Sheble a.k.a. Wizaerd Wizaerd's Realm Canvas, 3D, Graphics, ColdFusion, PHP, and mySQL http://www.wizaerd.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] 2 questions
Hi I have a couple of questions. One about hosting and the other about IP addresses. The first on the IP's. I have been speaking to a company that I am looking at getting a dedicated server from. They ONLY do one IP address per server and use name-based hosting. I have asked for dedicated IP's, but their answer has been that all hosting companies are going to have to go to name-based hosting now. What is everyone's feeling on this? Years ago, the company I was with used name-based and I remember that the search engines did not like this On to hosting, the above server is a Cobalt Raq 4i. Does anyone else on the list use one of these and what do you think? I want to make sure that it's easy enough to compile latest php and mysql whenever I want to Thanks for any advice Ade -- 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] 2 questions
I use a RaQ3 and have no problems running PHP and MySQL. I started out using one IP but the biggest problem I found was that in order to view the site or make changes to it, the domain name must resolve to the server before it would work. I decided it would be best for me to assign each site an IP and go with it. I am not sure who you are talking to about a dedicated RaQ but look into http://www.4webspace.com. I have a RaQ3 with 100 gig transfer and 30 IP's for $110 a month. They do have RaQ4's for a little more money. David Smith - Original Message - From: Adrian Teasdale [EMAIL PROTECTED] To: PHP List Post [EMAIL PROTECTED] Sent: Sunday, February 04, 2001 12:47 PM Subject: [PHP] 2 questions Hi I have a couple of questions. One about hosting and the other about IP addresses. The first on the IP's. I have been speaking to a company that I am looking at getting a dedicated server from. They ONLY do one IP address per server and use name-based hosting. I have asked for dedicated IP's, but their answer has been that all hosting companies are going to have to go to name-based hosting now. What is everyone's feeling on this? Years ago, the company I was with used name-based and I remember that the search engines did not like this On to hosting, the above server is a Cobalt Raq 4i. Does anyone else on the list use one of these and what do you think? I want to make sure that it's easy enough to compile latest php and mysql whenever I want to Thanks for any advice Ade -- 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]