[PHP] Unclonable objects
What situation would make a mysqli object unclonable? This is a problem that occurs only on a linux machine with mysql4. I am simply trying to declare a link resource and I get an error "Trying to clone unclonable object of type mysqli" If I declare the link using a reference however, the code seems to work fine. It still would be better not to use a reference though. Thanks in advance, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysqli unclonable object
On a Fedora 4 machine running MySQL 4.1 I am having trouble declaring an instance of a mysqli extension. class Data extends mysqli { function __construct($host, $user, $password, $db = null) { @parent::__construct($host, $user, $password, $db) or printf("There was an error (id: %d) connecting to the database: %s", mysqli_connect_errno(), mysqli_connect_error()); } } $link = new Data("localhost", "user", "password", "db"); This invokes the error "Trying to clone unclonable object of type Data." However if I create the link with a reference ... $link =& new Data(); ...everything works fine. This error is interesting because it only occurs on the machine mentioned above, in a Windows/MySQL 5.0 environment, everything works fine without the reference. Thanks in advance! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqli unclonable object
Thanks for your attention Curt, but unfortunatly that is not the issue. Compatibility mode is not on. For documentation's sake, I think the problem is that there are other links in the code using the same credentials. When you declare a link resource to a database, PHP first searches to see if there is already one open, therefore despite the fact that this link wasn't even using the same library (mysql vs mysqli) it didn't matter; only one connection to the database could be made (as root in this case). If this is incorrect or anyone has additional insight, please reply. Thanks, Matt "Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wed, Nov 23, 2005 at 01:13:22AM -0500, Matt Monaco wrote: >> On a Fedora 4 machine running MySQL 4.1 I am having trouble declaring an >> instance of a mysqli extension. >> >> class Data extends mysqli { >> >> >> $link = new Data("localhost", "user", "password", "db"); >> >> This invokes the error "Trying to clone unclonable object of type Data." >> However if I create the link with a reference ... >> $link =& new Data(); >> ...everything works fine. > > This is because you have the ini option: > > zend.ze1_compatibility_mode = On > > > Curt. > -- > cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqli unclonable object
I get string(1) "", should that be taken just the same as 0? In addition phpinfo() indicates php 5.0.4 - does the upgrade to .5 involve remove .4 first? btw, as I'm new to the mailing list thing, why do some names appear in quotes and others do not? Thanks, Matt "Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wed, Nov 23, 2005 at 06:48:50PM -0500, Matt Monaco wrote: >> Thanks for your attention Curt, but unfortunatly that is not the issue. >> Compatibility mode is not on. > > What does this say just before you do $link = new ...: > > var_dump(ini_get('zend.ze1_compatibility_mode')); > > If it says string(1) "0", then either your using php4 or some buggy > version of php5. > >> For documentation's sake, I think the problem is that there are other >> links >> in the code using the same credentials. When you declare a link resource >> to >> a database, PHP first searches to see if there is already one open, >> therefore despite the fact that this link wasn't even using the same >> library >> (mysql vs mysqli) it didn't matter; only one connection to the database >> could be made (as root in this case). >> >> If this is incorrect or anyone has additional insight, please reply. > > Only the old mysql extension has any sort of credential checking > and if they are the same, returns the same connection (which can be > bypassed with an option to mysql_connect(). mysqli has no such > credential checking. > > > Curt. > -- > cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Passing objects between pages
What is the best way to pass an object between pages? Currently I am first serializing, then doing a base64_encode, this doesn't seem entirely efficient. (Especially the encode). I am however using the encode because I have the serialized object as the value of a hidden form element. I can only have alphanumerics here. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: array woes
Within grabQuotes(); if you do a var_dump($arg); (where $arg is $res[id]) is your vehicle name displayed? If it is, and you're using it correctly, make sure you're returning the value you'd like correctly. It might help to post your grabQuotes function as well as the code that displays $cars[]. Matt "blackwater dev" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello all, I have some array code driving me nuts. I am pulling from a db: select id, vehicle, has_quotes from cars where active=1 I then loop through these and build an array that contains the id's and cars. while($res){ $cars[$res[id]]=$res[vehicle]; //here is the problem, when has_quotes is 1, I call another function to grab the quotes if ($res[has_quotes]>1){ $cars[$res[id]]=grabQuotes($res[id]); } } The grabQuotes function returns an array and works fine. THe problem is when I go to display these, I cycle through the car array printing id and vehicle name. I do a check so if vehicle name is an array, I print out the quotes from the inner array, problem is I have lost the vehicle name! How can I fix this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: swaping numerical index for keys
function addAssoc($ary_stat) { $ls_statfields = array(.); while ($assoc = each($ls_statfields)) { $ary_stat[$assoc['key']] = $ary_stat[$assoc['value']]; } return $ary_stat; } This should do what you want. I'm not sure if you want to remove the numeric keys entirely, but after this function they still exist. Matt "Pooly" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I've an array : $ls_statfields=array( "rfile" =>0, "file" =>1, "dev" =>2, "ino" =>3, "mode" =>4, "nlink" =>5, "uid" =>6, "gid" =>7, "rdev" =>8, "size" =>9, "atime" =>10, "mtime" =>11, "ctime" =>12, "blksize" =>13, "blocks" =>14 ); Which is the correspondance between the numerical and keys for stat before PHP 4.0.6 : http://uk.php.net/manual/en/function.stat.php What would be the fastest solution to transform the result from stat to the one with the keys (before 4.0.6 :-) ? (i.e. Exchanging numerical indexing the for hash keys in the ls_statfields ?) -- Pooly Webzine Rock : http://www.w-fenec.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $_GET and $_POST arrays not working
In php.ini (most likely located in your windows directory) look for the globals section and turn register_globals = on Matt "Unknown Unknown" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello everyone, i am running PHP 5 on Windows XP Pro SP2, my $_GET and $_POST arrays do not seem to be working, I am Sure I am spelling them right, but i keep getting the errors: ** *Notice*: Undefined index: Username in * D:\Apache\Apache(re)\Apache2\htdocs\RegisterP.php* on line *3* *Notice*: Undefined index: Password in * D:\Apache\Apache(re)\Apache2\htdocs\RegisterP.php* on line *4* *Notice*: Undefined index: EMail in * D:\Apache\Apache(re)\Apache2\htdocs\RegisterP.php* on line *5* Is this a problem with configuration or is there a bug in PHP, thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Passing objects between pages
I mean the object itself, not the class (the file containing the class definition is included on all necessary pages with require_once("file.inc.php"); I want to create an object on one page ($obj = new MyClass();) and have it on other pages, all members and functions intact. Matt "Unknown Unknown" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Do you mean passing the class statement or the vars? couldn't you format the vars into mysql and pull them? On 11/25/05, Matt Monaco <[EMAIL PROTECTED]> wrote: > > What is the best way to pass an object between pages? Currently I am > first > serializing, then doing a base64_encode, this doesn't seem entirely > efficient. (Especially the encode). > > I am however using the encode because I have the serialized object as the > value of a hidden form element. I can only have alphanumerics here. > > -- > 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] Re: $_GET and $_POST arrays not working
Somewhat, but its what you need to do for the post and get arrays to work. What you need to do is make sure check the values in the global variables before you use them. For example if on one page you have a form for a user signup and on the next page $_POST['userName'] should be checked for things like quotes and other characters that will alter your SQL statement before you actually INSERT that value into your table. "Unknown Unknown" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Doesn't that cause security problems? On 11/25/05, Matt Monaco <[EMAIL PROTECTED]> wrote: > > In php.ini (most likely located in your windows directory) look for the > globals section and turn register_globals = on > > Matt > > > "Unknown Unknown" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Hello everyone, i am running PHP 5 on Windows XP Pro SP2, my $_GET and > $_POST arrays do not seem to be working, I am Sure I am spelling them > right, > but i keep getting the errors: > ** > *Notice*: Undefined index: Username in * > D:\Apache\Apache(re)\Apache2\htdocs\RegisterP.php* on line *3* > > *Notice*: Undefined index: Password in * > D:\Apache\Apache(re)\Apache2\htdocs\RegisterP.php* on line *4* > > *Notice*: Undefined index: EMail in * > D:\Apache\Apache(re)\Apache2\htdocs\RegisterP.php* on line *5* > > Is this a problem with configuration or is there a bug in PHP, thanks in > advance > > -- > 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] Passing objects between pages
I know the functions don't need to be copied. I would like to easily transport the objects (not the class) between pages using a form. I'm pretty sure the serialize() function can't be avoided (otherwise all that will be passed is a string with a value like "Object ID: #55") but how can I get around the base64_encode() so the serialized object can be the value of a checkbox? $obj = new MyClass(); $obj = serialize($obj); $obj = base64_encode($obj); //I would like to eliminate this line So on the next page I have to decode and deserialize $obj = $_POST['fieldName']; $obj = base64_decode($obj); $obj = unserialize($obj); echo $obj->member; $obj->function(); "Unknown Unknown" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Well the functions won't need to be copied, but can't you put the properties into a MySQL or other database? Then on a page that you need the properties you pull them from the table? On 11/25/05, Matt Monaco <[EMAIL PROTECTED]> wrote: > > I mean the object itself, not the class (the file containing the class > definition is included on all necessary pages with > require_once("file.inc.php"); > > I want to create an object on one page ($obj = new MyClass();) and have it > on other pages, all members and functions intact. > > Matt > > > > "Unknown Unknown" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Do you mean passing the class statement or the vars? couldn't you format > the > vars into mysql and pull them? > > On 11/25/05, Matt Monaco <[EMAIL PROTECTED]> wrote: > > > > What is the best way to pass an object between pages? Currently I am > > first > > serializing, then doing a base64_encode, this doesn't seem entirely > > efficient. (Especially the encode). > > > > I am however using the encode because I have the serialized object as > the > > value of a hidden form element. I can only have alphanumerics here. > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: $_GET and $_POST arrays not working
I apologize, but I've never been able to access $_POST and $_GET in any context whatsoever without first turning on the register globals. "John Nichel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Matt Monaco wrote: >> Somewhat, but its what you need to do for the post and get arrays to >> work. > > > No. Things like $_POST and $_GET are global arrays and work regardless of > the register_globals setting. The information you're handing out above is > wrong and dangerous. > > >> What you need to do is make sure check the values in the global variables >> before you use them. For example if on one page you have a form for a >> user signup and on the next page >> $_POST['userName'] should be checked for things like quotes and other >> characters that will alter your SQL statement before you actually INSERT >> that value into your table. > > ie they should be sanitized. Things like mysql_real_escape_string() or > adding slashes (depending on your magic_quotes setting) should be done > prior to inserting any data. Also, you should check to ensure that it's > the data you expect; if you only allow usernames to contain alpha-numeric > characters, then you should check for that. Toss is out if it contains > something else. > > Best rule of thumb: Never trust user input, regardless of the > register_globals setting. > > -- > By-Tor.com > ...it's all about the Rush > http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: $_GET and $_POST arrays not working
Well, I turned them off and it worked as it apparently should. It was just a setting I read I had to make for globals to work the first time I install PHP. I've made that change ever since. I've always wondered why these variables - which I consider really important, need to be turned on. Matt "John Nichel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Matt Monaco wrote: >> I apologize, but I've never been able to access $_POST and $_GET in any >> context whatsoever without first turning on the register globals. > > If you have a form like this one one page... > > > > > > > And this on page2.php... > > > echo ( $_POST['foo'] ); > > ?> > > And the output on page2.php is not 'bar' when you submit the form, > something is very wrong with your install. > > -- > By-Tor.com > ...it's all about the Rush > http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqli unclonable object
In outlook express by default the headers are displayed as some icons and then subject, from, sent, size. For some people From is displayed in double quotes, and others not. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Adding links to HTML for a CMS
You can use file_get_contents and use an http address as a parameter. Then use the pearl regular expressions functions to replace with the elements you'd like. ""Shaun"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I am trying to create my own CMS. To being with I want to let users edit > anything within a tag. > > I want to have a menu to the left and display the webpage in the rest of > the page, and for each set of tags I want the user to be able to click > on the link to edit that paragraph. > > My problem is how can I include a webpage in my CMS and for each tag > wrap an tag araound it? > > Thanks for your advice. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Adding links to HTML for a CMS
You can use file_get_contents and use an http address as a parameter. Then use the pearl regular expressions functions to replace with the elements you'd like. ""Shaun"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I am trying to create my own CMS. To being with I want to let users edit > anything within a tag. > > I want to have a menu to the left and display the webpage in the rest of > the page, and for each set of tags I want the user to be able to click > on the link to edit that paragraph. > > My problem is how can I include a webpage in my CMS and for each tag > wrap an tag araound it? > > Thanks for your advice. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: When to make a class
There's really no reason making classes for those (unless you'd like to write an entire HTML class and its children - I'd be happy to use it!). Matt "Todd Cary" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > My background is in Object Oriented Pascal (Delphi), however I am having > difficulty knowing when to make a class in PHP. For instance, in my > script file, functions.php, I have these functions among others: > > /* Input a field */ > function input_field($name, $value, $size, $max) { > echo(''); > }; > > /* Input a password field */ > function input_password_field($name, $value, $size, $max) { > echo(''); > }; > > > Should I have a class that contains these functions (methods)? > > One of my non-profit clients would like to have an online emailer program > driven by a MySQL database. This I can envision as a class, actually > several classes (e.g. send mail, create message, select addresses, etc.). > > Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: A basic question
In your server configuration file (httpd.conf for apache) you specify which extensions are parsed by the php module. It is perfectly acceptable for you to specify .html in addition to .php as a parsed extension. "Oil Pine" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I am new to php scripting and would like to ask you a basic question. > > Could you kindly explain to me why "time.php" works but "time.html" does > not? > > pine > > > > time.php > -- > > $serverdate = date("l, d F Y h:i a"); > print ("$serverdate"); > print (" "); > > ?> > - > > > time.html > --- > "http://www.w3.org/TR/html4/loose.dtd";> > > > > Local Time > > > > > This is a test. > $serverdate = date("l, d F Y h:i a"); > print ("$serverdate"); > print (" "); > ?> > This is the end. > > > --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help avoid multiple login
Create an object with the functionality of your choosing, in the destructor perform your cleanup operations. ""mail.pmpa"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Greetings > > I'm having some trouble on a members online script. > I use a php script to track member login to avoid multiple logins on > different ips etc. > When a logged member closes the browser window I can't delete the table > entry because I will not have access to some sort of "Session_OnEnd" > action > on hosting. > Is there a workaround for this? > > I'm using PHP 5.0.4 and IIS on win XP. > > Thanks in advance. > Pedro. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help avoid multiple login
If you store your "login object" in a session, when the browser window is closed the object will automatically be destroyed, thus calling the destructor. In response to the message you send directly to me, you would create a file called Login.class.php and at the top of each page include the file using require_once("Login.class.php"); Matt ""mail.pmpa"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >De: Matt Monaco [mailto:[EMAIL PROTECTED] >Create an object with the functionality of your choosing, in the destructor >perform your cleanup operations. The problem is I don't know when a member closes the browser window. If I knew that i would automatically logout that member. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: checkboxes
Well if your keys are a straight sequence of numbers instead of a foreach you can do a for loop and for those whose value is not one, set to zero. Matt "blackwater dev" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I have a form where I am dynamically building a bunch of checkbox inputs. Then when submitted, I need to update the db. Problem is, of course, if the checkbox is unchecked then the $_POST doesn't have the value in the array. How can I get the value from $_POST even though it's unchecked? For example, here would be the generated form: Car 1 Car 2 Car 3 Car 4 Then in the update I loop through: foreach($_POST[cars] as $id=>$value){ //update vehicles set value to yes or no } But, if the unchecked values aren't in $_POST, how do I know to update them??? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $_POST won't work for me
As I learned recently, register_globals should always be off, you do not need it to enable GET and POST variables. I believe enabling it will do something like set $_POST["name"] to $name automatically (of course there's always the 90% chance that I'm absolutely wrong). You might want to see if your _GET variables are working correctly too. Try creating a simple page: "; var_dump($_GET); echo "END TEST"; ?> If you call the page like localhost/testGet.php?testVar=testString than there might be some security settings within your http server preventing this and you should check both your http access and error logs. "Fil" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Ladies and Gentlemen, > > Thankyou for this opportunity of picking someones brains before I tear the > place apart. I am just starting with PHP but have encountered an > insurmountable hurdle.. I need to work through HTML form "posting" > examples to a PHP script. ONE STEP after "Hello World" > > I have taken the following steps: > > 1: My php.ini (The only one on the system ) is located in /etc/php.ini > > Because I am using an above 4.1 version of PHP > I have manually altered the values of > > register_globals = On > > 2: I have repeatedly stopped and restarted Apache webserver. > (Version 2) > > 3. I have a "Hello World" HTML - > hello.php that loads and runs > succesfully hence I have a valid Webserver PHP HTML connection with my > browser. > > 4. In "Hello World I have taken the liberty of including a phpinfo() > > 5. The output of phpinfo() among others reveals: > > post_max_size 8M 8M > precision 14 14 > register_argc_argv On On > register_globals On On > safe_mode Off Off > > 5. I should be able to use GLOBALS ( even if this will become a > health hazard later on) > > > 6. I have used the two examples from PHP's Documentation. > > Literally cut and paste... > > "Action.html " > >> >> >> > http-equiv="content-type"> >> filsform >> >> >> > style="text-decoration: underline;">Fils Form >> >> >> >> >> Name: > type="text"> >> >> Email: >> >> >> >> >> >> > > and action.php >> >> >> PHP Test >> >> >> HI . >> Your email >> >> > > > 7. After submitting "action.html" action.php loads and prints > > Hi > Your email > > The contents of $_POST['name'] and $_POST['email'] appear to be > unavailable to action.php. If I understand the documentation correctly > this should not be the case and whatever strings are filled in the form > of action.html should now be available??? > > What or where or how or why or whatever ? must I do next... > > Many thanks for those interested in advance > > Fil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] weird error, cookies??
Check your http access file to verify what david and jochem have said, you should see lines upon lines of access for the pages in question. "Jochem Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Angelo Zanetti wrote: >> Hi guys. >> >> Been working on my site and then been trying to navigate through it, the >> once page redirects to another. >> >> then all of a sudden I get this weird popup (in mozilla) "Redirection >> limit for this URL exceeded. Unable to load requested page" >> >> Also IE seems to timeout. >> >> The page redirects from http to https. > > yeah and I bet by the time the request comes back to your webserver it > sees > it as a HTTP request - ergo an infinite loop. > > are you using Squid per chance? or maybe doing something fancy with > url rewriting in Apache? one of those is likely to be causing the infinite > loop. > >> >> anyone come across this or know what the problem is? > > I have been fighting the such a problem all today - a site that requires > HTTPS for logged in customers (only), the site lives behind Squid (reverse > proxy) > and Squid hits Apache with HTTP requests... and if you try to hit the > login page > as http://mydomain/login.php it redirects to https://mydomain/login.php > which > is recieved by Squid which passes it to http://127.0.0.1/login.php - and > the redirect > occurs again - lots of fun really, and Squid configuration isn't mind > numbingly > painful either! > > hth to give you some possible insight :-/ > >> >> Thanks in advance. >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Submit Form Values To Parent
is valid just as with any other link. ""Shaun"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > How can I get the form values submitted from an iframe where the target is > the parent window? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Determine object type
Is there a function or method to determine the class an object was defined from? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Determine object type
Hah, I was looking in the object aggregation functions, that really deserved a RTFM "Ray Hauge" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > That would be get_class( [obj] ); > > http://us3.php.net/manual/en/function.get-class.php > > Matt Monaco wrote: > >>Is there a function or method to determine the class an object was defined >>from? >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] need session_start() to recall session data.
I have the following two methods as part of a class I'm using to transport data between pages. static function pack($object) { if (session_id() == "") { session_start(); } $class = get_class($object); $_SESSION["cmsSessionArray"][$class] = serialize($object); } static function unpack($strObject) { session_start(); return unserialize($_SESSION["cmsSessionArray"][$strObject]); } the pack() method is called by the destructor of the objects I want to save like: function __destruct() { parent::pack($this); } On subsequent pages the session data is not available until I do a session_start(). Regardless of the fact that I think the session shouldn't need to be restarted, I don't like the fact that if indeed it has been closed that a session_start() on another page will bring back the data. (Note, fortunately this doesn't not occur if the browser window has been closed, at that point all session data is definitely lost as expected.) Are session supposed to work this way? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need session_start() to recall session data.
Yes, I actually changed the destructors to handle the session as you indicated a few minutes after I posted, however I still have no clue as to why I would need to do a session_start() to get data from the session. "Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sat, Dec 03, 2005 at 01:28:21PM -0500, Matt Monaco wrote: >> I have the following two methods as part of a class I'm using to >> transport >> data between pages. >> >> static function pack($object) >> { >> if (session_id() == "") { >> session_start(); > > I wouldn't put a random session_start() in places like this. > >> } >> >> $class = get_class($object); >> $_SESSION["cmsSessionArray"][$class] = serialize($object); >> } >> ... >> >> the pack() method is called by the destructor of the objects I want to >> save >> like: >> function __destruct() >> { >> parent::pack($this); >> } >> > >> On subsequent pages the session data is not available until I do a >> session_start(). Regardless of the fact that I think the session >> shouldn't >> need to be restarted, I don't like the fact that if indeed it has been >> closed that a session_start() on another page will bring back the data. >> (Note, fortunately this doesn't not occur if the browser window has been >> closed, at that point all session data is definitely lost as expected.) > > I'm not sure what you mean by restarting a session or what 'indeed > has been closed' > > btw, your pack and unpack aren't really needed. All you have to do > is in your __destruct() function is put something like: > > $_SESSION['cmsSessionArray'][__CLASSNAME__] = $this; > > And when you pull it out of the session: > $obj = $_SESSION['cmsSessionArray']['someClass']; > > You'll have an instance of that class; you're really causing more > work than needed. > > Curt. > -- > cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php