[PHP] Re: Using and Echoing Session Variables

2004-07-18 Thread Jason Barnett
Harlequin wrote: OK, so here's my conundrum... After verifying the user and pulling all fields from the record I declare two variables (just testing here): $_SESSION['UserID'] = UserID; now contains the string / constant UserID $_SESSION['FurtherComments'] = FurtherComments; now contains the

[PHP] Re: Using and Echoing Session Variables

2004-07-18 Thread Jason Barnett
Harlequin wrote: So If I needed say 10 session variables all based on field values in the database I'd have to execute 10 separate queries and assign each variable separately...? If that's the case then fine - as I only need do it once I know, but it does seem a rather long winded way of doing

[PHP] Re: Using and Echoing Session Variables

2004-07-18 Thread Jason Barnett
Harlequin wrote: Jason Would there be anything wrong with using an include statement at the top of every page and the include page could then start a session, execute queries etc or would the session not start as it's not the first line in the page...? That's completely fine. The main thing is,

[PHP] Re: Using and Echoing Session Variables

2004-07-18 Thread Jason Barnett
Jason Barnett wrote: Harlequin wrote: Jason Would there be anything wrong with using an include statement at the top of every page and the include page could then start a session, execute queries etc or would the session not start as it's not the first line in the page...? That's completely

Re: [PHP] PHP Form Field Validation

2004-07-18 Thread Jason Barnett
if (empty($_REQUEST['formfieldname'])) { //do something } else { //do something else } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: separating a file extention

2004-07-18 Thread Jason Barnett
I'm a bit confused as to what you mean by posting the list into a text field (do you want to print_r the list?). But an easy, efficient (I think) way to do this is strrpos(). ?php function sort_extensions($a, $b) { $apos = ($pos = strrpos($a, '.')) ? (strlen($a) - $pos) : 0; $bpos = ($pos

Re: [PHP] Re: Is Function Constants the Correct Term?

2004-07-18 Thread Jason Barnett
If someone has access to the source then yes, you're screwed. But you can put your class library outside of the document root and keep the login information inside the class instead of keeping that information in your web pages. -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

[PHP] Re: catch $variable with spaces, and convert them

2004-07-18 Thread Jason Barnett
This should work... enjoy! ## code, using PEAR DB ## while ($q-fetchInto($row)) { print ( tr td width=90 align=center .$row[0]. /td tda href=FILES/ .$row[1]. .$row[1]. /a/td tda href=FILES/ .rawurlencode($row[1]). .$row[1]. /a/td td .$row[2]. /td /tr ); }; ## end

[PHP] Re: Using and Echoing Session Variables

2004-07-19 Thread Jason Barnett
Ligaya Turmelle wrote: if they are all coming from the same query can't you assign them using the fetch_assoc? Sure! Ex: $data = mysql_fetch_assoc($result); $_SESSION['column1'] = $data['column1']; $_SESSION['column2'] = $data['column2']; $_SESSION['column3'] = $data['column3']; ... Or am I

[PHP] Re: expiring login by 5 days period

2004-07-19 Thread Jason Barnett
Louie Miranda wrote: Hello, i had been working the whole day thingking about how to expire a login? Using dates. I have with me the ff fields: 1. regdate (-MM-DD) 2. expired (1=(Yes) or 0=(No)) Can you give me some tips, how to write this on php? The problem is, i could not figure out how to

[PHP] Re: Parse Error, Unexpected $

2004-07-19 Thread Jason Barnett
Did the error actually say Unexpected $end ? That would mean that PHP hit the end of the script before it expected to, and could be caused by an unclosed string. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Parse Error, Unexpected $

2004-07-19 Thread Jason Barnett
But the error (line 40) is actually the last line...! :| You had a missing brace. When the error line is the last line (and especially if error is Undefined $end) then you likely have a missing ending brace or ending quote. Not trying to start a flame war here, but if you try a different

[PHP] Re: Mixing $_POST with text in a variable

2004-07-19 Thread Jason Barnett
Markus Stobbs wrote: I'm changing my HTTP POST variable declarations from $variablename to $_POST['variablename'] to make my code more compliant with current best practices. However, I find that I cannot mix these new variable declarations into big variable strings like I used to. For example,

[PHP] Re: Login Script

2004-07-19 Thread Jason Barnett
Brian Krausz wrote: While I know there are many scripts out there, and have spent many hours looking through them, I am having trouble finding a login script that fits my needs. I am looking for the following: A MySQL-based login system that doesn't use Pear :: DB. All I would like is for it

[PHP] Re: PHP XL2Web?

2004-07-19 Thread Jason Barnett
Eric Marden wrote: I recently heard of a product called XL2Web (www.xl2web.com) and wanted to know if there is a php variant out there, perferably open source. It's going to be used for one or two excel files (our budget spread sheets) so i can't see spending the money on the commercial product.

[PHP] Re: Array Losing value

2004-07-19 Thread Jason Barnett
if I die(sizeof($objDBI-Fetch_Array($objDBI-getResultID( within the DBI method, it return the correct value, however if I do $retval = $objDBI-Fetch_Array($objDBI-getResultID()); die(sizeof($retVal)); $retval != $retVal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] is there anyway to use constants in a string?

2004-07-19 Thread Jason Barnett
I was working on something else tonight when I literally stumbled across another solution that works here... pick your poison: ?php $heredoc = XML ?xml version=1.0 encoding=iso-8859-1 ? root node attribute=I am an attribute textI am a text node./text /node dynamic

[PHP] Re: Execute a scipt in the background

2004-07-20 Thread Jason Barnett
Narender wrote: I want to start the execution of a script in the background at the time of user login. In the script there is infinite loop which is checking something after every 10 seconds and if it get true value the it open a popup window on the brower and if the user session expires then it

[PHP] Re: current directory?

2004-07-20 Thread Jason Barnett
Justin French wrote: I've got some weirdness with files included via a symbolic link. Is there any way I can find out what directory PHP is currently trying include from? --- Justin French http://indent.com.au echo getcwd(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

[PHP] Re: current directory?

2004-07-20 Thread Jason Barnett
I should have probably added this to my last note, but if I find I'm having weirdness with relative includes I do something like this: include_once dirname(__FILE__) . ../relative/path/to/script.php; The __FILE__ constant will resolve to the name of the file it's located in, so you can rely on

[PHP] Re: newbie needs help in getting php and MySQL integrated

2004-07-20 Thread Jason Barnett
Everyone read closely... this is a nice error report that shows a) he's done his homework and b) what he tried that didn't work. Chris Hunt wrote: All, I'm a newbie trying to learn PHP and MySQL (following examples in a book PHP and MySQL by Larry Ullman. I am running: Windows XP SP1 Norton

[PHP] Re: PHP 5 installation

2004-07-20 Thread Jason Barnett
DON'T REPLY TO A MESSAGE WHEN YOU NEED TO START A NEW THREAD! Marv Cook wrote: I have PHP 4 installed and tried to install 5. No luck. Both at the same time? Do you *really* need this? It's generally much easier to have only one installation at a time. I unzipped over the current folder

Re: [PHP] Problem of a beginner with Array

2004-07-20 Thread Jason Barnett
Hey John, maybe you should ask him how his script picks the winning lottery numbers :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: template and file read

2004-07-20 Thread Jason Barnett
Ee wrote: Dears, In one of the tutorials I read about templates, the writer is diving the code into multiple files. He put the menu, main, left, right, footer each in a separate file. He is using foreach to go through an array and reads all these files. Is this a good practice? I use a lot of

[PHP] Re: file_exists() to search for *.xml file with a wild card???

2004-07-20 Thread Jason Barnett
Scott Fletcher wrote: I would like to use the file_exists() or something similar to check for the existance of any of the xml files regardless of what filename it use. Like file_exist(*.xml) for example. Anyone know?? FletchSOD fnmatch() -- PHP General Mailing List (http://www.php.net/) To

[PHP] Re: PHP5, XPath and count()

2004-07-20 Thread Jason Barnett
To find the number of nodes in a DomNodeList you need to access the length property... sample code to do this: ?php $xml = XML music artist id=1 nameThe Rolling Stones/name albums titleExile On Main Street/title /albums /artist artist id=2 nameAimee Mann/name

[PHP] Re: PHP5 - Weird Error - cannot find element in variable

2004-07-20 Thread Jason Barnett
The Object is being created perfectly, I've checked. The collection's Add() method is something like: Since you know you're adding MyObject objects, first of all check for that: public function Add(MyObject $object) public function Add($object) {

[PHP] Re: PHP5 - Weird Error - cannot find element in variable

2004-07-20 Thread Jason Barnett
: Scott Hyndman [EMAIL PROTECTED] To: Jason Barnett [EMAIL PROTECTED] Overwriting at that index is intended. Object (Really called Amenity) is defined as such: class Amenity { public $position; public $name; public $description; public $context; public $state

[PHP] Re: How to use reflection API?

2004-07-21 Thread Jason Barnett
Andreas Goetz wrote: I'm trying to use theh reflection API but can't seem to start: $func= new Reflection_Function('counter'); This was changed, manuals haven't caught up yet. This should be $func = new ReflectionFunction('counter'); You can also just use the static method export, if you intend

Re: [PHP] PHP-5 book

2004-07-21 Thread Jason Barnett
Philip Olson wrote: Can someone advise me of a very good PHP-5 book. Hands down the best: Advanced PHP Programming by George Schlossnagle Regards, Philip I've also read this book (*almost* cover to cover) and it is quite excellent. However, it definitely assumes that you understand the basics

Re: [PHP] PHP5, XPath and count()

2004-07-21 Thread Jason Barnett
this doesn't work yet in DOM. The returned value has to be a nodeset. Will be fixed some day ;) see victors answer for the work around chregu I was wondering about that. So is there someplace online where we can find out what does / does not yet work for XPath? I've been looking but google

Re: [PHP] Re: template and file read

2004-07-22 Thread Jason Barnett
Is the compiler cache a function of the my web host or my code? You can cache the PHP bytecode on the server (which is more what I meant originally), and you can also cache in your code. For an easy example of caching with your code you could check out PEAR's package Cache_lite. -- PHP

[PHP] DirectoryIterator

2004-07-22 Thread Jason Barnett
Hey guys, I'm getting some unexpected results when trying to use ArrayIterator - but since it's undocumented this might be correct. When I use a DirectoryIterator to traverse a directory I can't seem to create an array containing all of the directory elements. I've tried using references as

Re: [PHP] How to use reflection API?

2004-07-22 Thread Jason Barnett
See: http://www.php.net/manual/en/language.oop5.reflection.php Curt Oops, hadn't seen that yet. Great! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: Preventing static method calls in PHP4

2004-07-22 Thread Jason Barnett
The easiest way I can think of to prevent static method calls is to use the $this pseudo variable in your method. A method *cannot* be used statically if the method requires use of $this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: PHP 5 and Implicit cloning

2004-07-22 Thread Jason Barnett
If you need a copy of an object (like the default in PHP4), you can explicitly do that with clone. $cErrorHandler = new testErrors(); $clone = clone $cErrorHandler; If you do this you shouldn't need zend engine 1 compatibility (unless you need that for other reasons). -- PHP General Mailing

Re: [PHP] PHP5 - Weird Error - cannot find element in variable

2004-07-22 Thread Jason Barnett
Give us the exact error as it is displayed in your browser. Also did you try to print_r on every Add as was suggested to you earlier? To be honest, I'm starting to wonder if we haven't stumbled on a bug. I have had similar problems (in an entirely different context) and improper cloning may

[PHP] Re: Project-browser-function / required/included

2004-07-22 Thread Jason Barnett
Hmmm... this may be difficult to implement. For simple include/require trees it could be done quite easily... but __autoload opens up a whole other bag of worms. But now that I think of it I suppose you could create Reflections and get the location of class defintions from that. This might

[PHP] Re: PHP 5 and Implicit cloning

2004-07-22 Thread Jason Barnett
Jules wrote: Jason, I need it for other reasons. This is not a new application that is causing this. It was built on PHP 4 and therefore has lots of non PHP 5 elements. So I'm pretty sure I need than on, unless someone has another idea... Thanks, Jules... Not sure what all your classes do, but

Re: [PHP] Re: Project-browser-function / required/included

2004-07-22 Thread Jason Barnett
Frank Munch wrote: Hi, thanks for your comment. Right, and similarly, it struck me that in case there are variable-names in the path, like in require_once $my_lib_dir . some_funcs.php; the variable $my_lib_dir could only be known at run-time and not by any simple script just scanning the

[PHP] Re: DirectoryIterator

2004-07-22 Thread Jason Barnett
Jason Barnett wrote: Hey guys, I'm getting some unexpected results when trying to use ArrayIterator - but since it's undocumented this might be correct. When Typo... I actually got ArrayIterator to work... should have said DirectoryIterator which doesn't inherit from ArrayIterator. Life would

[PHP] Aggregating classes?

2004-07-22 Thread Jason Barnett
Since I can't have a class inherit from two parent classes, does anyone know how I could aggregate class methods / properties together? I thought of using __call, __get and __set but I'm having a tough time wrapping my mind around that one - mostly potential problems with $this. -- PHP

[PHP] Re: DOMXML support should be added to PHP5

2004-07-23 Thread Jason Barnett
Scrumpy wrote: Sorry for the repeated posts. I didn't know that they got queued awaiting confirmation of my email address :) Yeah, I was wondering about the reposts. Well you are right that if you used the old DOMXML functions in PHP4 that there is no clean way to move that code forward

[PHP] Re: Installing Php5 over Existing Php4.3.6

2004-07-23 Thread Jason Barnett
Francis Chang wrote: Hi, I would like to install Php5 over an existing Php4.3.6 installation on Linux. What is the proper procedure? Do I need to uninstall the previous version first, if so, how? Can I install Php5 into the same location as the previous installation or should I install it into

[PHP] Re: Changing items in $_POST

2004-07-23 Thread Jason Barnett
However, there are a few variables I need changed. For example, the people I'm sending it to need $rate_1m which is a mortgage rate but in $_POST there is $rate_1m1 (the whole number) and $rate_1m2 (the two numbers after the decimal). How do I get those two together and then discard the two

[PHP] Re: Code elegance and cleanliness

2004-07-23 Thread Jason Barnett
Depends on the project. Generally I try to use something more like the first code block unless I really need to optimize for the server. Getting another server is usually cheaper than the extra time (read: money) spent debugging. Robb Kerr wrote: Just a quick question. Does it really matter

[PHP] Re: replace n first occurences of a char in a string

2004-07-23 Thread Jason Barnett
Then, once I have determined there are more than one dot, how can I remove all the dots but the right most one? You can replace a limited number of matches using preg_replace(). ?php $number = '123.456.789.10'; $count = substr_count($number, '.'); $number = preg_replace('/\./', '', $number,

Re: [PHP] Weeeeee! ;)))

2004-07-24 Thread Jason Barnett
Comex wrote: but there isn't any archive.. Let's see I shake my magic 8-ball and it says... PEAR? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: include_path ???

2004-07-24 Thread Jason Barnett
When I run phpinfo() the include_path points to .;c:\php\PEAR but that is incorrect the correct path is c:\inetpub\php5\PEAR. Are you *certain* you're looking at the correct ini file? phpinfo() should show the settings currently in use for your server (assuming you're calling the phpinfo in a

[PHP] Re: Learning Regex

2004-07-24 Thread Jason Barnett
This helped me get started with Perl-compatible regular expressions: http://www.weitz.de/regex-coach/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] How to get all links from a webpage?

2004-07-25 Thread Jason Barnett
Wudi wrote: This script can replace links: $text = ereg_replace([[:alpha:]]+://[^[:space:]]+[[:alnum:]/], a href=\\\0\\\0/a, $text); But it cannot get the links. Magic 8-ball says... go read ereg() in your manual. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

[PHP] Re: include_path ???

2004-07-25 Thread Jason Barnett
Lester Caine wrote: D_angle wrote: This is taken right out of the download of PHP 5 zip file php-5.0.0-Win32.zip. Opening the php.ini-recommended it states the following configuration php.ini-recommended is probably not the one being used... if you want to use this you most likely just need to

[PHP] Re: class help (PLEASE)

2004-07-25 Thread Jason Barnett
No offense intended, but I'm not going to read through all of that. Narrow down the code block that gives you problems and then post that one block here... not the entire class. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: PHP function speed testing

2004-07-25 Thread Jason Barnett
Shawn McKenzie wrote: O.K. So I've written my application and debugged it, and now I want to try and optimize the speed. I have written a little test script to test Several profilers / debuggers will help you optimize on speed... by telling you how much time the parser spends inside a

Re: [PHP] Re: class help (PLEASE)

2004-07-25 Thread Jason Barnett
Hey Jason, No offense at all taken, am happy you read part of my help-email. Problem is, like I said, I dont have a clue about the workings of a class and all the pointing like this $this- blah (-) means blah is a property of the class. ($this) means an instance of the class. gets me totally

[PHP] Re: Sticky session after session_destroy...

2004-07-26 Thread Jason Barnett
Since you're using cookies, are you remembering to destroy the cookie as well? Check your web browser to see if the cookie is still there - then do your logout script - and then immediately check to see if the cookie is still there. Firefox makes this easy... just another reason why I love that

[PHP] Re: totally new to PHP

2004-07-27 Thread Jason Barnett
phpfreaks.com and codewalkers.com Or check the mailing list archives, others have been mentioned before. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: Organising PHP projects

2004-07-27 Thread Jason Barnett
One of the new options that I am playing with is the __autoload() handler. If you keep each of your main classes in a separate file then it will try to load the class file the first time you try to create an instance of an undefined class. There is a little bit of documentation out there about

[PHP] Re: Problem with circular include statement

2004-07-27 Thread Jason Barnett
I *believe* that include_once will be all that is necessary. However if that doesn't stop the problem, you can use a DEFINE and at the top of each script: if (!defined(FILE1)) { include_once 'file1.php'; } -- file1.php - define ('FILE1', TRUE); -- PHP General Mailing List

Re: [PHP] Urgent..my MYSQL dies..

2004-07-27 Thread Jason Barnett
[EMAIL PROTECTED] wrote: please give me a command line to startup MySQL using safe_mysqld C:\ ---John Holmes... HAHAHA How'd you guess they would have a drive letter for their prompt :) Oh, us poor, poor windows users. Microsoft has protected us from it for so long that we've forgotten what

[PHP] Call for XML / XPATH examples

2004-07-27 Thread Jason Barnett
I'm working on a project that makes use of the DOMXPath class in PHP5. I have some test xml documents / queries, but it would be good to test my project with other people's documents / xpath queries that do things mine don't. Please reply off list though, since I doubt most of the people here

Re: [PHP] Installing PEAR on Windows

2004-07-28 Thread Jason Barnett
[EMAIL PROTECTED] wrote: Hi Matt (et al), I've added the c:\www\pear path to both the windows path and also the path in the php.ini file. However it's still coming up with the same error. Is there a way of putting in a temporary path in the go-pear.php file? Yes... ini_set('include_path',

Re: [PHP] For Loop Problems

2004-07-28 Thread Jason Barnett
[EMAIL PROTECTED] wrote: Hello Everyone, I'm building a hotel management system and I can't seem to figure out why my for() loop doesn't work the way it should. I'm using patTemplate to create the HTML Template (I like using it and I don't want to start a pro/con template war). Here is the script:

[PHP] Re: Accessing a variable from inside a local function

2004-07-28 Thread Jason Barnett
Something like this is probably better handled by a class. Then you can access class properties to do what you want. Class yourclass { function foo() { $this-my_foo_local = 10; } function bar($var_bar) { return $this-my_foo_local+$var_bar+1; } } $object = new yourclass();

Re: [PHP] strpos mystery

2004-07-28 Thread Jason Barnett
Because === and !== check the type as well. Of you set $string = 'blah' you'll still get the same result. If you were using != and == both would print. strpos() returns an int, so comparing it to false with === is always false. The same would be true for true. That's half right. strpos actually

Re: [PHP] strpos mystery

2004-07-28 Thread Jason Barnett
Heck, even I got it wrong ;) True check below should always fail... Jason Barnett wrote: Because === and !== check the type as well. Of you set $string = 'blah' you'll still get the same result. If you were using != and == both would print. strpos() returns an int, so comparing it to false

[PHP] Re: Conversion of Field Value to Hyperlink

2004-07-30 Thread Jason Barnett
Harlequin wrote: Afternoon... I have a table generated by some code that returns certain field values and drops them into a table. On of these values is ID and I'd like to convert it I wouldn't let users create their own primary key for any type of inserts, if that's what you're using ID for.

Re: [PHP] Conversion of Field Value to Hyperlink

2004-07-30 Thread Jason Barnett
Funny... for the short time I've been on the list, it seems like our most popular topics are the ones that involve flaming. I guess I need to get some charcoal for my barbecue pit, lest I be the one on the end of the fork ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

Re: [PHP] Browser reload problem

2004-07-30 Thread Jason Barnett
Is there a question here? Or is this a resolution? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: PHP5 Manual in PDF and for Pocket PCs

2004-07-31 Thread Jason Barnett
As far as I know, no one has done that yet. Although all of the PHP manual pages are written in XML so if you were so inclined you could do it yourself. And I'm sure others would appreciate it if you shared it :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

[PHP] Re: Advise on parsing XML

2004-08-07 Thread Jason Barnett
I assume you are using PHP4's DOMXML functions? If that's the case then you have a bit of a problem. XML support changed between 4.0 and 5.0, we use libxml2 (which supports UTF-8), but the object model / methods changed to better conform with the DOM standard. Also AFAIK the experimental tag

[PHP] instanceof / __CLASS__ question

2004-08-31 Thread Jason Barnett
It's only a minor nuisance, but in order to use __CLASS__ with instanceof I have to assign __CLASS__ to a variable first. Should I bother submitting a bug report for this? Or am I perhaps missing something... ?php class Test { function checkObj2() { //workaround $class =

[PHP] help with crc32

2004-08-31 Thread Jason Barnett
I've been able to use md5 / md5_file to verify file integrity. However when I try to check crc32's I'm running into some problems. As an example I download and extract the PHP package for Windows, then when I try to crc32() the file contents I get a totally different value from what I think I

[PHP] Re: Broken data within an Array

2004-08-31 Thread Jason Barnett
Harlequin wrote: Hi all. Having a problem echoing a broken date. Here's where I'm at: $DateAdvertisedBroken = explode(-, $DateAdvertised); So this contains an array of (year, month, day) or something similar? You should be able to grab the values here if that's the case. later, in a table, I

[PHP] Re: help with crc32 [SOLVED]

2004-08-31 Thread Jason Barnett
I hate when this happens all I needed was dechex(). *sigh* I could have sworn I'd tried that already, ah well. Jason Barnett wrote: I've been able to use md5 / md5_file to verify file integrity. However when I try to check crc32's I'm running into some problems. As an example I download

[PHP] is_a (WAS: Re: instanceof / __CLASS__ question [SOLVED])

2004-08-31 Thread Jason Barnett
Greg Beaver wrote: Hi, I'm not sure I understand why you would use instanceof on $this. Try this code: Kind of complicated (so probably not the best way) but I have objects I'm creating with a factory method - and all of these objects *should* be extending a parent class. It's in the parent

<    2   3   4   5   6   7