[PHP] Object References Problem
Hi there, I'm having trouble with passing objects as references. What I want to do is something like this: class object_1 { var $my_chld; var $my_array; function object_1() { $this->my_array = array('id' => 0, 'name'=>''); $this->my_child = new object_2($this); } } class object_2 { var $my_parent; function object_2(&$parent_object) { $this->my_parent = $parent_object; } function set_parent() { $this->my_parent->my_array['id'] = 1; $this-> my_parent->my_array['name'] = 'test'; } } $instance = new object_1(); $instance->my_child->set_parent(); echo "instance: ".$instance->my_array['name'].""; echo "parent: ".$instance->my_child->my_parent->my_array['name'].""; The above code give the output: instance: parent: test where I want it to give: instance: test parent: test but somewhere along the way, the reference to the parent object is being broken. I've looked all over the place, and I can't find the answer to this. Can somebody please help me? Cheers, Gareth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Object References Problem
Boyan, Michael and Mike, Thanks for the help, I now understand what is going on, and you guys have saved me from pulling my hair out in frustration. I'm more used to doing OOP in Delphi and Perl, and the peculiarities of PHP are somewhat confusing. Once again, thanks for the help. On Friday, Oct 31, 2003, at 03:03 Europe/Amsterdam, Mike Migurski wrote: I don't pretend to fully understand PHP references, or the strange and mysterious ways that they work in regards to PHP objects, but I can tell you how to acheive the results you desire. Someone else will have to explain it. :) If someone sees that I'm leading Gareth astray here, feel free to jump in and correct me... Your explanation squares with my experience. My understanding from dealing with some fairly complex OOP interactions is that PHP operators generally favor passing-by-value to passing-by-reference, and the underlying language engine is optimized to perform well under those circumstances. Which is great, if you're new to programming, have never used Java or C, and are tossing arrays around and don't want to be bothered with premature optimization, but it's a royal pain when you need to maintain some degree of referential integrity. I frequently find myself using '&' all over the place to cut down on accidental returns-by-value. I have not yet had a chance to play with PHP5's beta versions, but its strong focus on OOP makes me wonder, what kind of language changes (if any) were required to help ease this situation? -mike. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using existing mysql connection in a php extension
Hi there, Try this: mysql_pconnect($_host, $_user, $_password) or die("Could not connect: " . mysql_error());; This open a permanent mysql connection. The first time you run it, it opens the connection, and the second time, etc, it just uses the one already opened. On Friday, Oct 31, 2003, at 13:14 Europe/Amsterdam, Adrian wrote: hello, is it possible to use an existing mysql connection created from php-code $conn=mysql_connect('localhost','root','secret'); in an php-extensions, e.g. by giving the ressource id to the extension as an argument: my_extemsion_function('do_something',$conn); ? because if i have to connect to the mysql server again from my extension, i'll lose the performance-improvement gained from the faster C++-code. -- Adrian mailto:[EMAIL PROTECTED] www: http://www.planetcoding.net www: http://www.webskyline.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session for creating a unique shopping cart for each user
Have you already sent anything to the browser? Once the first echo has been performed, you can't send header information, as the header is sent with the first bit of text. On Friday, Oct 31, 2003, at 15:47 Europe/Amsterdam, Tore E. Mackay wrote: Hi, I am creating a shopping cart but experiensing some difficulty in creating unique shopping carts for each user. When I try to create a session I get this error message: Warning: session_start(): Cannot send session cookie - headers already sent This is the code: if(isset($_COOKIE["cartId"])) { return $_COOKIE["cartId"]; } else { session_start(); session_register("cartId", session_id(), time() + ((3600 * 24) * 30)); return session_id(); } If I remove the session_start() and session_register it works fine, but then everyone uses the same cart and that can't be good. Thanx!!! Regards Tore -- 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] Session for creating a unique shopping cart for each user
Do you see any information in your browser before the error appears? Perhaps you could also do a view source from the browser to see if anything has been sent out. On Friday, Oct 31, 2003, at 16:06 Europe/Amsterdam, Tore E. Mackay wrote: Don't realy know. Here is what I have: 1. An index.php that inculdes products.php if $file=products.php. 2. products.php includes db.php that contains databse connection and the code for creating a session. 3. When I click "add product" $file=cart.php and cart.php includes the db.php file that should connect me to the db and check if there is a session. It works fine if I go passed the index.php file. Maybe it is because the index.php file has echoed information. Any idea Tore "Gareth Williams" <[EMAIL PROTECTED]> skrev i melding news:[EMAIL PROTECTED] Have you already sent anything to the browser? Once the first echo has been performed, you can't send header information, as the header is sent with the first bit of text. On Friday, Oct 31, 2003, at 15:47 Europe/Amsterdam, Tore E. Mackay wrote: Hi, I am creating a shopping cart but experiensing some difficulty in creating unique shopping carts for each user. When I try to create a session I get this error message: Warning: session_start(): Cannot send session cookie - headers already sent This is the code: if(isset($_COOKIE["cartId"])) { return $_COOKIE["cartId"]; } else { session_start(); session_register("cartId", session_id(), time() + ((3600 * 24) * 30)); return session_id(); } If I remove the session_start() and session_register it works fine, but then everyone uses the same cart and that can't be good. Thanx!!! Regards Tore -- 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] Moving to php
hi there, I suppose that technically PHP is built to run on Linux, but does work on many other platforms. I do all of my development on OS X and have never had any problems, I've also had it running on Linux and FreeBSD without any trouble. I think there is no problem with Win2000, but I don't use that, so I can't give you a definitive answer there. From what I've read about the move from 4 to 5 backwards compatibility will not be a problem. MySQL works fine with PHP, as does PostgreSQL, and loads of other databases. cheers, Gareth On 16 Nov 2003, at 14:21, Jim Van Heule wrote: I'm seriously considering moving to php from a competing 3rd party application. I have a few basic questions. 1. What is the predominate OS platform php runs on? Recommended? 2. I'm currently well versed in Win 2000 & OS X. Are both "Well" supported? 3. When php comes out with a new major version (i.e. php 4 -> 5), how backward compatible is it? Basically, will I need to do a lot of recoding each time there is a new version in order to upgrade? (This is the biggy.) 4. We are currently standardized on MySQL. I'm assuming MySQL is the database of choice or am I wrong? -- Jim -- 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] submission before
I think you'll find that this is more of a Javascript problem than a PHP one. On 13 Oct 2004, at 12:11, Bruno Santos wrote: hello all. I've a question that i might think is not much related with PHP, even the pages are PHP and everything is working with PHP. I've a FORM in my site to be written by the user, but, i need to know before the value of a field to fill another field in the form depending with the value of the previous field. i could put just the field i need filed and then, the user submit the value and i can after that fill the next field becase of the information from the previous field. example: FIELD 1: some text - the user press enter, and the next field is filled regarding the information from these field. how can i accomplish this ?? FIELD 2: Another FIELD: submit button cheers -- [EMAIL PROTECTED] -- Divisao de Informatica [EMAIL PROTECTED] Tel: +351 272 000 155 Fax: +351 272 000 257 -- Hospital Amato Lusitano Av. Pedro Alvares Cabral 6000-085 Castelo Branco [EMAIL PROTECTED] Tel: +351 272 000 272 Fax: +351 272 000 257 -- 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] How to optimize select of random record in DB ?
What about in MySQL: SELECT personID from persons ORDER BY RAND(NOW()) LIMIT 1 If the table is large, then the following might be better: LOCK TABLES foo READ; SELECT FLOOR(RAND() * COUNT(*)) AS rand_row FROM foo; SELECT * FROM foo LIMIT $rand_row, 1; UNLOCK TABLES; There's a whole discussion on it in the MySQL documentation web site: http://dev.mysql.com/doc/mysql/en/SELECT.html On 15 Oct 2004, at 07:41, -{ Rene Brehmer }- wrote: I made this code to pick a random record from a changeable number of records in a given table. I'm just curious if any of the more awake coders out there can see a way to optimize this for better performance, since there's several other DB queries on the same page. $records = mysql_query("SELECT COUNT(*) AS count FROM persons") or die('Unable to get record count'.mysql_error()); $totalcount = mysql_result($records,0) - 1; $rndrecord = rand(0,$totalcount); $personquery = mysql_query("SELECT personID FROM persons LIMIT $rndrecord,1") or die('Unable to get random record'.mysql_error()); $personID = mysql_result($personquery,0); -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expression for a UK Mobile
Do you even need a regex? What about if (strlen($_POST['mobile_number']) != 11 && substr($_POST['mobile_number'],0,3) != 447) { $error="Invalid Number"; } On 15 Oct 2004, at 13:38, Shaun wrote: Hi, Could anyone help me with a reugular expression for a UK mobile phone number? So far I have tried this but with no success $regexp = "/^447[0-9]{9}$/"; if(!preg_match( $regexp, $_POST[mobile_number] )){ $error = "Invalid Mobile Number"; The number nust be 11 numbers long, be all numbers, have no spaces and begin with 447. Any help would be greatly appreciated... -- 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] Regular Expression for a UK Mobile
You could add is_integer() into the if statement. On 15 Oct 2004, at 14:07, Robert Cummings wrote: On Fri, 2004-10-15 at 07:45, Gareth Williams wrote: Do you even need a regex? What about if (strlen($_POST['mobile_number']) != 11 && substr($_POST['mobile_number'],0,3) != 447) { $error="Invalid Number"; } This doesn't verify that the portion following 447 is also a number. eg. 4474567X901 Cheers, Rob. -- .. | 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] splitting string into array
Try something like this: $string = 'A12B05C45D34'; $string = chunk_split($string, 3, ':'); //Should give you 'A12:B05:C45:D34'; $array = explode(":",$string); Cheers, Gareth On 29 Sep 2004, at 15:40, blackwater dev wrote: How can I take a string and create an array? Example, A12B05C45D34 I need to split this into chunks of three A12,B05,C45..etc? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Two people working on the same app / script?
There's a simple one abbreviation answer CVS. It's probably the widest used version control system in the world, and is integrated into XCode (if you are a Mac PHP developer). On 30 Sep 2004, at 10:24, Dave Carrera wrote: Hi List, Is there a simple solution for two or more people to work on the same php app /script without it turning into a mess of many tar / zip files with contributed additions. I want to keep it all in house, I have my own publicly available web server if that helps, so none of the online dev options are useful for us. If any of you good people have ideas or solution urls or pages for reading could you please let me know. I thank you fully in advance for any help with this Dave Carrera -- UK Web Hosting @ http://www.ephgroup.com --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004 -- 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] Replace or regex?
Well, if you can do it without a regex, then it's always best, because the regex engine slows things down. On 30 Sep 2004, at 10:39, mario wrote: Hi all I have a string: ##CODE## and I want to replace that with CODE can u help? -- 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] refresh page automaticly on PHP
Try header(); On 30 Sep 2004, at 14:09, welly limston wrote: how to make my page refresh automaticly? Can i use PHP function? what is it? - Do you Yahoo!? vote.yahoo.com - Register online to vote today! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stored procedures in Mysql
Not Really. On 30 Sep 2004, at 21:50, Sagar C Nannapaneni wrote: Hi folks, I wonder whether Mysql supports procedures and triggers :? /sagar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stored procedures in Mysql
Well, if you are running you own server at home, or have a dedicated server, you can install your own MySQL server, and use version 5, which has all this, but if you have a shared space, then you are probably running version 4.whatever, and don't have them. That's why I said not really, instead of a definite 'NO'. On 30 Sep 2004, at 23:54, Ed Lazor wrote: -Original Message- Not Really. Are you sure? http://dev.mysql.com/doc/mysql/en/Stored_Procedures.html On 30 Sep 2004, at 21:50, Sagar C Nannapaneni wrote: Hi folks, I wonder whether Mysql supports procedures and triggers :? /sagar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] general research question (maybe a little OT, sorry)
Oh please. Not even as a joke. On 7 Oct 2004, at 21:07, Matt M. wrote: My boss recently called PHP "good for hobbyists" but REAL sites have to be done with Microsoft technologies. He wants to use Sharepoint for a wiki type site because of versioning. :) real sites use iis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array concatenation behaviour change
Can't you sort the array? On 8 Oct 2004, at 10:41, rich gray wrote: Just a heads up on this change in array concatenation behaviour that could cause a few probs for some people... 'Zero'); $arr2 = array(1 => 'One',2 => 'Two'); $arr2 = $arr1 + $arr2; echo phpversion().''; print_r($arr2); ?> this code produces on our provider's server... 4.2.3 Array ( [0] => Zero [1] => One [2] => Two ) and on my development server... 4.3.8 Array ( [1] => One [2] => Two [0] => Zero ) hth rich -- 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] Simply open an URL
header("Location: <>"); On 9 Oct 2004, at 20:21, Armands Pucs wrote: Hi everyone! Sorry for the probably stupid question. But I can`t find a way to make a php script to open an url in a browser! Like " location = "example.html"; " does. Armand from Latvia -- 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: [users@httpd] Favorite Linux Distribution
I would agree with the Mandrake recommendation. I first installed it a few years back, to help me get started in the Linux/Unix world, and had very little trouble with it. It's hardware recognition has always been very impressive. Since first installing Mandrake, I have often thought I should 'grow up' and try a more serious distribution, but I always end up coming back. Being Mandrake, it's as easy as you want to configure stuff, and being Linux, it's also as hard as you want. I've rarely had dependency problems, but then I don't really go in for exotic configurations. On 8 Feb 2005, at 08:21, [EMAIL PROTECTED] wrote: Pretty difficult question as it's a question of taste :-) If your are new to linux and want to keep your windows (dual-boot), Mandrake would be my advice: in a class with users without experience of linux, they all have been able to install Mandrake (10.1) dual booting windows without a problem in -/+ 2 hours. I also have it on my laptop since 2/3 years now and it works pretty well Fedora Core is really nice, but if I'm not wrong, there is no possibility in the graphical installation to redimension your windows partition (by the way always do a backup and a defrag before) gaƫl The Disguised Jedi <[EMAIL PROTECTED]> wrote on 08/02/2005 00.25.28: Hello all - I've been a list member for a while, helped out some people, and asked some questions. But, today I have a completely off topic, but somewhat relevant question for y'all. What is your favorite Linux distribution? What would you recommend for my situation? I'm brand new to Linux. I'm just trying to learn how it works, but I think I'll catch on quick. I'm looking for the one with the most capability, and also one to run my development instance of Apache 2.0 on. I've been looking at either RedHat or Fedora. Is this a good choice? I'm truly drawing a blank, and I've searched Google, but never really found anything extremely useful. Please help me, an old Windows veteran, escape the Microsoft box! Thanks a ton!! -- The Disguised Jedi [EMAIL PROTECTED] PHP rocks! "Knowledge is Power. Power Corrupts. Go to school, become evil" Disclaimer: Any disclaimer attached to this message may be ignored. This message is Certified Virus Free - The official User-To-User support forum of the Apache HTTP Server Project. See http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: [EMAIL PROTECTED] " from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [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
Re: [PHP] [NEWBIE] Trying to combine array into one string
Use implode: http://nl2.php.net/manual/en/function.implode.php On 15 Feb 2005, at 16:37, Dave wrote: PHP General, The Situation: I'm retrieving some email addresses from a database. I want to be able assemble all the addresses into one string that I can use in the mail() command. At no time should there ever be more than about 5 email addresses collected from the database. I want all addresses to appear in the "To:" field so everyone receiving the email will know who else has a copy. The Problem: I can't quite figure out how to take the results of the mysql_query() and assemble them into a string. In my experiments so far, I either get a "mysql_data_seek(): Offset 0 is invalid for MySQL result index" error, or my mail function sends to a blank address. What I've Tried So Far: My own code is obviously flawed in syntax in logic, so I searched the manual and this list's archives under the terms "array", "concatenate", "convert", "append" and "string" in various combinations. However, while I learned some interesting tips on a variety of topics, I suspect I'm missing some essential description that will lead me to the command I need. The Question: How do I take the contents of an array and turn them into a single string? For Reference: Here is the code I have. I know it's flawed, but hopefully it will give an indication of what I'm trying to achieve: --code-- $tantoQuery = "SELECT forum_members.emailAddress AS email FROM forum_members, event_tanto WHERE forum_members.ID_MEMBER = event_tanto.tanto AND event_tanto.event ='" . $show . "'"; $tantoResult = mysql_query($tantoQuery); while ($tantoData = mysql_fetch_array($tantoResult)) { $tantoEmail = $tantoEmail . "," . $tantoData; } mail($tantoEmail, $subject, $mailcontent, $addHeaders); --code-- Any help would be much appreciated. -- Dave Gutteridge [EMAIL PROTECTED] Tokyo Comedy Store http://www.tokyocomedy.com/english/ -- 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] Improving a MySQL Search
Create some indexes. I spend most of my day messing around with a table of 200 records, and indexes increased the speed from 40 seconds to 55 minutes for a query, down to the longest being less than 5 seconds. On 28 Feb 2005, at 16:42, James Nunnerley wrote: I'm creating a serious of pages that show various aspects from a Syslog output. The main information is currently stored in one MySQL table - which after having been run for about 2 and a bit months has got nearly 100 records. With this amount of information, it's taking a large time to carryout even the simplest query. Someone has suggested I look at setting up an archive, for slower searches, and a more recent table for quicker searching, but I'm reluctant to do this, as it would take quite a bit of time to copy all the information across as it stands, and then also to run a cron which transfers between the live and archive. Can anyone suggest some quick easy methods for speeding up the search? Cheers James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preventing data from being reposted?
Wouldn't using GET instead of POST help? Gareth Williams venditor.com Buy cool stuff online at http://www.venditor.com";>venditor.com On 3 Mar 2005, at 14:20, Jochem Maas wrote: rory walsh wrote: Thanks Eoghan, I have tried the following but it still reposts the data from the form and goes back a page? header("Cache-control: private"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); Am I write in assuming that the above headers should prevent the user from going back in the first place as no cache has been taken? no - just that if they do then the page will have to be reloaded (under std conditions the user then gets the 'Are you sure you want to repost?' kind of message) before asking anything more on this topic, look up a thread on this lists archive entitled 'Clear POST variables on page refresh' this should give you headsup on the issues + a good suggestion by Richard Lynch on how to handle this (his idea uses md5 hashes to 'auth' specific POST actions, when the POST occurs the given hash is invalidated... read original thread for full info) Eoghan wrote: you can use header() http://ie.php.net/header rory walsh wrote: Is there anyway I can prevent data from being reposted when I hit the back button on my browser? When I hit back I get a message from my browser asking do I want to repost the data, can I prevent this window from appearing? -- 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] Problem with number_format
Hi there, Try using: round($number, 2); cheers, Gareth On 25 May 2004, at 16:00, [EMAIL PROTECTED] wrote: Hi, please suppose PHP 4.3.2 and $number=502,3550 number_format($number,2,'.',' ') returns 502.36. It seems ok, but if $number=253,0650 number_format($number,2,'.',' ') returns 253.06 instead of 253.07. Why? I've noticed this non-coherent approximation behaviour when 3rd decimal number is 5 and decimals are two many many times. It's a my error or should be a bug? Thanks, ciao Francesco --- Spazio ILLIMITATO per la tua Email, Scanner Antivirus, Antispam, Backup e POP3. Prova la nuova Email di superEva: http://webmail.supereva.it/ --- -- 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] Class rules
Hi there, Try include_once(), it's much safer Cheers, Gareth On 17 Feb 2004, at 23:02, Alex Hogan wrote: Hi All, What are the rules of thumb for classes and included files? Can I not include a file in a class function? If I put the include() outside the class structure everything works fine, but when I put it inside the class it freaks. Am I doing something wrong? Class myclass{ Include('myfile'); -- doesn't work Funciton myfunc($var1, $var2){ Include('myfile'); -- doesn't work } } But, include('myfile'); -- works Class myclass{ Funciton myfunc($var1, $var2){ . } } Why? alex hogan ** The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paginate any query
Hi, In your mysql query, use the LIMIT keyword at or near to the end of the query. LIMIT 1000 will limit to the first thousand records LIMIT 2000,1000 will retrieve 1000 records, offset by 2000 records. Cheers, Gareth On 17 Feb 2004, at 22:12, Shaun wrote: Hi, I use the following function to display any query i send to it. Some of these queries produce 1000's of rows and produce an internal server error, is there a way to paginate any query sent to it - say 1000 rows per page? Thanks for your help // query functions function doQuery($query){ if(!($result = mysql_query(stripslashes($query{ echo ''.mysql_error().''; exit; } else { $num_fields = mysql_num_fields($result); $num_rows = mysql_num_rows($result); if ($num_fields > 0 && $num_rows > 0){ echo ' bordercolor="#FF"> '; for($i = 0; $i < mysql_num_fields($result); $i++){ echo ' align="center">'.mysql_field_name($result, $i).''; } for($i = 0; $i < mysql_num_rows($result); $i++){ echo ''; $row_array = mysql_fetch_row($result); for($j = 0; $j < mysql_num_fields($result); $j++){ echo ''.$row_array[$j].''; } echo ''; } echo ''; } else { echo 'No data in table'; } } } -- 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] Finding orphan functions
Well if you are a unix/linux/os x user, drop to the command line, go to the directory with all the php files, and type in: grep php or if your php files are scattered around a load of sub-directories, then go to a directory which sits above all your php files, and type in: grep -r * if your function is only declared and not used, you will only get one line back (plus a line for each comment line which might have the function name in it. On 18 Feb 2004, at 15:58, Al wrote: Anyone have a suggestion for how I can determine if I have any orphan functions in a function file? I have a include file with about 30 functions that I have been adding to for several months. No doubt some have been superseded, etc. and are now obsolete. I could laboriously trace every path in my code and find the orphans; but, it would be nice to be able to automate the job a bit. Is there a neat way to run my applications and record which functions are used? Thanks -- 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] Finding orphan functions
No probs. On 18 Feb 2004, at 16:34, pete M wrote: Wicked - that's the best tip I've seen for a long time... TA Gareth Williams wrote: Well if you are a unix/linux/os x user, drop to the command line, go to the directory with all the php files, and type in: grep php or if your php files are scattered around a load of sub-directories, then go to a directory which sits above all your php files, and type in: grep -r * if your function is only declared and not used, you will only get one line back (plus a line for each comment line which might have the function name in it. On 18 Feb 2004, at 15:58, Al wrote: Anyone have a suggestion for how I can determine if I have any orphan functions in a function file? I have a include file with about 30 functions that I have been adding to for several months. No doubt some have been superseded, etc. and are now obsolete. I could laboriously trace every path in my code and find the orphans; but, it would be nice to be able to automate the job a bit. Is there a neat way to run my applications and record which functions are used? Thanks -- 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] PHP, Cache Control and Mac IE
Hello Roger, If you find a solution, I would also be interested to to see it. I have tried almost everything to get Mac IE to not use the cache. It just doesn't seem to accept anything. On 18 Feb 2004, at 18:58, Roger Spears wrote: Hello List, I am using the following in a PHP script: header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); Most browsers will prompt the visitor to reload the data, but if a visitor is using IE 5.? on a Mac OS X machine, their browser's back button still shows them the original page from cache. At the top of the page, in HTML, I've also added (along with the above headers): and still, the browser pulls from the cache. I'm guessing this is a bug, but I'm wondering if any one has a work around? TIA, Roger -- 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: Image resize on upload
I'll second that one, I wrote a shell script in PHP to resize images, using ImageMagicks mogrify command, and it took ages. It's really much too slow for a web site. If you need a faster solution, I think you have to buy something. On 26 Feb 2004, at 09:15, Adam Bregenzer wrote: On Thu, 2004-02-26 at 02:25, Will wrote: I forgot to mention what I was trying to do. There is a web page that pulls the image file name from the database then reads the URL to the directory where the image is. Is it possible to just resize it when the web page is brought up in the browser? I use ImageMagick's[1] convert[2] to do this. It is not a PHP module and must be run through exec[3]. Also, in my experience image manipulation is rather time consuming, it is a good idea to cache altered images so they do not have to be recreated on every page load. [1] http://www.imagemagick.org/ [2] http://www.imagemagick.org/www/convert.html [3] http://www.php.net/exec -- Adam Bregenzer [EMAIL PROTECTED] http://adam.bregenzer.net/ -- 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] How to get the auto-incremented value?
The function mysql_insert_id() will return the correct value. On 26 Feb 2004, at 17:10, Brian Dunning wrote: When I write a record to a MySQL db with an auto-incremented key column, say it's called "id", what's the easy to retrieve that value? Do I have to run a query? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Passing the value of a variable from PHP to JavaScript.
Try this: function tes(selCtrl){ document.write('JavaScript'); window.location.replace('http://192.168.23.1/coba/coba.php? vtes='+selCtrl.value); } or this: function tes(){ selCtrl = document.getElementById('vtes'); document.write('JavaScript'); window.location.replace('http://192.168.23.1/coba/coba.php? vtes='+selCtrl.value); } On 27 Feb 2004, at 10:00, Prabu Subroto wrote: Dear my friends... I have my code like this : == echo "
function tes(){
document.write('JavaScript
');
window.location.replace('http://192.168.23.1/coba/coba.php? vtes=$vtes');
} "; echo "diforward ke javascript"; echo " 1 2 "; ?> == I expect this result on url column of my internet browser: " http://192.168.23.1/coba/coba.php?vtes='1' " or " http://192.168.23.1/coba/coba.php?vtes='1' " But I only get this unexpected result: " http://192.168.23.1/coba/coba.php?vtes= " Lookslike the value of "$vtes" was not passed to JavaScript interpreter. Anybody of you have a solution for me? Please teach me. Thank you very much. -- _ Web-based SMS services available at http://www.operamail.com. From your mailbox to local or overseas cell phones. Powered by Outblaze -- 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 OOP or Not 2 OOP
I had programmed for years in OO, and when I learned PHP, it only seemed natural to stay with it. I personally find the OO functionality in PHP to be not quite complete, but good enough for daily use. In fact, I don't write any sites in a non-oo manner. I love it. On 28 Feb 2004, at 22:58, Monty wrote: I've decided it's time to learn how to program using PHP's OOP. But, I just found this article which is giving me second thoughts... http://www.zend.com/zend/art/mistake1.php#Heading13 The article was written in 2000, so, it may not apply now. Is OOP in PHP 4.3 slow and incomplete as the article states? Or is it much better now? I probably won't be moving to PHP 5 in then near future, which apparently has much better OOP support. So, I can't decide if I should just go ahead and start using OOP in PHP 4.3 (as long as it's not slow and klugey) or if I should just wait until I get PHP 5? Anyone have any insight?? - Monty -- 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] OTP: Programming
The easiest language to learn for Windows is Visual Basic. You can get a simple gui app up and running in minutes. On 8 Mar 2004, at 14:40, Jay Blanchard wrote: [snip] I have been working with PHP for a few years now, and I feel very comfortable with it. I am considering branching out into windows application development, and I was wondering what language people would recommend for someone comfortable with PHP. I have heard that PHP can be used in this capacity, would PHP work for me to create applications with a GUI? [/snip] To look at PHP see http://gtk.php.net/, otherwise consider starting down the path to C++ enlightenment. -- 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] Confused with constructors
Try this: class base_object() { function base_object() { echo "I'm the base"; } function base_test() { echo "I'm the base test"; } } class extended_object() extends base_object { function extended_object() { echo "I'm the extend object"; $this->base_object(); } function extended_test() { echo "I'm the extended test"; } } Barring any syntax errors (I wrote this out of my head), this should show you that the base object is being properly constructed. On 19 Nov 2004, at 09:02, Gerald Wharney wrote: I'm trying the example at: http://www.php.net/manual/en/language.oop.constructor.php class A { function A() { echo "I am the constructor of A.\n"; } function B() { echo "I am a regular function named B in class A.\n"; echo "I am not a constructor in A.\n"; } } class B extends A { function C() { echo "I am a regular function.\n"; } } // This will call B() as a constructor. $b = new B; ?> Running this on 4.3.9 both as an apache module and from CLI I get: I am a regular function named B in class A. I am not a constructor in A. This is contrary to what the manual says: "This is fixed in PHP 4 by modifying the rule to: 'A constructor is a function of the same name as the class it is being defined in.'. Thus in PHP 4, the class B would have no constructor function of its own and the constructor of the base class would have been called, printing 'I am the constructor of A.'." Is this an error in the manual? Or a bug in php 4.3.9? Or just me being stupid? -- G W (no bush) ___ ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!
You could try chown user:group, where user and group are those apache runs in. Is this script running on your own machine, or on a web server hosted somewhere? On 1 Dec 2004, at 09:03, Michael Leung wrote: Hi all, I am still solving my upload script problems. Here is the error Msg: "Warning: copy(/var/www/html/upload_files/Default.bk1) [function.copy]: failed to open stream: Permission denied in /var/www/html/simple_upload.php on line 77" My Upload Code: $result = move_uploaded_file($temp_name, $file_path); I started to think this is not only PHP , may be Apache problem too. Anyone has some ideas? I have tried to set my upload directory into 777. Even I tried to use sudo , giving apache as root permission and running system command copy the file from the tmp directory to upload_files. but still no success!! I have done some research on web, no one can suggest a solution rather than chmod 777( I did that!) yours, michael -- 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] Software patents
No On 1 Dec 2004, at 15:37, abrea wrote: Will the adoption and legalization of software patents actually threaten the activity of PHP software developers? I see some people quite worried about this, e.g. at http://www.knoppix.org and http://swpat.ffii.org/index.en.html Alberto Brea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Magic Quotes Issue
Try $string = mysql_real_escape_string($string); On 7 Dec 2004, at 14:12, Shaun wrote: Hi, I have been investigating the problem of apostrphes in a mysql insert / update. I use a db_query function for all my queries: function db_query($query) { $qid = mysql_query($query); return $qid; } It appears after some research that the best way around the problem is to check whether magic_qoutes_gpc is off and if so use addslashes(). I have altered the function to this: function db_query($query) { if(!magic_quotes_gpc()){ $qid = mysql_query(addslashes($query)); } else { $qid = mysql_query($query); } return $qid; } But this adds too many slashes! Has anyone come to a better solution regarding this? Thanks -- 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] For Loop
What happens is (if I understand it correctly): First, PHP sets $i to equal 0, and then immediately sets $i to $months_arr_length. Every time the loop executes, it resets $1 to $months_arr_length, so you are stuck in an infinite loop. The reason behind this is you are using assignment equals (=) instead of comparison equals(==). It's a mistake I've made myself quite a few times. As an aside, a neater way of using a for loop on an array is the following: foreach ($months_arr as $key => $value) { echo $value.""; } On 8 Dec 2004, at 22:41, R. Van Tassel wrote: I have a question about the following code: ** $months_arr = array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"); $months_arr_length = count($months_arr); for($i = 0; $i = $months_arr_length; $i++){ echo $months_arr[1]." "; } *** When I run the code above it continues and never stops. According to the PHP documentation the second condition works as follows: "In the beginning of each iteration, expr2 is evaluated. If it evaluates to TRUE, the loop continues and the nested statement(s) are executed. If it evaluates to FALSE, the execution of the loop ends." In the first iteration of the loop $i would equal 0 and the array length is 12. 12 is consistent. To it seems that the loop should STOP when the counter reaches 12, equal to the length of the array. Why is it continuing in a neverending loop? What am I missing? Changing the condition of the for loop to $i <= $months_arr_length; fixes everything and it works properly. Can someone please explain where my confusion is? Thanks, ~R. Van Tassel -- 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] PHP vs JSP?
Because you prefer it? Seriously, you should choose what you are most happy with. Both work fine, although, PHP rocks! On 11 Dec 2004, at 10:11, Peter Lauri wrote: Best groupmember, Why should I choose PHP instead of JSP/Servlets when it comes to develop a high-traffic site. Assume that the infrastructure for both are set up. It only comes to efficiency (both coding and running)? What are your experience? -- - Best Of Times /Peter Lauri -- 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] Loops
$result = mysql_query("SELECT name, description FROM table"); while ($row = mysql_fetch_assoc($result)) { echo "{$row['name']}$row['description']"; } On 14 Dec 2004, at 16:52, Steve Marquez wrote: Greetings. I am trying to display looped information from a MySQL database in a PHP file. Loop $name (witht a br />) then $description End of loop I would like to loop the multiple variables rather than put all the variables into a single variable with an array. I can not figure out how to do this. I have very little knowledge of PHP but am learning. Let me know if more information is needed. Thank you for any help. -- Steve Marquez [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] header information problem
In the else part, you have the possibility to echo to the screen and later on, then header("Location: ..."); This is the bit which isn't allowed. If you are doing header("Location: ...");, you are not allowed to echo before it. On 18 Dec 2004, at 11:52, Ahmed Abdel-Aliem wrote: Dear Groups members. i am making a user protected page, the script works excellent on my local server, but online it gives me this error : Warning: Cannot modify header information - headers already sent by (output started at /home/me2resh/public_html/apex/upload/header.html:10) in /home/me2resh/public_html/apex/upload/upload.php on line 33 the script of the page is You Got To This Page By Mistake"; include 'footer.html'; }else{ session_start(); include 'db.php'; include 'header.html'; $username = $_POST['username']; $password = $_POST['password']; if((!$username) || (!$password)){ echo "Please enter ALL of the information! "; include 'login_form.html'; include 'footer.html'; exit(); } $sql = mysql_query("SELECT * FROM user WHERE User_Login='$username' AND User_Password='$password'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ session_register('ID'); $_SESSION['ID'] = $ID; while($row = mysql_fetch_array($sql)){ foreach( $row AS $key => $val ){ $$key = stripslashes( $val ); } session_register('User_First_Name'); $_SESSION['User_First_Name'] = $User_First_Name; session_register('User_Last_Name'); $_SESSION['User_Last_Name'] = $User_Last_Name; session_register('User_ID'); $_SESSION['User_ID'] = $User_ID; header("Location: login_success.php"); } }else{ include 'header.html'; echo "You could not be logged in! Either the username and password do not match! Please try again!"; include 'login_form.html'; include 'footer.html'; } } ?> Can anyone help me with that problem please ? -- Ahmed Abdel-Aliem www.ApexScript.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php