[PHP] Re: OOP Hello World
Me... again, still boring you to death with meaningless OOP rantings. First I would like to point out that there was a design mistake in what I proposed in the last mail (following afterwards): the Saluter shouldn't be an abstract class, it isn't correct to base your class hierarchy on the ability to greet (or in the ability to do something generally speaking). If it's done that way we'll have classes coexisting in the same branch of the class tree, but possibly having completely different nature. Saluter should be an interface: interface class Saluter { public function greet(Salutable $receiver); } class FormalSaluter implements Saluter { public function greet(Salutable $receiver) { echo Hello . $receiver-getSalutationName() . \n; } } Then, I'll try to translate what has been said in the spanish list. It has been proposed that World should be a singleton, since there is only one world... but this arguable, at metaphysic level perhaps... Also an observer pattern could be used so anyone can hear the greetings. But I think this should be done on the design of the greeting enviroment abstraction (to provide other places than standard output where the greeting can be said). The saluters factory should use a factory method pattern or an abstract factory pattern? I think an abstract factory is not appropiate in this case, the creation process is not that complex to require this kind of design pattern. Also I proposed that decorators could be used to add styles to the greeting for outputs that allow styling (e.g.:html). In this case maybe an abstract factory would be appropiate, so that decorated saluters are created for the appropiate type of output, combined with a builder pattern to create the decorated saluters (this last part I thought it just now, I'll post it later on the spanish list) Well, I think that sums it all up. 2006/9/29, Martin Alterisio [EMAIL PROTECTED]: What's up folks? I just wanted to tell you about a thread that's going on in the spanish php mailing list. A fellow software developer which had just started with OOP was asking for Hello World examples using OOP. The examples of code he had been doing was not that different from the usual Hello World example we all know and love(?), so I thought he was missing the point of what was the purpose of using OOP. This was my reply (I'll try to keep the translation as accurate as possible): I believe you have misunderstood what is the purpose of OOP, your objects are not proper abstractions. First and most important, you should define what is the problem to solve: greet the world. We build an abstraction of the problem and its main components: somebody who greets and something to greet. Here we're working with generalizations, since our main objective is to build reusable objects. For that purpose is useful that our saluter could be used to greet more than just the world. Therefore we'll first define what kind of interaction we expect the salutation receivers to have, in the following interface: interface Salutable { public function getSalutationName(); } In this interface we have all we need to properly greet any entity: the name we should use when doing the salutation. Then we create the object which represents the world: class World implements Salutable { public function getSalutationName() { return World; } } Now we're missing a saluter, but we're not sure which way of greeting would be appropiate, so we prefer to create an abstract saluter and leave the child implementation to decide the appropiate greeting: abstract class Saluter { abstract public function greet(Salutable $receiver); } In our case we need a formal saluter as we should not disrespect the world (saying hey! wazzup world? could be offensive), then: class FormalSaluter extends Saluter { public function greet(Salutable $receiver) { echo Hello . $receiver-getSalutationName() . \n; } } Finally we make our saluter greet the world: $saluter = new FormalSaluter(); $world = new World(); $saluter-greet($world); Other things you should keep in mind: * PHP's type hinting is preety limited, in this case we would like to indicate that the name should be provided as a string but we can't. Maybe it would be useful to use an object as a wrapper for native strings. EDIT: I remembered while translating this that type hinting can only be used in function parameters, therefore this point is useless. * En this model it seems more appropiate that the saluter is an abstract class, since salutation works one way, but, in the event salutations became a two way trip, an interface would be more appropiate for the saluters. * Here we're sending the salutation to the standard output, which is acceptable in this case, but a more complex abstration would require us to indicate where we should procede with the salutation, and we will have to provide an abstraction for the possible salutation
Re: [PHP] Re: OOP Hello World
Double-checking. Nope. It wasn´t from the Java mailing list, they're still talking about hibernate... they'll probably give a damn about this thing anyway, because they're all oop gurus, what would they care about a hello world? PHP seems to be getting more and more object oriented, I think it's the right time to start questioning what have been done so far in terms of OOP in PHP, because, honestly, there are too many php classes being distributed out there that are a complete mess. Forget about spaghethi code, we have to deal with pizza classes too. 2006/10/5, John Wells [EMAIL PROTECTED]: Are you sure you're not on a Spanish *Java* mailing list? :) On 10/5/06, Martin Alterisio [EMAIL PROTECTED] wrote: Me... again, still boring you to death with meaningless OOP rantings. First I would like to point out that there was a design mistake in what I proposed in the last mail (following afterwards): the Saluter shouldn't be an abstract class, it isn't correct to base your class hierarchy on the ability to greet (or in the ability to do something generally speaking). If it's done that way we'll have classes coexisting in the same branch of the class tree, but possibly having completely different nature. Saluter should be an interface: interface class Saluter { public function greet(Salutable $receiver); } class FormalSaluter implements Saluter { public function greet(Salutable $receiver) { echo Hello . $receiver-getSalutationName() . \n; } } Then, I'll try to translate what has been said in the spanish list. It has been proposed that World should be a singleton, since there is only one world... but this arguable, at metaphysic level perhaps... Also an observer pattern could be used so anyone can hear the greetings. But I think this should be done on the design of the greeting enviroment abstraction (to provide other places than standard output where the greeting can be said). The saluters factory should use a factory method pattern or an abstract factory pattern? I think an abstract factory is not appropiate in this case, the creation process is not that complex to require this kind of design pattern. Also I proposed that decorators could be used to add styles to the greeting for outputs that allow styling (e.g.:html). In this case maybe an abstract factory would be appropiate, so that decorated saluters are created for the appropiate type of output, combined with a builder pattern to create the decorated saluters (this last part I thought it just now, I'll post it later on the spanish list) Well, I think that sums it all up. 2006/9/29, Martin Alterisio [EMAIL PROTECTED]: What's up folks? I just wanted to tell you about a thread that's going on in the spanish php mailing list. A fellow software developer which had just started with OOP was asking for Hello World examples using OOP. The examples of code he had been doing was not that different from the usual Hello World example we all know and love(?), so I thought he was missing the point of what was the purpose of using OOP. This was my reply (I'll try to keep the translation as accurate as possible): I believe you have misunderstood what is the purpose of OOP, your objects are not proper abstractions. First and most important, you should define what is the problem to solve: greet the world. We build an abstraction of the problem and its main components: somebody who greets and something to greet. Here we're working with generalizations, since our main objective is to build reusable objects. For that purpose is useful that our saluter could be used to greet more than just the world. Therefore we'll first define what kind of interaction we expect the salutation receivers to have, in the following interface: interface Salutable { public function getSalutationName(); } In this interface we have all we need to properly greet any entity: the name we should use when doing the salutation. Then we create the object which represents the world: class World implements Salutable { public function getSalutationName() { return World; } } Now we're missing a saluter, but we're not sure which way of greeting would be appropiate, so we prefer to create an abstract saluter and leave the child implementation to decide the appropiate greeting: abstract class Saluter { abstract public function greet(Salutable $receiver); } In our case we need a formal saluter as we should not disrespect the world (saying hey! wazzup world? could be offensive), then: class FormalSaluter extends Saluter { public function greet(Salutable $receiver) { echo Hello . $receiver-getSalutationName() . \n; } } Finally we make our saluter greet the world: $saluter = new FormalSaluter(); $world = new World(); $saluter-greet($world
Re: [PHP] Help on objects
2006/10/4, Deckard [EMAIL PROTECTED]: Hi, I'm trying to lay my hands on PHP OOP, but it's not easy :( I've read several examples in the web, but cannot transpose to may case. I'm trying to set a class to make SQL inserts in mysql. I have the class: - ?php class dBInsert { // global variables var $first; // constructor function dBInsert($table, $sql) { $this-table = $table; $this-sql = $sql; return(TRUE); } // function that constructs the sql and inserts it into the database function InsertDB($sql) { print($sql); // connect to MySQL $conn-debug=1; $conn = ADONewConnection('mysql'); $conn-PConnect('localhost', 'deckard', 'ble', 'wordlife'); if ($conn-Execute($sql) === false) print 'error inserting: '.$conn-ErrorMsg().'BR'; return (TRUE); } } and the code that calls it: ?php include_once(classes/dBInsert.php); $sql = INSERT INTO wl_admins VALUES ('',2); $dBInsert = new dBInsert('wl_admins', '$sql'); $dBInsert-InsertDB('$sql'); ? but it's not working ? Can anyone give me a hand here ? I've read the manuals, examples, etc. Any help would be appreciated. Best Regards, Deckard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php For database interaction, give PDO a chance: http://php.net/pdo IMO it's cleaner and more efficient than adodb. Then, I believe what you're trying to make is a query builder. I would break down the differente parts of an sql query and create abstractions for each part (some can be reused on different types of queries), then have builder create the queries abstractions from the different parts.
Re: [PHP] Help on objects
2006/10/5, Satyam [EMAIL PROTECTED]: I've seen you already had a good answer on the errors in the code so I won't go on that. As for OOP, the one design error you have is that you are asking for an action, not an object. You want to make SQL inserts, that is your purpose, and that is an action, which is solved by a statement, not by an object. There is no doer. Objects are what even your English teacher would call objects while describing a sentence. You are asking for a verb, you don't have a subject, you don't have an object. Of course you can wrap an action in a class, but that is bad design. Classes will usually have names representing nouns, methods will be verbs, properties adjectives, more or less, that's OOP for English teachers. Satyam You're wrong, partially: an action can be an object and it's not necessarily a bad design, take for example function objects or the program and statements as objects in lisp-like languages. It's acceptable to make a class that works as an abstract representation of an sql query. This kind of classes are used very efficiently in object persistence libraries. What I agree with you is that it's not right that this class works as the insert action and not as a representation of the insert operation.
Re: [PHP] Re: OOP Hello World
2006/10/5, John Wells [EMAIL PROTECTED]: On 10/5/06, Martin Alterisio [EMAIL PROTECTED] wrote: PHP seems to be getting more and more object oriented, I think it's the right time to start questioning what have been done so far in terms of OOP in PHP, because, honestly, there are too many php classes being distributed out there that are a complete mess. Forget about spaghethi code, we have to deal with pizza classes too. [code] require_once('previousEmails.php'); interface Responder { public function respond(Salutable $receiver, $response); public function getResponderName(); } class WiseAssResponder implements Responder { protected $responderName; public function __construct($responderName) { $this-responderName = $responderName; } public function getResponderName() { return $this-responderName; } public function respond(Salutable $receiver, $response) { echo Hi . $receiver-getSalutationName() . . Please read my response below: \n\n; echo $response; echo Kindest Regards,\n . $this-getResponderName(); } } class Martin implements Salutable { public function getSalutationName() { return get_class($this); } } $martin = new Martin(); $johnW = new WiseAssResponder('John W'); $response=HEREDOC Well I'm not going to argue with you that there is plenty of crap code out there. PHP or not. OOP or not. And I'm all for taking OOP in PHP seriously, but I also think it's worth keeping in mind that the real power in PHP is not it's object oriented capabilities, but rather its simplicity and flexibility. And, well, I don't know if your Hello, World example keeps that in mind. I'd rather say that we have different concepts of what is simple and flexible, and both concepts are aceptable. I know that plenty of people on this list want to have a serious conversation about OOP for PHP (should we just start using OOPHP as the new acronym? or maybe POOPH? Or... PHOOP?!? Wait, that's not taking thing seriously...), but I don't think a complex Hello, World made of Saluters, Salutables, factories and abstractions is taking it serious. I think it's exhausting the theory and using various design patterns for the sake of using design patterns... It seems we've differents approaches to what is complex and what is simple (in terms of computer systems). I think being serious about OOP is start thinking even the simplest of problem from an OOP perspective. I just exposed the Hello World as an example, off course it seems like using a nuke to kill a mosquito, but here I'm not thinking about efficiency or efficacy, it's about training the mind into the OOP methodologies and ways of thinking. Like training your body, once the mind sees everything in terms of object abstraction, OOP will be as natural as breathing. The kind of thinking that OOP it's just a *super* feature of a programming language that should be used only for highly complex problems, is what I want to eradicate. OOP doesn't stand neither as a language feature nor as extra capabilities of a language, on the contrary, it takes some freedom away from the programmer. I see OOP as a way of thinking and working, that should be used in the most complex problem and the most simple problem equally. But really all of this comes down to the imutable truth about programming in PHP: there are a *million* ways to skin a cat. When you heard OOP + Hello, World, you thought about people/things greeting each other. When I heard it, I thought about an application outputing a string. The guy who started that particular thread probably thought of something totally different. Who's to say who is right? Off course, no one can say which is the right way to solve a problem, and I will not hide the fact that OOP is just a coder's whim. I'm just inviting you over to this whim, I can assure you that it's a healthy and beneficial whim, it's not just a Java hype. At least it's healthier whim than web2.0. Hey, take my words as mine alone though. Maybe I was the only one that got my joke. It's happened before. Nope, I caught your joke, and I found it amusing. Though every joke hides a truth, as I can explain a hello world in oop laughing and being serious at the same time. HEREDOC; $johnW-respond($martin, $response); exit; [/code]
Re: [PHP] Help on objects
2006/10/5, Satyam [EMAIL PROTECTED]: - Original Message - *From:* Martin Alterisio [EMAIL PROTECTED] *To:* Satyam [EMAIL PROTECTED] *Cc:* Deckard [EMAIL PROTECTED] ; php-general@lists.php.net *Sent:* Thursday, October 05, 2006 3:50 PM *Subject:* Re: [PHP] Help on objects 2006/10/5, Satyam [EMAIL PROTECTED]: I've seen you already had a good answer on the errors in the code so I won't go on that. As for OOP, the one design error you have is that you are asking for an action, not an object. You want to make SQL inserts, that is your purpose, and that is an action, which is solved by a statement, not by an object. There is no doer. Objects are what even your English teacher would call objects while describing a sentence. You are asking for a verb, you don't have a subject, you don't have an object. Of course you can wrap an action in a class, but that is bad design. Classes will usually have names representing nouns, methods will be verbs, properties adjectives, more or less, that's OOP for English teachers. Satyam You're wrong, partially: I am sure you could have stated that in a more courteous way. I apologize, english is not my first language and I usually can't express myself correctly. As a fellow compatriot I hope you'll understand there weren't ill intentions on what I said.
Re: [PHP] OOP slow -- am I an idiot?
On 10 Oct 2006, at 4:14 PM, Chris de Vidal wrote: I think perhaps I'm using classes and OOP incorrectly. The last time I used them, they were slow. I want to create a customer class which fetches its attributes from a MySQL database. Something like this pseudocode: class customer { ... getName ($id) { $result = mysql_query (SELECT name FROM customers WHERE id = '$id'); return mysql_result ($result, 0); } getRevenue ($id,$department,$month,$year) { $result = mysql_query (SELECT revenue FROM customer_revenue WHERE customer_id = '$id' AND department = '$department' AND month = '$month' AND year = '$year'); return mysql_result ($result, 0); } ... } You should look into getting Professional PHP5 by Lecky-Thompson, Eide-Goodman, Nowicki and Cove from WROX. It's a good introduction to using PHP5 with design patterns to solve problems similar to yours. Plus, the knowledge can be applied to other object oriented programming languages, not just PHP5. It's also been out for a while so it may be in the sale section already. The collection class in chapter 5 discusses a programming problem just like yours. Johan Martin Catenare LLC 534 Pacific Ave San Francisco, CA. 94133 http://www.catenare.com http://www.linkedin.com/in/catenare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Imagecopyresampled creates black pictures
Hi! I'm using imagecopyresampled to create thumbnails of various pictures. That works well except some pictures that imagecopyresampled converts to small black thumbnails (although it converts it correctly to a bigger size) What is wrong here? lg Martin (Suse Linux 10.1, Apache 2.2, gd 2.0.32, php 5.1) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Imagecopyresampled creates black pictures
Ed Lazor schrieb: On Oct 30, 2006, at 12:52 AM, Martin Hochreiter wrote: Hi! I'm using imagecopyresampled to create thumbnails of various pictures. That works well except some pictures that imagecopyresampled converts to small black thumbnails (although it converts it correctly to a bigger size) What is wrong here? No idea off-hand, but it would probably help if you you included more information like source code and details about the images that are not working. Hi Ed! I added the upload.php file below and posted the nfs.jpg image file on http://www.rk-lilienfeld.at/nfs.jpg Maybe you can have a look at it . lg - upload.php ?php function resize($image,$name,$dir) { // $height=0 ... quer // $height=1 ... hoch $ori = imagecreatefromjpeg($image); $smaller=0; $x=imagesx($ori); $y=imagesy($ori); echo brx:.$x., y:.$y.br; if(imagesx($ori)imagesy($ori)) { if(imagesx($ori)1024) { $smaller=1; $faktor=imagesy($ori)/imagesx($ori); $thumb = imagecreatetruecolor (150,150*$faktor); // echo brimage: .$image; // echo braktdir: .$dir.view/.$name; if(!copy ($image,$dir.view/.$name)) { imagedestroy($thumb); imagedestroy($ori); die(kopie 1 fehlgeschlagen); } # imagecopyresized ( $thumb, $ori, 0, 0, 0, 0, 150, round(150*$faktor,0), imagesx($ori), imagesy($ori)); imagecopyresampled ( $thumb, $ori, 0, 0, 0, 0, 150, round(150*$faktor,0), $x, $y); } else { $faktor=imagesy($ori)/imagesx($ori); $new= imagecreatetruecolor (1024,1024*$faktor); $thumb = imagecreatetruecolor (150,150*$faktor); # imagecopyresized ( $new, $ori, 0, 0, 0, 0, 1024, round(1024*$faktor,0), imagesx($ori), imagesy($ori)); imagecopyresampled ( $new, $ori, 0, 0, 0, 0, 1024, round(1024*$faktor,0), imagesx($ori), imagesy($ori)); # imagecopyresized ( $thumb, $ori, 0, 0, 0, 0, 150, round(150*$faktor,0), imagesx($ori), imagesy($ori)); imagecopyresampled ( $thumb, $ori, 0, 0, 0, 0, 150, round(150*$faktor,0), imagesx($ori), imagesy($ori)); } } else { if(imagesy($ori)768) { $smaller=1; $faktor=imagesx($ori)/imagesy($ori); $thumb = imagecreatetruecolor (112*$faktor,112); if(!copy ($image,$dir.view/.$name)) { imagedestroy($thumb); imagedestroy($ori); die(kopie 2 fehlgeschlagen); } # imagecopyresized ( $thumb, $ori, 0, 0, 0, 0, round(112*$faktor,0),112, imagesx($ori), imagesy($ori)); imagecopyresampled ( $thumb, $ori, 0, 0, 0, 0, round(112*$faktor,0),112, imagesx($ori), imagesy($ori)); } else { $faktor=imagesx($ori)/imagesy($ori); $new= imagecreatetruecolor (768*$faktor,768); $thumb = imagecreatetruecolor (112*$faktor,112); # imagecopyresized ( $new, $ori, 0, 0, 0, 0, round(768*$faktor,0), 768, imagesx($ori), imagesy($ori)); imagecopyresampled ( $new, $ori, 0, 0, 0, 0, round(768*$faktor,0), 768, imagesx($ori), imagesy($ori)); # imagecopyresized ( $thumb, $ori, 0, 0, 0, 0, round(112*$faktor,0),112, imagesx($ori), imagesy($ori)); imagecopyresampled ( $thumb, $ori, 0, 0, 0, 0, round(112*$faktor,0),112, imagesx($ori), imagesy($ori)); } } imagedestroy($ori); if($smaller==0) { echo 'brAusgabebild: '.$dir.'view/'.$name; imagejpeg($new,$dir.'view/'.$name,85); imagedestroy($new); } echo 'brVorschaubild: '.$dir.'thumb/'.$name; imagejpeg($thumb,$dir.'thumb/'.$name,100); imagedestroy($thumb); } require('connect1.php'); require('inc_query.php'); if(isset($_FILES['userfile']['name'])) { $name=time().'.jpg'; echo brDEBUGINFORMATION:br; echo name:.$name.br; echo tmp name:.$_FILES['userfile']['tmp_name'].br; if(move_uploaded_file($_FILES['userfile']['tmp_name'],'/srv/www/phpup/'.$name)) { resize('/srv/www/phpup/'.$name,$name,'/srv/www/htdocs
Re: [PHP] Imagecopyresampled creates black pictures
tedd schrieb: At 9:52 AM +0100 10/30/06, Martin Hochreiter wrote: What is wrong here? Martin: Damn, that's a lot of code to do something pretty simple. I had no problems uploading and resampling your image with a lot less. Try using ob_start() and ob_end() to grab your image.: ob_start(); imagejpeg($new,$dir.'view/'.$name,85); ob_end_clean(); hth's tedd Damn, that's a lot of code to do something pretty simple ... i am not a php professional - just hacking around to get things run ... Ok, thank you for your code - unfortunately the result is the same (I added the picture as attachement) Maybe php is not responsible for that - should I try another GD library version or image Magik version? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Imagecopyresampled creates black pictures
Tedd, may I ask you what GD library version and php version are you using? I am using: php5-5.1.2 gd-2.0.32-23 All Suse 10.1 machines using that versions and on all that machines I have the same problem ... lg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mac PHP MySQL
On 02 Nov 2006, at 5:11 PM, Ed Lazor wrote: I'm trying to configure and compile PHP 5. The configure is failing to find the MySQL UNIX socket. Any ideas? ./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-zlib \ --with-mysql=/usr/local/mysql \ --with-mysql-socket=/tmp I had a similar problem and downloaded the tar version of the Mac OS X Mysql Server. Pointed --with-mysql= to the libraries and that folder and it worked. Decided to compile my own because the packages always seem to lag behind the released versions of the software. Also need both postgresql and mysql support. Johan Martin Catenare LLC 534 Pacific Ave San Francisco, CA. 94133 Phone: (415) 834-9802 Fax: (415) 294-4495 http://www.catenare.com AOL: catenarellc Yahoo: martin_johan GTalk: [EMAIL PROTECTED] FreeWorldDialup :716798 - http://www.freeworlddialup.com/ Gizmo Project: 747-627-9132 - http://www.gizmoproject.com/ http://www.linkedin.com/in/catenare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fwrite() timeout
Hi, I am using the fsockopen(), fwrite() and fread() functions to get a web page from a remote server. The remote server is currently down and I see the code hangs on the fwrite() call. Is there a way how to set a timeout for the fwrite() remote call? I have found the stream_set_timeout(), but it seems not to be effective on the fwrite(), only on fread(). Thanks, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Microsoft Partners With Zend
On Wed, 01 Nov 2006 23:23:15 +0100, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] I guess that's sorta what I'm afraid of... PHP# (like the did to Java - J++ - C# ) Don't get me wrong. C# is a great language (probably one of the few things that M$ did right), and I'd LOVE to use a real IDE like Visual Studio to dev in... But I'm also terrified they'll pervert PHP. [/snip] Please NO PHP.NET === ACCCKKK The .NET compiler for PHP exists for many years. It was created by students of the Charles University in Prague. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Microsoft Partners With Zend
Jay Blanchard wrote: [snip] I guess that's sorta what I'm afraid of... PHP# (like the did to Java - J++ - C# ) Don't get me wrong. C# is a great language (probably one of the few things that M$ did right), and I'd LOVE to use a real IDE like Visual Studio to dev in... But I'm also terrified they'll pervert PHP. [/snip] Please NO PHP.NET === ACCCKKK The .NET compiler for PHP exists for many years. It is created and managed by students of the Charles University in Prague. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fwrite() timeout
Hi, I am using the fsockopen(), fwrite() and fread() functions to get a web page from a remote server. The remote server is currently down and I see the code hangs on the fwrite() call. Is there a way how to set a timeout for the fwrite() remote call? I have found the stream_set_timeout(), but it seems not to be effective on the fwrite(), only on fread(). Thanks, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems re-reading from socket
I have a daemon class which reads and answers using socket_read and socket_write functions. The things is that I connect to the daemon, sent a chain and the I get an answer, but after that the daemon get's struck in the next socket_read. The problem appears to be here (a method from my class). I put the 2 echos for debugging purposses: function socketRead(){ echo Vamos a leer nomas!\n; $lectura = socket_read($this-conexion, 2048, PHP_NORMAL_READ); echo $lectura; return $lectura; } In th output from the socket daemon I get the 2 strings (generated by the 2 echos), after that I get again the first echo, but no matter how I try to send a new string to the socket, it just stays there reading from the socket. By the way $this-conexion is a socket resource from socket_accept. Also the socket reads and answers one time, so it is working, but after that first answer it stays reading. All this I'm testing from the console using a telnet to the socket. -- - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems re-reading from socket
On Fri, 24 Nov 2006 13:41:59 -0600 (CST), Richard Lynch [EMAIL PROTECTED] wrote: On Fri, November 24, 2006 1:21 pm, Martin Marques wrote: I have a daemon class which reads and answers using socket_read and socket_write functions. The things is that I connect to the daemon, sent a chain and the I get an answer, but after that the daemon get's struck in the next socket_read. Have you set: http://www.php.net/manual/en/function.socket-set-nonblock.php If I set non-blocking, I get endless warnings when trying to accept connexions: Warning: socket_accept(): unable to accept incoming connection [11]: Resource temporarily unavailable in /usr/local/php/offline/lib/daemonSocket.inc on line 100 socket_accept() failed: reason: Success It seems to me that if you don't, you are going to wait for 2048 bytes, no matter how little/much data is there... From the socket_read manual: The function socket_read() reads from the socket resource socket created by the socket_create() or socket_accept() functions. The maximum number of bytes read is specified by the length parameter. Otherwise you can use \r, \n, or \0 to end reading (depending on the type parameter, see below). I'm using PHP_NORMAL_READ BTW. -- - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] EZ array problem - What's wrong with my brain?
2006/11/30, Brian Dunning [EMAIL PROTECTED]: var_dump() gives me this: array(1) { [1.2]= array(2) { [code]= array(1) { [0]= string(3) 111 } [status]= array(1) { [0]= string(3) new } } } I'm trying to set a variable to that 1.2. Shouldn't I be able to get it with $var = $arr[0][0]? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $keys = array_keys($var); var_dump($keys[0]); string(3) 1.2 $values = array_values($var); var_dump($values[0]); array(2) { [code]= array(1) { [0]= string(3) 111 } [status]= array(1) { [0]= string(3) new } }
Re: [PHP] Count empty array
On Thu, 21 Dec 2006, Kevin Murphy wrote: I'm wondering why this is. $data = ; $array = explode(,,$data); $count = count($array); $count will = 1 $array has 1 element: An empty string. $data = Test; $array = explode(,,$data); $count = count($array); $count will = 1 $array has 1 element: The string Test $data = Test,Test; $array = explode(,,$data); $count = count($array); $count will = 2 $array has 2 elements:. Why doesn't the first one give me an answer of 0 instead of 1. I know I could do a IF $data == [empty] and then not count if its empty and just set it to 0, but am wondering if there was a better way. Because explode divides the string in n+1 elements, where n is the amount of , (or your favorite delimiter) found in the string. So if no , is found, explode will return 1 element: the whole string (even if it's empty). -- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Clarification: Jump to a record/PHP paging...
To solve a problem like yours I ussualy do the following: First you need to use a deterministic order criteria when displaying the results, this means that according to the order columns you provide, MySQL will not have to decide how to order two rows that have the same values for this columns. For example, if you order an users table by the first name of the user, there might be two users with the same name, and MySQL will order them the way it founds more convenient. One way to do this is using an uniquely indexed column in the order criteria. The primary key would be a nice idea. You don't need to enforce an order criteria to the listing, you can simply add the primary key as the last column in the order by and that will be enough. Then, look for the record you need and store the values it has for the columns used in the order. With that info you can build a query which will return how many records there are, in the listing, before the one you sought before: SELECT COUNT(*) FROM table WHERE order_column1 'order_column1_value' OR (order_column1 = 'order_column1_value' AND order_column2 'order_column2_value') OR (order_column1 = 'order_column1_value' AND order_column2 = 'order_column2_value' AND order_column3 'order_column3_value') ...etc... If the order direction of one column is descending instead of ascending, you should use instead of for that specific column. If you're worried about performance you should add indexes to the columns of the order criteria, which you probably have done so anyway. Also you should consider splitting this query in many queries: SELECT COUNT(*) FROM table WHERE order_column1 'order_column1_value' SELECT COUNT(*) FROM table WHERE order_column1 = 'order_column1_value' AND order_column2 'order_column2_value' SELECT COUNT(*) FROM table WHERE order_column1 = 'order_column1_value' AND order_column2 = 'order_column2_value' AND order_column3 'order_column3_value' etc... and sum all the results. It seems that sometimes this run faster with a MySQL server, anyway, give it a try if you're worried about the query performance. The result will be the number of records before the one you sought, with that info getting the page of the record is piece of cake. 2006/12/23, T.J. Mahaffey [EMAIL PROTECTED]: I see now that I did not explain myself adequately. I think jump to record was the wrong way to put it. So, here goes. I already have excellent paging functionality working well, based on a nice tutorial at PHPFreaks. My problem is that when a user performs a search, I need to display the page on which their search string is found, but still display ALL records within the paging of the entire database. I've since discovered the core of what I need to do: 1. I can find the record I need through a simple query. 2. I can easily determine WHICH page this record is on by counting BACKWARDS from the found record to the FIRST record, totaling the number of records from record 1 to the found record. Then, by performing a bit of division, I can determine which page that record appears on and direct the user to ...page=8 via $_GET. SO, my question is: how might I have MySQL tell me how many records came BEFORE the found record? (FYI: there is currently no auto-incrementing ID on these records, so that obviously easy solution would be unavailable.) Thanks in advance for any insight. -- T.J. Mahaffey [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Odd behavior
2006/12/25, jekillen [EMAIL PROTECTED]: On Dec 25, 2006, at 7:21 AM, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-12-24 18:11:03 -0800: function display($list, $in, $out, $save, $req, $x) { for($i = 0; $i count($in); $i++) {$j = $i + 1; // two sets of links displayed instead of one for($i = 0; $i count($out); $i++) {$j = $i + 1; // two sets of links displayed instead of one for($i = 0; $i count($save); $i++) {$j = $i + 1; // two sets of links displayed instead of one for($i = 0; $i count($req); $i++) {$j = $i + 1; // two sets of links displayed instead of one The print lines above are supposed to produce a list of links to files. In the web display I get duplicate sets of links which seems to mean that the loops in the function are running twice, and in one instance three times instead of once. Look at the variable names you use for iteration. Thanks, Usually, when a variable name like $i is used and then reset to 0 in the next loop it does not matter. But I solved the problem and posted the solution. I also solved the regex problem. There was an extra \n sneaking into the test pattern so I could not get a match. I am not sure where the extra \n is coming from. It looks like I didn't post the solution after all: Update: I solved the double loops problem with this code change: function display($list, $a, $x) { for($i = 0; $i count($a); $i++) {$j = $i + 1; print a href=\steps.php?list=$listnext=$jx=$x\$j/abrbr\n; }; } and: if($list || $current) { switch($list) { case 'in': display($list, $in, $x); break; case 'out': display($list, $out, $x); break; case 'save': display($list, $save, $x); break; case 'req': display($list, $req, $x); break; } } Apparently what was happening was that the code running under 5.1.2 was trying to process all the arrays that had values in spite of the switch statement in the original display() function. If the was an $in array the switch would process that for the $list value being 'in' but since there was also a save value, the switch tried to process it also, even though 'save' wasn't the $list value. I found it would do this for all arrays that had values. So if three had values the loop selected loop would run three times. Could this be a bonafide bug? JK I suspect this is an EBSAC bug, but I'm not completely sure. Anyway, please consider improving your coding style, its all messy and unreadable. Also, you should provide a description of the calling conditions, since there might be the cause of the error in the function.
Re: [PHP] Clarification: Jump to a record/PHP paging...
2006/12/25, Robert Cummings [EMAIL PROTECTED]: WRONG! See Martin Alterisio's post for the same thread. You must not have understood the OP's requirements. xD I was starting to think my mails weren't getting through the list, maybe its nothing else than only a bigger delay than the usual. Anyway, I kind of lost the topic of your discussion there... if you're so kind to explain in such a way that an idiot like me can understand... And Merry Xmas, Merry hangover or anything else you should desire to celebrate. PS: was my previous post useful to anyone? or did I mess up the explanation? I'm not sure... =S that's why I'm asking...
Re: [PHP] array_intersect problem
2006/12/25, Leo Liu [EMAIL PROTECTED]: Hi, I try to intersect associative array and it seems to fail to do so. Can anyone show me a walk around? For example I have array1 Array ( [0] = Array ( [imageID] = 1 ) [1] = Array ( [imageID] = 2 ) [2] = Array ( [imageID] = 3 ) [3] = Array ( [imageID] = 4 ) ) And array 2 Array ( [0] = Array ( [imageID] = 6 ) [1] = Array ( [imageID] = 3 ) ) After intersection instead of me getting 3 as a result, I got the array 1 unchanged. Seems like intersection doesn't take place at all. Anyway to solve this problem? Regards, Leo Reality starts with Dream Quote from php manual, in the reference for the array_intersect function: *Note: * Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same. That's why array_intersect isn't working with your arrays. If you're using PHP5 you could use array_uintersect, and compare the items by the imageID: function compareByImageID($elem1, $elem2) { return $elem1['imageID'] - $elem2['imageID']; } $intersection = array_uinsersect($array1, $array2, 'compareByImageID'); Or you can do the following, which works in PHP4, but is not as versatile as array_uintersect: class InArrayFilter { var $arr; function InArrayFilter($arr) { $this-arr = $arr; } function filterFunction($elem) { return in_array($elem, $this-arr); } } $filter = new InArrayFilter($array2); $intersection = array_filter($array1, array($filter, 'filterFunction'));
Re: [PHP] Basic question - Starting a background task without waiting for its end.
2006/12/31, Michel [EMAIL PROTECTED]: I (very simply) try to open a notepad on a simple text file in a simplistic PHP script, and would like to go on and display the next page without waiting for this notepad to be shut. After various attempts, I have used an : exec ('bash -c cmd /C start /MAX notepad my_file NUL'); ... but it still wait for the shutting of the notepad ..! Could anybody help me ? For clarification : 1) I use this script on a machine which is in the same time server and client, which gives meaning to this operation. 2) I use bash -c because I have the cygwin platform which can easily initiate tasks in background, but it could be suppressed, because it de facto changes nothing... Thank's for help. Michel. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you tried the following? exec ('bash -c cmd /C start /MAX notepad my_file NUL ');
Re: [PHP] classes and objects: php5. The Basics
Backward compatibility with PHP4, where member functions couldn't be declared as static. Any member function could be called statically providing a static context instead of an object instance. 2007/1/16, Cheseldine, D. L. [EMAIL PROTECTED]: Hi I'm stuck on The Basics page of the php5 Object Model: http://uk.php.net/manual/en/language.oop5.basic.php The top example has the code: A::foo(); even though foo is not declared static in its class. How does it get called statically without being declared static? regards dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] classes and objects: php5. The Basics
Forgot to mention that calling a non-statical function this way should generate an E_STRICT warning. 2007/1/16, Martin Alterisio [EMAIL PROTECTED]: Backward compatibility with PHP4, where member functions couldn't be declared as static. Any member function could be called statically providing a static context instead of an object instance. 2007/1/16, Cheseldine, D. L. [EMAIL PROTECTED]: Hi I'm stuck on The Basics page of the php5 Object Model: http://uk.php.net/manual/en/language.oop5.basic.php The top example has the code: A::foo(); even though foo is not declared static in its class. How does it get called statically without being declared static? regards dave -- PHP General Mailing List ( http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] nuSoap -method '' not defined in service
Try the following: $server-register('getColumns', array(), array()); The second argument is an array containing an entry for each argument of the webservice call, and the third argument is an array for the return value. Since you don't have either arguments nor return value, empty arrays should be provided. Also I think you should call $server-configureWSDL(domain), before registering anything. 2007/1/18, blackwater dev [EMAIL PROTECTED]: I have the following code but when I hit the page, I get the xml error of method '' not defined in service. I don't have a wsdl or anything defined. Is there more I need to do to get the SOAP service set up? Thanks! include(nusoap/nusoap.php); $server=new soap_server(); $server-register('getColumns'); function getColumns(){ $search= new carSearch(); return $search-getSearchColumns(); } $server-service($HTTP_RAW_POST_DATA);
Re: [PHP] preg_match problem
Double slash to prevent PHP interpreting the slashes. Also using single quotes would be a good idea: if (preg_match('/[\\w\\x2F]{6,}/',$a)) 2007/1/19, Németh Zoltán [EMAIL PROTECTED]: Hi all, I have a simple checking like if (preg_match(/[\w\x2F]{6,}/,$a)) as I would like to allow all word characters as mentioned at http://hu2.php.net/manual/hu/reference.pcre.pattern.syntax.php plus the '/' character, and at least 6 characters. But it throws Warning: preg_match(): Unknown modifier ']' and returns false for abc/de/ggg which string should be okay. If I omit the \x2F, everything works fine but / characters are not allowed. Anyone knows what I'm doing wrong? Maybe / characters can not be put in patterns like this? Thanks in advance, Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] CMS-Blog system
Hi, I am working on CMS-Blog system, which will be using approx. 10 000 users. I have a basic question - I believe there are only two options - which one is better? 1) having separate databases for each blog = fast (problem: what if I will need to do search in all of the blogs for some article?) 2) having all blogs in one database - that might be 10 000 * 100 articles = too many rows, but easy to search and maintain, hmm? --- I am thinking of having some file etc. cms-core.php in some base directory and every subdirectory (= users subdomains) would include this cms-core file with some individual settings. Is there better idea? I appreciate your discussion on this topic. Martin Zvarik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] CMS-Blog system
Thank you for all the comments. Thanks for the WP tip: I don't know much about wordpress (it looks good), but I have tryed enough of open-source CMS to say that they are based on messy solutions (one for all = joomla) + it won't be free blog system, so I don't think using this free system would be fair. So, I will stick with separate databases for each user + central databases used for searches etc. I am pretty sure I am up for this wheel reinventing ;-) The only thing I am not strong in is the MySQL, but with you guys there is nothing impossible! Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP tags - any reasons to close ?
Hi, I have seen some projects where people start with opening tag ?php but they DON'T close it with ? This is especially the case of CONFIG.php files... 1) What's the reason of that? 2) What if you would not close any 100% PHP files? 3) What's the reason of making an empty space after ? I've also seen this in some projects. Thanks for ideas, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: searching by tags....
Ryan S napsal(a): Hey, this the first time I am actually working with tags but it seems quite popular and am adding it on a clients requests. By tags I mean something like wordpress' implementation of it, for example when an author writes an article on babies the tags might be baby,babies, new borns, cribs, nappies or a picture of a baby can have the tags baby,babies, new born, cute kid, nappies the tags are comma separated above of course. The way i am doing it right now is i have sa an article or a pic saved in the db as article_or_pic_address text the_tags varchar(240) My question is, when someone clicks on any one of the tags, do i do a LIKE %search_term% search or...??? quite a few sites seem to have a very neat way of implementing this with (url rewriting?) something like http://sitename/blog/tags/tag-comes-here/ Any help in the form of advise, code or links would be appreciated. TIA. Cheers! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) The main point here is WHAT SHOULD BE THE BEST DB STRUCTURE. I got this feeling, from what I've read, that everybody wants to express themselves so much, that they talk about something they know at least a little about = SEO. To the TOPIC: I think normalization would be a killer. Imagine joining 3 tables (I really don't see more functionality here) OR just selecting from 1. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XCache, APC, Memcached... confused
Hi, I became confused after an hour trying to understand the PHP cache solutions. XCache, APC, eAccelerator and others are opcode cache systems... is memcache in the same category? or is it completely different? If I install for example XCache, set it for certain directory... it will automatically cache the website into the memory. What happens if the memory will get full? Thanks for explanation, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XCache, APC, Memcached... confused
I guess the XCache everybody talks about is the open-source here: http://xcache.lighttpd.net/ But what about this: http://www.xcache.com/ ... is it the same author? :-O Martin Zvarík napsal(a): Hi, I became confused after an hour trying to understand the PHP cache solutions. XCache, APC, eAccelerator and others are opcode cache systems... is memcache in the same category? or is it completely different? If I install for example XCache, set it for certain directory... it will automatically cache the website into the memory. What happens if the memory will get full? Thanks for explanation, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ZendOptimizer + APC
Jochem Maas napsal(a): anyone know whether running ZendOptimizer + APC simultaneously still causes allsorts of problems ... I know it did in the past but I can't find any very recent stuff about the issues online. I believe you should look up eAccelerator or XCache, which should work with ZendOptimizer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XCache, APC, Memcached... confused
Thanks for reply Stut. So, the APC, XCache etc. doesn't work as FileCache and also doesn't decrease the number of database queries, since it is not caching the content... I see now, it is obvious that it would be very hard to run out of memory. -- Martin Stut napsal(a): On 22 Oct 2008, at 22:19, Martin Zvarík wrote: I became confused after an hour trying to understand the PHP cache solutions. XCache, APC, eAccelerator and others are opcode cache systems... is memcache in the same category? or is it completely different? Memcache is completely different in that it's not an opcode cache, it's an in-memory volatile cache for arbitrary key = value data with a client-server API. If I install for example XCache, set it for certain directory... it will automatically cache the website into the memory. What happens if the memory will get full? First of all you need to get it clear in your head what an opcode cache is actually doing. It does not cache the website, it caches the compiled version of the PHP scripts such that PHP doesn't need to recompile each file every time it's included which is the default way PHP works. Secondly, if you run out of memory you buy more!! But seriously, you'd need a very very very big site to have this problem. An opcode cache of a PHP script will generally take less space than the script itself. So if you're worried about it simply get the total size of all the PHP scripts in your site and you'll see that even on modest hardware you'll have a lot of headroom. Obviously you need to take other users of the server into account, especially if you're on a shared hosting account, but in most cases you won't have a problem. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XCache, APC, Memcached... confused
I am looking at the eAccelerator's website and I realize what got me confused: there is a function for OUTPUT CACHE, so it actually could cache the whole website and then run out of memory I guess... that means I would be able to store anything into the memory and reference it by a variable? are the variables accessible across the whole server? I still don't really understand, but I am trying... Stut napsal(a): On 22 Oct 2008, at 22:19, Martin Zvarík wrote: I became confused after an hour trying to understand the PHP cache solutions. XCache, APC, eAccelerator and others are opcode cache systems... is memcache in the same category? or is it completely different? Memcache is completely different in that it's not an opcode cache, it's an in-memory volatile cache for arbitrary key = value data with a client-server API. If I install for example XCache, set it for certain directory... it will automatically cache the website into the memory. What happens if the memory will get full? First of all you need to get it clear in your head what an opcode cache is actually doing. It does not cache the website, it caches the compiled version of the PHP scripts such that PHP doesn't need to recompile each file every time it's included which is the default way PHP works. Secondly, if you run out of memory you buy more!! But seriously, you'd need a very very very big site to have this problem. An opcode cache of a PHP script will generally take less space than the script itself. So if you're worried about it simply get the total size of all the PHP scripts in your site and you'll see that even on modest hardware you'll have a lot of headroom. Obviously you need to take other users of the server into account, especially if you're on a shared hosting account, but in most cases you won't have a problem. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamically creating multi-array field
PHP Version 5.2.4 ? $node = '[5][1][]'; ${'tpl'.$node} = 'some text'; print_r($tpl); // null ? I really don't like to use the EVAL function, but do I have choice?? This sucks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamically creating multi-array field
No offense, but I thought it's obvious what I want to print. print_r() shows null, and it should print what you just wrote = array field. It works when first defining with eval(): eval('$tpl'.$node.'=array();'); I guess that's the only way. Anyway, I appreciate your quick reply, Martin Jim Lucas napsal(a): Martin Zvarík wrote: PHP Version 5.2.4 ? $node = '[5][1][]'; ${'tpl'.$node} = 'some text'; print_r($tpl); // null ? I really don't like to use the EVAL function, but do I have choice?? This sucks. You should print the results that you are looking for! Are you looking for something like this? Array ( [5] = Array ( [1] = Array ( [0] = some text ) ) ) how is the $node string being created? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamically creating multi-array field
Nope, you have to use the eval() everytime for read/write. Martin Zvarík napsal(a): No offense, but I thought it's obvious what I want to print. print_r() shows null, and it should print what you just wrote = array field. It works when first defining with eval(): eval('$tpl'.$node.'=array();'); I guess that's the only way. Anyway, I appreciate your quick reply, Martin Jim Lucas napsal(a): Martin Zvarík wrote: PHP Version 5.2.4 ? $node = '[5][1][]'; ${'tpl'.$node} = 'some text'; print_r($tpl); // null ? I really don't like to use the EVAL function, but do I have choice?? This sucks. You should print the results that you are looking for! Are you looking for something like this? Array ( [5] = Array ( [1] = Array ( [0] = some text ) ) ) how is the $node string being created? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamically creating multi-array field
:-D :-D :-D :-D :-D :-D :-D :-D ok :) Robert Cummings napsal(a): On Mon, 2008-10-27 at 02:09 -0400, Robert Cummings wrote: On Sun, 2008-10-26 at 22:39 -0700, Jim Lucas wrote: Even slimmer ?php $node = '[5][1][]'; $text = 'some text'; preg_match_all('|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER); $recursive = $matches[1]; $recursive = array_reverse($recursive); foreach ( $recursive AS $index ) { $out = array(); $out[(int)$index] = $text; $text = $out; } print_r($out); ? It's buggy... you need to test for an blank string to properly handle the append to array case when the index is blank []. ?php $node = '[5][1][]'; $text = 'some text'; preg_match_all( '|\[([^\]\[]*)\]|', $node, $matches, PREG_PATTERN_ORDER ); $recursive = $matches[1]; $recursive = array_reverse($recursive); foreach( $recursive AS $index ) { $out = array(); if( trim( $index ) === '' ) I probably shouldn't trim... since we're not supporting quotes in any way, it might be desirable to have a key that is one or more spaces... for whatever reason :) Personally, I have a similar implementation I use all the time, but I use forward slashes to separate keys. ?php hashPathSet( $hash, 'this/is/the/hash/path', $value ) ? Cheers, Rob. { $out[] = $text; } else { $out[$index] = $text; } $text = $out; } print_r( $out ); ? I also removed the (int) cast since integer keys will be cast automatically by PHP and then it will have support for text keys also. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create/write to psd file
What I know is that you can control GIMP over the command line = you can use PHP to do this. Though I guess GIMP doesn't support PSD files, I had to express myself anyways. vuthecuong napsal(a): Hi all Is there a way to create/read/write to psd file? (photoshop format) I would like to hear opinion form you: Do you recommend gd2 or imageMagick to perform this task? and why thanks in advanced -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamically creating multi-array field
2008/10/26 Martin Zvarík [EMAIL PROTECTED]: PHP Version 5.2.4 ? $node = '[5][1][]'; ${'tpl'.$node} = 'some text'; print_r($tpl); // null ? I really don't like to use the EVAL function, but do I have choice?? This sucks. Hi there, While this question can spur some neat solutions, it raises a red flag in that if you need to do this, you probably need to rethink things a bit. In cases like this it is easier for people to help if you describe the actual problem you are trying to solve, not how you think it needs to be solved. It could be that you don't really need weird (but beautiful, like Jim's idea) solutions. If you explain why you believe that you need to do this in the first place, maybe someone can suggest something else which doesn't require a weird solution (however beautiful). Torben Hi, I am aware of this, but explaining my problem in this case would take me an hour --- and eventually would lead to a) misunderstanding, b) weird solution, c) no solution... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to kill a session by closing window or tab clicking on X?
Afan Pasalic napsal(a): hi. I'm sorry for posting this more javascript then php question, but it's somehow php related. here is the issue: very often people close the window/tab without logging out. I need solution how to recognize when [x] is clicked (or File Close) and kill the session before the window/tab is closed. few years ago, before firefox and tabs, I solved this by javascript and onClose() as a part of body tag. now, it doesn't work anymore. any suggestion/opinion/experience? thanks afan You might wanna check this out: http://cz2.php.net/ignore_user_abort -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Secure redirection?
I might have not read your post thorougly, but it's important to know, that Header sends a HTTP request to the browser - you are not hiding the destination URL. So, calling header(location: in PHP is basically same as redirect using JS. Martin Zoran Bogdanov napsal(a): Hi, I'm building a login system with AJAX/PHP/MySQL. I have worked everything out... AJAX is sending request to a php login script (login.php) who if authentication passes initializes the session and sends the header using header(Location : registered_user_area.php); The whole system works great without AJAX, but when I put AJAX in the story I ahve one problem: 1.When the user is successfully authenticated the login.php sends the header, but the AJAX XMLHttpRequest call is still in progress waiting for a PHP response. So when PHP using the header function redirects to another page that page is outputed to the login form... My PHP login snippet is: if ($res_hash == $u_pass) { $logged_user = $sql_execution-last_query_result-user; $sql_execution-exec_query(DELETE FROM seeds,false); $sql_execution-db_disconnect(); session_start(); $_SESSION['user'] = $logged_user; $host = $_SERVER['HTTP_HOST']; $url = rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . '/mpls/index.php'; header(Location: http://$host$url;);//--That page ($host$url) is outputed in the login form... exit(); } else { $sql_execution-exec_query(DELETE FROM seeds WHERE id=$row-id,false); $sql_execution-db_disconnect(); echo 'BLS';//--This is sent when the password/username is wrong exit(); } ??? Any help greatly appreciated Thank you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: operators as callbacks?
Joe napsal(a): Is it possible to use a PHP operator as a callback? Suppose I want to add two arrays elementwise, I want to be able to do something like this: array_map('+', $array1, $array2) but this doesn't work as + is an operator and not a function. I can use the BC library's math functions instead: array_map('bcadd', $array1, $array2) but that is an ugly hack that might break if the library is not available. I can create an anonymous function: array_map(create_function('$a, $b', 'return $a + $b;'), $array1, $array2) but that seems really unnecessarily verbose. Is there any simple clean way to do it? Thanks, array_sum() ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] IP and gethostbyaddr() --- difference?
Hello, I am doing a view stats for my website. I've seen that many of such statistic scripts store two values to identify the visitor: IP and getHostByAddr(IP) I've been searching..., but I don't get why the IP address isn't enough by itself?! What is the getHostByAddr() = Internet host name for? When IP changes the hostname does too and vice-versa? What's the difference between these two values? And why do I need both of them? Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] get_browser() too slow
Hello, anyone has a good function for getting a user's browser, OS and crawler detection ? I have looked at google etc, but I ran only into long list of ineffective ereg()s functions or not checking if it's crawler... Is it possible to make an array list and just check using strpos() each one? The basic browsers for Win, Mac, and Linux - others would be unknown. And then only to check for OS. I tryed get_browser() but that thing is way too slow for my needs: 0.09 sec. Thanks in advance, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: get_browser() too slow
Martin Zvarík napsal(a): Hello, anyone has a good function for getting a user's browser, OS and crawler detection ? I have looked at google etc, but I ran only into long list of ineffective ereg()s functions or not checking if it's crawler... Is it possible to make an array list and just check using strpos() each one? The basic browsers for Win, Mac, and Linux - others would be unknown. And then only to check for OS. I tryed get_browser() but that thing is way too slow for my needs: 0.09 sec. Thanks in advance, Martin Hmm... This one is decent: http://techpatterns.com/downloads/scripts/browser_detection_php_ar.txt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: =.='' what wrong ? just simple code, however error.
It works as expected on my PHP 5.2.4 LKSunny napsal(a): ? $credithold = 100; for($i=1;$i=1000;$i++){ $credithold -= 0.1; echo $creditholdbr /; } //i don't know why, when run this code, on 91.3 after expect is 91.2, however..91.2001 //who can help me ? and tell me why ? //Thank You. ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP webhosting - USA
Hi, I currently host my site by Powweb, and I am WANT to change it - can you guys recommend me something good? Powweb's website looks awesome and it's the best marketing I think I had saw! After a minute it makes you think there is NO better hosting - and it's a LIE. What happened to me? - database connection were exceeded, I read many people had problems with their phorums not working etc., the solution: I put a message to the visitor that he has to wait (it was not frequent so I didn't care much) - my client stopped receiving orders, he called me after a week something is wrong. I found out that Powweb changed a MySQL settings, which nobody informed me about - they restricted a JOIN limit max to 3, the mysql_query SQL thus did not work and orders were not storing for 7 days! - the suport is HORRIBLE - they don't give you email, but they have this ONLINE support, meaning: you wait 10-20 minutes on queue, and then they talk to you like a robots and usually tell you something you already know. - now they automatically changed all my passwords so they can keep me secure! what's cool is that I cannot change it back to what I have! Hey, the chance of getting me hit by bus is higher than someone cracking my 15 letter password with numbers! Thank you powweb for keeping me secure. Thanks for reading my story, now, does someone know a better hosting alternative? Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP webhosting - USA
That's an awful looking website, but thanks for reply. I am looking for rather a US hosting company. Andrew Williams napsal(a): go to www.willandy.co.uk http://www.willandy.co.uk best value for money On Sat, Jan 24, 2009 at 3:03 PM, Martin Zvarík mzva...@gmail.com mailto:mzva...@gmail.com wrote: Hi, I currently host my site by Powweb, and I am WANT to change it - can you guys recommend me something good? Powweb's website looks awesome and it's the best marketing I think I had saw! After a minute it makes you think there is NO better hosting - and it's a LIE. What happened to me? - database connection were exceeded, I read many people had problems with their phorums not working etc., the solution: I put a message to the visitor that he has to wait (it was not frequent so I didn't care much) - my client stopped receiving orders, he called me after a week something is wrong. I found out that Powweb changed a MySQL settings, which nobody informed me about - they restricted a JOIN limit max to 3, the mysql_query SQL thus did not work and orders were not storing for 7 days! - the suport is HORRIBLE - they don't give you email, but they have this ONLINE support, meaning: you wait 10-20 minutes on queue, and then they talk to you like a robots and usually tell you something you already know. - now they automatically changed all my passwords so they can keep me secure! what's cool is that I cannot change it back to what I have! Hey, the chance of getting me hit by bus is higher than someone cracking my 15 letter password with numbers! Thank you powweb for keeping me secure. Thanks for reading my story, now, does someone know a better hosting alternative? Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP webhosting - USA - conclusion
I should have said in the beginning it's a small website and I am not looking for a dedicated server. Howewer, I decided to move to Lypha.com Thanks for all your fruitful* comments :) Martin PS: PHP mailgroup rulz *) that was in dictionary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Make New-Age Money Online with Google
Ashley Sheridan napsal(a): On Sat, 2009-01-24 at 10:14 +0200, Dora Elless wrote: That's why I am sending this email only to people I know and care about. And they send to a mailing list. Come again? Ash www.ashleysheridan.co.uk The sad thing though is that there will be always people who believe this shit and pays... Like my dad bought a little book Take off your glasses for $10 and he received 2 papers saying: sun is our best friend, look right into it and it will heal your eyes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cgi vs php
Thodoris napsal(a): Y In cgi i can use perl ,c etc suppose i use perl now how efficiency differs? How cgi written in perl and php is differ in working in context of web service? other difference?. but their differ. On Thu, Feb 5, 2009 at 6:45 PM, Jay Blanchard jblanch...@pocket.com wrote: [snip] can anybody tell me the benefits of php over cgi or vice versa? i need to compare both? [/snip] CGI is a gateway to be used by languages PHP is a language First of all try not to top post this is what we usually do here. Well CGI is a standard protocol implemented by many programming languages. You may start googling to find about it but this is a start: http://en.wikipedia.org/wiki/Common_Gateway_Interface Both Perl and PHP can work with CGI but working with Perl-CGI is not something that we should discuss in this list since this is a *PHP* list. IMHO you should start reading some aspects of web development to make some things clear before start asking questions in the lsit. This will improve your understanding and it help us to make suggestions. I admire your calmness. Such a descriptive reply for someone who doesn't think before asking. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Speed Opinion
Nathan Rixham napsal(a): Ashley Sheridan wrote: On Thu, 2009-02-05 at 09:44 +1100, Chris wrote: PHP wrote: Hi all, I am seeking some knowledge, hopefully I explain this right. I am wondering what you think is faster. Say you have 1000 records from 2 different tables that you need to get from a MySQL database. A simple table will be displayed for each record, the second table contains related info for each record in table 1. Is if faster to just read all the records from both tables into two arrays, then use php to go through the array for table 1 and figure out what records from table 2 are related. Or, you dump all the data in table 1 into an array, then as you go through each record you make a database query to table 2. Make the db do it. PS: I know I can use a join, but I find anytime I use a join, the database query is extremely slow, I have tried it for each version of mysql and php for the last few years. The delay difference is in the order of 100x slower or more. Then you're missing indexes or something, I've joined tables with hundreds of thousands of records and it's very fast. -- Postgresql php tutorials http://www.designmagick.com/ I've used joins on tables with millions of rows, and it's still not been too slow to use. Admittedly it was an MSSQL database, which I've always found to be slower, but MySQL was built to be a relational database, and can handle many many millions of records quite happily. The slowdown you experienced is either not using indexes on tables, or the way you were displaying/manipulating those results from within PHP. Ash www.ashleysheridan.co.uk and if you use spatial indexes and points instead of integers you can join on the biggest of databases with literally no perfomance hit, same speed regardless of table size :p (plus cos a point has two values you can use one for id and the other for timestamp ;) regards ps: i've said this many times before, but not for like 6 months so time for another reminder MySQL supports spatial extensions to allow the generation, storage, and analysis of geographic features. So, I use spatial indexes when creating a geographic map? Is it good for anything else? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ZEND Certification
Hi, anyone has taken ZEND PHP Certification Exam??? Please can you give me some information about it? Thank you, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] ZEND Certification
Ok, what should I expect from the certification then? Was there any question you didn't expect or anything you didn't know?? If yes, what was it? It seems like not many people took it as I am reading some emails here... like How to get variable after the form is sent etc... I have looked at yellow pages, seems like you're not there either, Rory Browne... If many people here have taken it, can someone please answer my questions above? Thank you! Martin -Original Message- From: Rory Browne [mailto:[EMAIL PROTECTED] Sent: Friday, May 20, 2005 1:31 PM To: Martin Zvarik Cc: php-general@lists.php.net Subject: Re: [PHP] ZEND Certification On 5/20/05, Martin Zvarik [EMAIL PROTECTED] wrote: Hi, anyone has taken ZEND PHP Certification Exam??? Yes. Loads of people here have taken it. Loads of other people here set the questions. Please can you give me some information about it? I'm sure you'll get lots of useful and encourageing information about it. In the meantime you might want to search the archives. Thank you, Martin -- 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: Strange comparison behaviour
String info is converted to integer, which is 0... a) if(info == 0) b) if(info === 0) c) if(info == (string)0) Or use strcmp() Cya... Read a book PHP for beginners -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED] Sent: Friday, May 13, 2005 5:13 AM To: php-general@lists.php.net Subject: [PHP] Re: Strange comparison behaviour You probably mis-typed something: [EMAIL PROTECTED] ~]$ php ? if (info == 0) echo is 0\n; else echo not 0\n; ? Content-type: text/html X-Powered-By: PHP/4.3.11 is 0 Cheers, Bogdan Erwin Kerk wrote: Hi All, Can anyone explain me why the following code: if (info == 0) echo is 0\n; else echo not 0\n; Results in: not 0 Whereas: if (inf == 0) echo is 0\n; else echo not 0\n; Results in: is 0 Notice the difference: info in the first sample, inf in the second sample. The used PHP version is PHP 4.1.2 (CLI version) Erwin Kerk -- 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] .INC files
Hi, I saw files like file.inc.php and file.inc What is the *.inc suffix good for ? Thank you for replies. Martin
[PHP] [Files suffix] .inc.php files
Hi, I saw files like file.inc.php and file.inc What is the *.inc suffix good for ? Thank you for replies. Martin
[PHP] TEST
test dammit, doesnt work
[PHP] Re: .INC files
Sorry I didnt know the post delay is that LONG... On 5/31/05, Jason Barnett [EMAIL PROTECTED] wrote: Martin Zvarik wrote: Hi, I saw files like file.inc.php and file.inc What is the *.inc suffix good for ? Thank you for replies. Martin STOP SPAMMING THE LIST! .inc is just a shorthand for include files and it's just a different way of organizing code
Re: [PHP] Beautiful HTML Invoice - Prints like crap! I need somesuggestions!
On 6/7/05, Matt Babineau [EMAIL PROTECTED] wrote: Yeah I was considering that...I'm trying the html2pdf site right now. It seems alright...its choking on my invoice as we speak (lots of html). Is there a way to make a JPG? I've looked at a few sites from google..most are activeX...somewhat undersirable. Looking for something I can run on the server to do the convert work. Thanks, Matt Babineau Criticalcode w: http://www.criticalcode.com p: 858.733.0160 e: [EMAIL PROTECTED] -Original Message- From: Jack Jackson [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 07, 2005 3:21 PM To: php-general@lists.php.net Subject: Re: [PHP] Beautiful HTML Invoice - Prints like crap! I need somesuggestions! Matt Babineau wrote: Hi all - I've got a great html invoice that prints like crap because of my user of background images and foreground images. Does anyone have any good suggestions other than turn on images in IE to get this thing to print the graphics? Is there a good way I could convert the HTML view to a JPG? I'm on a linux box and have php 4.3.10. Thanks for the help! Matt Babineau Criticalcode w: http://www.criticalcode.com p: 858.733.0160 e: [EMAIL PROTECTED] Make it a pdf? Is a simple CSS print stylesheet out of the question? If the site is marked up properly, this should be trivial, and would be much easier/more efficient. IMO the only image that should be on a printed invoice, is the logo (if any). -- Chris Martin Web Developer Open Source Web Standards Advocate http://www.chriscodes.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best way how to STORE DATA
Hi, what's the best way how to store a small amount of data, like list of categories or sections of a website. CVS (comma delimited text) x Database (MySQL, or other) x XML ? Which method is the fastest? Anyone has any personal experiences? Thank you in advance for replies. Martin Zvarik
[PHP] PHP Install with MySQL in 64 bit libraries.
I installed MySQL 4.23 using SuSE provided rpms so it loads to /usr/lib64 How do I configure the php 5.0 configure script so that it finds the mysql client in here while finding other objects in the /urs/local/. Currently the link fails as it does not find the mysql client so files. Thanks Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php vulnerability
You might also scan your machine (and/or network) with something such as nessus, or another vulnerability scanner -- Chris Martin Web Developer Open Source Web Standards Advocate http://www.chriscodes.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php5 COM strange behaviour
Hello NG, we have a script to create a word-document via COM which, so far, run pretty stable under php 4.3.7 Since we upgraded to php 5.0.3.3 the same script works only on the first run! On the following runs the same script causes a fatal error on the code below: Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft Word Description: Wrong Parameter.' in [Scriptname]:65 Stack trace: #0 [Scriptname](65): variant-GoTo('wdGoToField', 'wdGoToFirst', 1) #1 [SourceScript] include('[Scriptname]') #2 {main} thrown in [Scriptname] on line 65 Code : $NumberFields = $word-ActiveDocument-MailMerge-fields-Count; for ($CounterFields = 1; $CounterFields = $NumberFields; $CounterFields++) { $word-Selection-Range-GoTo(wdGoToField, wdGoToFirst, $CounterFields); -- Creates Fatal Error ... } When we reset the Apache-Service, the script runs again once! Subsequent calls create the same fatal error again ... we changed access-rights in dcomcnfg which didn't show any influence ... Environment: win 2003 server, Apache 2.0.53 I'm greatful for any hint ! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 COM strange behaviour
we have a script to create a word-document via COM which, so far, run pretty stable under php 4.3.7 are you using apache2 with php4? Yes ! are you using the prefork version of apache2? (you should be!!) No - not to my knowledge. I couldn't really find out HOW to implement this prefork version !?!? It's off-topic here, but could you give me a hint, what to do/where to lookup? Is it just configuration or do we have to compile it ourselves? Since we upgraded to php 5.0.3.3 the same script works only on the first maybe try 5.0.2, 5.0.4 or 5.0.5beta ?? I'll try Apache 2 prefork first, since the changelog of PHP doesn't indicate any progress related to COM-operations recently. run! blooming odd - sounds like a thread[ing] related issue (which is why I say you should be using the orefork version of apache2) On the following runs the same script causes a fatal error on the code below: Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft Word Description: Wrong Parameter.' in [Scriptname]:65 Stack trace: #0 [Scriptname](65): variant-GoTo('wdGoToField', 'wdGoToFirst', 1) #1 [SourceScript] include('[Scriptname]') #2 {main} thrown in [Scriptname] on line 65 apparently the COM extension is designed to throw exceptions in php5 (sometimes). which, regardless of the fact that this exception is being thrown seems to be a complete error, would seem to mean that you are going to have to change your code slightly to incorporate at least one try/catch block around all your code in order to avoid uncaught exceptions. We'll do so, after the core-problem is identified. Code : $NumberFields = $word-ActiveDocument-MailMerge-fields-Count; for ($CounterFields = 1; $CounterFields = $NumberFields; $CounterFields++) { $word-Selection-Range-GoTo(wdGoToField, wdGoToFirst, $CounterFields); are wdGoToField and wdGoToFirst actually constants? yep. And they work usually. -- Creates Fatal Error ... } When we reset the Apache-Service, the script runs again once! Subsequent calls create the same fatal error again ... we changed access-rights in dcomcnfg which didn't show any influence ... Environment: win 2003 server, Apache 2.0.53 Thank you for the support ! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 COM strange behaviour
we have a script to create a word-document via COM which, so far, run pretty stable under php 4.3.7 are you using apache2 with php4? Yes ! Sorry - my mistake here : the problems are caused under PHP5. With PHP4 the script runs fine, so right now we are using PHP4, but due to other functionality we're forced to migrate to PHP5 pretty soon. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Themes, pictures directory
Hi, I have a website, which uses themes. The web tree looks like this: * webroot o *themes* + default # images + red design # images o *index.php* Let's say I choose red design theme. All the pictures the theme is using will have URL like www.site.com/themes/default/images/bla.jpg. Is there a way how I can change it? So noone can see I have themes in that directory? I was thinking about: ShowImage.php?blah.jpg, but that is too slow... :-/ Any help appreciated. Martin
[PHP] (Yet another) I'm blind ... post
In this code, I'm not getting the value of $list passed to the Mailman page. I've checked this umpteen times by now, but fail to see the error. I've beaten myself suitably with a steel ruler -- but it didn't help. Nor does the cold I'm coming down with I suppose. Anyone see the error, and feel like pointing it out to me? Martin S ?php print H2BJoin the lists/b/H2; print FORM Method=POST ACTION='http://www.bollmora.org/mailman/subscribe/' . $lista . 'br'; print Your E-mail address: INPUT type=\Text\ name=\email\ size=\30\ value=\\br; print Your Name (optional): INPUT type=\Text\ name=\fullname\ size=\30\ value=\\brbr; print Lista: select name=\lista\ /; print option value=\tvl_bollmora.org\Tävling/option; print option value=\jpg_bollmora.org\JGP/option; print option value=\styrelse_bollmora.org\Styrelse/option; print /selectbr; print You may enter a privacy password below. This provides only mild security, but shouldbr prevent others from messing with your subscription. bDo not use a valuable password/b as itbr will occasionally be emailed back to you in cleartext.brbr If you choose not to enter a password, one will be automatically generated for you, and it willbr be sent to you once you've confirmed your subscription. You can always request a mail-backbr of your password when you edit your personal options.brbr; print Would you like to receive list mail batched in a daily digest? (You may choose NoMail after you join.)BRbr; print input type=radio name=\digest\ value=\0\ CHECKED No input type=radio name=\digest\ value=\1\ Yesbrbr; print INPUT type=\Submit\ name=\email-button\ value=\Subscribe\; print /FORM; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beware of OS X PHP security update...
On 03/03/2006, at 11:15 PM, Marcus Bointon wrote: The OS X security update issued yesterday includes a PHP 'fix', by which they mean that it installs PHP 4.4.1. If you have installed PHP 5 from elsewhere, it will get trashed along with your PEAR setup. PEAR is now completely confused or me and just crashes when I try to do anything. Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I installed the update successfully, no effect on PHP 5. Perhaps you need to look elsewhere Geoff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL close connection, what's the purpose?
Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
Richard Lynch wrote: On Fri, March 31, 2006 2:30 pm, Martin Zvarík wrote: I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? Yes, but... Suppose you write a script to read data from one MySQL server, and then insert it into 200 other MySQL servers, as a sort of home-brew replication (which would be really dumb to do, mind you)... In that case, you REALLY don't want the overhead of all 200 connections open, so after you finish each one, you would close it. There are also cases where you finish your MySQL work, but have a TON of other stuff to do in the script, which will not require MySQL. Close the connection to free up the resource, like a good little boy. :-) There also COULD be cases where your PHP script is not ending properly, and you'd be better off to mysql_close() yourself. So, does the connection close automatically at the end of the script ? My situation is following: I have a e-shop with a ridiculously small amount of max approved connections, so it gives an error to about 10% of my visitors a day, that the mysql connections were exceeded. Now, if I will delete the mysql_close() line, will that help me or not? My webhosting does not allow perminent connections either. Thanks, MZ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simpleXML - simplexml_load_file() timeout?
Maybe you can read the contents of the feeds using fsockopen() and stream_set_timeout() to adjust the timeout, or stream_set_blocking() to read it asynchronously, and then load the xml with simplexml_load_string(). PS: I forgot to reply to all and mention you'll have to send the GET http command and headers, check the php manual for examples. 2006/4/10, darren kirby [EMAIL PROTECTED]: Hello all, My website uses simpleXML to print the headlines from a few different RSS feeds. The problem is that sometimes the remote feed is unavailable if there are problems with the remote site, and the result is that I must wait for 30 seconds or so until the HTTP timeout occurs, delaying the rendering of my site. So far, I have moved the code that grabs the RSS feeds to the bottom of my page, so that the main page content is rendered first, but this is only a partial solution. Is there a way to give the simplexml_load_file() a 5 second timeout before giving up and moving on? Here is my function: function getFeed($remote) { if (!$xml = simplexml_load_file($remote)) { print Feed unavailable; return; } print ul\n; foreach ($xml-channel-item as $item) { $cleaned = str_replace(, amp;, $item-link); print lia href='$cleaned'$item-title/a/li\n; } print /ul\n; } PHP 5.1.2 on Linux. thanks, -d -- darren kirby :: Part of the problem since 1976 :: http://badcomputer.org ...the number of UNIX installations has grown to 10, with more expected... - Dennis Ritchie and Ken Thompson, June 1972 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function by reference
The ampersand before the function name indicates that the function returns a reference instead of a copy of the variable, for example: ?php function max($var1, $var2) { if ($var1 $var2) return $var1; else return $var2; } $global1 = 10; $global2 = 9; $maxglobal = max($global1, $global2); $maxglobal++; echo $global1; //this will print 11 since $maxglobal is a reference to $global1 ? 2006/4/11, tedd [EMAIL PROTECTED]: Additionally, what I don't get is this: ?php $a = 10; echo($a br/); ref1($a); echo($a br/); $a = 10; echo($a br/); ref2($a); echo($a br/); $a = 10; echo($a br/); ref3($a); echo($a br/); ? ?php function ref1($a) { $a--; } ? ?php function ref2($a) { $a--; } ? ?php function ref3($a) { $a--; } ? The first two functions work as I would expect. The last one is shown in the documentation, but doesn't work as I expected. There doesn't appear to be any difference between ref1 and ref3 -- so what's with the ampersand in ref3? What is an ampersand supposed to mean/do when it precedes a function? Thanks. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: double lines
Barry wrote: clive wrote: Does the html textarea add in \r. Normally not. But the mailing function might do. Replace every \n with linbreak and every \r with linefeed with str_replace And probably you see where the problem is It's because of the operation system. Win32 and Linux works different. Linux adds extra line. Martin [Zend Certified] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] Include Problem
Ups, I forgot to reply to everyone again, sorry. -- Forwarded message -- From: Martin Alterisio [EMAIL PROTECTED] Date: 16-abr-2006 13:53 Subject: Re: [PHP] Include Problem To: Shaun [EMAIL PROTECTED] You're using an absolute path to the file, maybe what you really meant to do was: include(cms/templates/footer.php); 2006/4/15, Shaun [EMAIL PROTECTED]: Hi, I am having problems with an include statement, i am using the following statement in an effort to include a footer file on my page: include(/cms/templates/footer.php); However I get the following error: Warning: main(/cms/templates/footer.php): failed to open stream: No such file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line 38 Warning: main(/cms/templates/footer.php): failed to open stream: No such file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line 38 Warning: main(): Failed opening '/cms/templates/footer.php' for inclusion (include_path='.:/lib/php') in /home/m/y/mysite/public_html/cms/news/index.php on line 38 The file is definitely there, the script just doesn't seem to be picking it up, has anyone else had this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Passing Form As Argument
My first answer to your question would be: no, you can't refer to an html form in any way in php. My second answer would be, as usual, a question: what, exactly, are you trying to do? 2006/4/20, Chris Kennon [EMAIL PROTECTED]: Hi, I'm new to the list so Hello to all. I'm drafting a function.php page, which will be included() in the pages in need. How would I pass a form as an argument of a function? From the name parameter of the form element or perhaps an ID: function checkForm(theForm){ //Form validation code omitted. } Also, I seem to recall some caution is needed when using user-defined functions? Art is an expression of life and transcends both time and space. We must employ our own souls through art to give a new form and a new meaning to nature or the world. -- Bruce Lee _ Return True, Christopher Kennon Principal/Designer/Programmer -Bushidodeep http://bushidodeep.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an OO Shopping Cart
The $_SESSION array is already being serialized before saving it to the session datafile. You'll only have to: $_SESSION['cart'] = $cart; And before session_start(): require_once 'fileWhereClassIsDefined'; . . . session_start(); If the class isn't defined before serialization (session start) an instance of stdclass is created. You should define the magic member functions __sleep and __wake if you need to reopen any resource needed for your object (resources, as in opened files, opened mysql connectios, mysql queries, ARE NOT serialized) 2006/4/20, Paul Novitski [EMAIL PROTECTED]: At 05:14 PM 4/20/2006, Steve wrote: I'm creating my own Object Oriented PHP Shopping Cart. I'm confused about the best way to call the functions of the class given the static nature of the web. For example, if I have a function addItem($code), how will this be called from the catalog or product description pages where the BUY buttons are? On the product description page (say for product ABC213), there will be a BUY button, but when the button is clicked, obviously I cannot immediately call $cart-addItem('ABC213'). So how is this done? Steve, One way to preserve your cart object between page requests is to keep it serialized in the session. When the PHP program wakes up: // begin session processing session_start(); // if the cart already exists... if (isset($_SESSION[cart]) { // read the cart from the session $oCart = unserialize($_SESSION[cart]); }else{ // or create it $oCart = new CartObject(); } Before the PHP script ends: // save the cart to the session $_SESSION[cart] = serialize($oCart); In the body of the script, you'll use $_GET and/or $_POST arrays to feed user input into the cart object, and echo functions to write each new page in response. Does this help clarify, or am I stating only what you already know? Paul _ Refs: http://php.net/session http://php.net/session_start http://php.net/serialize http://php.net/unserialize http://php.net/isset -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Linebreak
You wouldn't feel/look stupid if you had RTFM: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single 2006/4/20, Peter Lauri [EMAIL PROTECTED]: I feel stupid. In many examples I have seen similar to: echo 'pWhatever./p\n'; echo 'pAn other whatever./p\n'; But my PHP outputs the \n instead of a new line in the source. I am stupid?
Re: [PHP] Re: Creating an OO Shopping Cart
You don't need the unserialize(), it's done internally by the session_start(). All the things you put inside $_SESSION, except for resources, will be rebuilt when the session is regenerated. This way you don't need to worry about serializing. Read the manual section about sessions. 2006/4/21, Steve [EMAIL PROTECTED]: Hi Thanks for all your help so far. I've combined all your thoughts, and from what I understand, for every page I have that interacts with the cart, I need to have something like the following code. So basically, on every page, be it a page that displays the contents of the cart, the checkout, or catalog pages, at the top of the code I always need to check if files are being added, deleted or changed qty. Is this correct? This is my biggest concern. What's the best way to interact with the Cart class when adding/removing items? Thanks Steve ?php // This File: catalog.php require_once 'Cart.php'; session_start(); /* Establish connection to the cart */ if ( isset($_SESSION[cart] ) $cart = unserialize($_SESSION[cart]); else $cart = new Cart(); /* Modify the cart for this user */ if ( isset($_GET['add']) ) $cart-addItem($_GET['add']); if ( isset($_GET['remove']) ) $cart-removeItem($_GET['remove']); /* Save the cart's state */ $_SESSION['cart'] = $cart; /* Display the catalog */ echo HEREDOCS blah blah HEREDOCS; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array problem
You're wrong, he isn't using an associative array, since the keys used are only integers. array(10,10,40,30,30,10); and array(0=10,1=10,2=40,3=30,4=30,5=10); create the same array. The problem is that array_unique preserves keys (read the manual!!!) If you don't want this, use array_values() to turn the array into a more traditional array: $a = array_values(array_unique($a)); 2006/4/22, Brian V Bonini [EMAIL PROTECTED]: On Sat, 2006-04-22 at 07:09, suresh kumar wrote: sorry.earlier i mistyped some values. I am facing one project in my project . this is my code: a=array(0=10,1=10,2=40,3=30,4=30,5=10); b=array(); b=array_unique($a); print_r($b); o/p getting from above code is b[0]=10,b[2]=40,b[3]=30,b[5]=10; but i want the o/p be b[0]=10,b[1]=40,b[2]=30,b[3]=10; That will return: Array ( [0] = 10 [2] = 40 [3] = 30 ) If you want: Array ( [0] = 10 [1] = 40 [2] = 30 ) Don't use an associative array for $a $a=array(10,10,40,30,30,10); Or iterate through $a to re-sequence the index in $b. $a=array(0=10,1=10,2=40,3=30,4=30,5=10); $a=array_unique($a); foreach($a as $v) { $b[] = $v; } print_r($b); -- s/:-[(/]/:-)/g BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CMS for Auto Parts
On 23 Apr 2006, at 8:03 PM, John Hicks wrote: CK wrote: Hi, On Apr 22, 2006, at 1:26 PM, John Hicks wrote: CK wrote: Hi, I've been commissioned to design a web application for auto parts sales. The Flash Front end will communicate with a MySQL DB via PHP. In addition, PHP/XML should be used with a client-side Web GUI to upload images, part no., descriptions and inventory into the DB; a Product Management System. I am curious as to how you plan to using XML for the client's back end? (I don't see any reason to use it.) Using XML to keep an inventory dynamically, was the thought. The XML file would be updated with each entry, then could be imported into a spreadsheet. If you are storing your inventory in an XML document, then what are you using the MySQL database for? After Googling the returned queries have been slim, any leads on more specific examples? What specifically are you looking for and how are you googling for it? --John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You may want to look into openlaszlo. http://www.openlaszlo.org/ You can use it to provide the Internet front-end and use PHP for the back- end. Also, now has the option for either DHTML or Flash on the client side. Johan Martin Catenare LLC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Standard style of writing your code
Hi, I see everyone has its own way of writing the code. If there is 10 programmers working on same thing, it would be good if they would have same style of writing the PHP code. So, my question is: Is there anything what would define standard style of writing PHP code? Thanks, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
You should be able to do this in two calls to the mysql_query() function. mysql_query(SET @var1=3); mysql_query(SELECT * from table1 Where [EMAIL PROTECTED]); 2006/4/26, Mauricio Pellegrini [EMAIL PROTECTED]: Hi all I'm trying to execute two querys and they execute perfectly in fact, but after the execution of the first query there suposed to be some variable setted to a certain value. The problem is this variable is not available at the time the second query runs. I`ll try to explain a little bit further //This is my first query $quer1= SET @var1=3 ;//Here I`m suposed to set the value for var1 to 3 mysql_query($quer1); // This is query #2 $query2=SELECT * from table1 where [EMAIL PROTECTED] //Here @var1 doesn`t exist That wasn't really my first attempt. Originally I've tryied the whole thing in just one single query but mysql gave me an error message complinning about the semicolon Please look at this $quer1 = SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ; This gave a syntax error from MySQL inmmediately before the ; (semicolon), Please any help greatefully appreciated Thanks Mauricio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Debuggin PHP
2006/4/26, John Nichel [EMAIL PROTECTED]: hicham wrote: Hello I'm a newbie in php world , and I'm trying to get a php 4 script work on an php5 version how do i debug php ? I get a blank page and nothing tells me what 's wrong ? Thanks hicham Turn on error reporting. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] error_reporting(E_ALL); at the beggining of your script or modify your php.ini
Re: [PHP] PHP 4.3.11, call_user_func and instances of classes
The problem is not what it seems. PHP4 assigns object by copy, not by reference. This is causing the call_user_func() to use a copy of the object instead of the original object. So, all modifications are lost once the call is done. One solution to this is to assign objects by reference: $addition = array ($this, 'AddOne'); $subtraction = array ($this, 'SubtractOne'); 2006/4/26, David Otton [EMAIL PROTECTED]: A bit of an oddity, this. There's some example code attached which illustrates my problem. I am attempting to call a method of an instance of an class from outside that instance, using call_user_func(). What's happening is that my attempt to call array ($this, 'AddOne') is silently being rewritten into a call to array ('Test', 'Addone') in other words, instead of calling $test-AddOne I'm calling Test::Addone. Thus, my expected output: Add:1,Add:2,Add:3,Subtract:2,Subtract:1,Subtract:0, becomes Add:1,Add:1,Add:1,Subtract:-1,Subtract:-1,Subtract:-1, So, my question is twofold: a) How can I accomplish this? b) Why is PHP silently modifying my code to mean something I didn't write, rather than throwing up an error? ?php $addition = $subtraction = null; class Test { var $x; function Test () { global $addition, $subtraction; $this-x = 0; $addition = array ($this, 'AddOne'); $subtraction = array ($this, 'SubtractOne'); doMath('+'); doMath('+'); doMath('+'); doMath('-'); doMath('-'); doMath('-'); } function AddOne () { $this-x++; echo (Add:.$this-x.,); } function SubtractOne () { $this-x--; echo (Subtract:.$this-x.,); } } function doMath($choice) { global $addition, $subtraction; switch ($choice) { case '+': call_user_func ($addition); break; case '-': call_user_func ($subtraction); break; } } $test = new Test(); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and dynamic creation and unique field names
Jason Gerfen wrote: I have come upon a problem and am not sure how to go about resolving it. I have an web form which is generated dynamically from an imported file and I am not sure how I can loop over the resulting post variables within the global $_POST array due to the array keys not being numeric. Any pointers are appreciated. You will never be ready for me. ~ Me Hahah... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to get the absolute path of an included file?
2006/4/27, Bing Du [EMAIL PROTECTED]: Hello, Here are the two scripts. The result is 'var is' rather than 'var is foo'. My suspect is I did not set the file path right in 'include'. So in file2.php, how should I get the actual absolute path it really gets for file1.php? Is it stored in some environment variable or something? I'd appreciate any help. file1.php == ?php $var = 'foo'; ? == file2.php == ?php include '/some/path/file1.php'; echo var is $var; ? == Thanks, Bing -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Activate reporting of all errors either through php.ini or error_reporting(E_ALL); Use include_once instead of include. That way the program will stop if it couldn't include the file. Try using a relative path to the file.
Re: [PHP] Re: forms and dynamic creation and unique field names
2006/4/27, Jason Gerfen [EMAIL PROTECTED]: Oops, I thought there might be an array function that would be better to use then foreach loops. Thanks. There are other functions (check the Array Functions section in the manual), but they just don't get along with the KISS principle. Dave Goodchild wrote: Foreach. Please try and read the manual, this is very basic stuff that could be gleaned in 5 minutes. On 27/04/06, Barry [EMAIL PROTECTED] wrote: Jason Gerfen schrieb: I have come upon a problem and am not sure how to go about resolving it. I have an web form which is generated dynamically from an imported file and I am not sure how I can loop over the resulting post variables within the global $_POST array due to the array keys not being numeric. Any pointers are appreciated. foreach? -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon! -- Jason Gerfen You will never be ready for me. ~ Me -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Recommended PHP frameworks
2006/4/27, Robert Cummings [EMAIL PROTECTED]: A funny PHPClasses article... http://www.phpclasses.org/blog/post/52-Recommended-PHP-frameworks.html One thing I understood after hitting my head many times to a wall is that a good idea can be, and should be, explained in just three lines of text, that's all you need, that's all they will hear from you. This article goes beyond that limit by far, if it was a good idea, the author still doesn't understand it completely. I find it telling that the guy who runs the PHP Classes site only uses his own code *lol*. Oh btw, the article says virtually nothing useful about frameworks, but it does go a long way to pimp Manuel's own classes -- another oddity considering it leads with a blurb about recognizing bias when you read it ;;) I want my 5 minutes back!! All those hours wasted in unlikely usable ideas will come back to you when you accidentally stumble into just one good idea, which can be either yours or someone's else (hopefully this person still doesn't have the copyright ;-) ) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help!
2006/4/28, Dave Goodchild [EMAIL PROTECTED]: Hi all - I am attempting to solve some maddening behaviour that has me totally stumped and before I take a blade to my throat I thought I would pick the brains of the group/hive/gang. I am working on a viral marketing application that uses multipart emails to notify entrants of their progress in the 'game'. I have a demo version which works fine, and the current rebranded version was also fine until the client asked for some changes then POW! I will try and define the issue as simply as I can. I am passing 11 arguments to a function called sendSantaMail (don't ask) and as a sanity check I have called mail() to let me know the values just before they are passed in to the function. I get this result: sendSantaMail That's just not a *declarative* way of naming a function. Then, 11 arguments Errr, passing an associative array with the email parameters wouldn't have been a cleaner and better option? Values to be passed to sendSantaMail: Friend Name: Treyt Friend Email: [EMAIL PROTECTED] Sender Name: Bull Sykes Sender Email: [EMAIL PROTECTED] Prize ID: 1 Nominator ID: 2555004452133557e4d Nominee ID: 851355445213355cc6f Chain ID: CHAIN824452133561a8d - this is all good and correct. I also call mail from the receiving function to check the actual values received by the function and I get this: Values sent into sendSantaMail function: Friend Name: [EMAIL PROTECTED] Friend Email: Look what you may have won! Sender Name: 8 Use of undefined constant prize - assumed 'prize' Sender Email: 158 Sender Email: /home/friend/public_html/process1.php Prize: 1 Subject: 158 Nominator ID: 33238744520f5235b85 Nominee ID: 96658244520f524bb19 Chain ID: CHAIN84644520f525a56f What is happening? I have checked the order of values being passed in and the function prototype and they match in the correct order, there are no default values. I have been trying to solve this for two days and am particularly concerned that somewhere along the way the sender email value becomes the script name. One idea, you messed up somewhere. Use debug_print_backtrace() on the function to get a dump of function call stack. Use it with an if to catch the moment where the wrong values appear. The first entry of the backtrace should point the file and line where the function was called. If you're using php4 you'll have to use var_dump(debug_backtrace()) instead of debug_print_backtrace(). Also check the error Use of undefined constant prize - assumed 'prize'. Please tell me your are not doing something like this: $arr[prize] Any ideas on this black Friday? -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
Re: [PHP] Help!
2006/4/28, Barry [EMAIL PROTECTED]: Martin Alterisio schrieb: 2006/4/28, Dave Goodchild [EMAIL PROTECTED]: Hi all - I am attempting to solve some maddening behaviour that has me totally stumped and before I take a blade to my throat I thought I would pick the brains of the group/hive/gang. I am working on a viral marketing application that uses multipart emails to notify entrants of their progress in the 'game'. I have a demo version which works fine, and the current rebranded version was also fine until the client asked for some changes then POW! I will try and define the issue as simply as I can. I am passing 11 arguments to a function called sendSantaMail (don't ask) and as a sanity check I have called mail() to let me know the values just before they are passed in to the function. I get this result: sendSantaMail That's just not a *declarative* way of naming a function. Do you know what santa means? No? so how can you tell it's not declarative. Santa could be a coded Mailer and that functions uses that specific Mailer Deamon called santa to send mails. Yeah you're right, I was thinking the exact same thing a while after I posted that. Maybe it was a correct name in the context used, but, I still think Santa is a really misleading name for a mailer, and not to mention that a mass mailer identifying itself as Santa mailer in the headers is asking to be send directly to spam. Anyway, I was wrong. Then, 11 arguments Errr, passing an associative array with the email parameters wouldn't have been a cleaner and better option? He just told he passes 11 arguments, never told how he does that. Well, if somebody tells you a function has 11 arguments what would you think?
Re: [PHP] undefined variable
2006/4/29, Smart Software [EMAIL PROTECTED]: code below shows all records from products table with an textbox and an order button for each record ? $query1 = mysql_query(SELECT * FROM products ); while ($rowType = mysql_fetch_array($query1)) { ? table width=500 border=0 tr class=largeheader td width=40%? echo $rowType[0]; ?/a /td td width=10%?php echo $rowType[1]; ?/td td width=10%input name=quantity type=text value=1 size=1 maxlength=3/td td width=40% a href=? echo products.php?cat=$cattoevoegen=1id=$rowType[7]; ?img src=images/bestel1.gif border=0/a/td /tr ?php } ? /table if someone presses the button, an item will be ordered. How can i add the content of the textbox? i tried this: td width=40% a href=? echo products.php?cat=$catquantity=$quantitytoevoegen=1id=$rowType[7]; ?img src=images/bestel1.gif border=0/a/td but all i get is an error telling me there is a undefined varable Can you post what the error looks like? thanx for all help N. Karademir -- PHP General Mailing List ( http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help!
That's ok, but then I can't help you more than I tried to. Just check with what I told you about debug_backtrace(), at least that way you can trace where the function was called with wrong arguments. 2006/4/29, Dave Goodchild [EMAIL PROTECTED]: Misleading to who? I own the app and am the only person who will ever use it. Rather anal. On 29/04/06, Martin Alterisio [EMAIL PROTECTED] wrote: 2006/4/28, Barry [EMAIL PROTECTED]: Martin Alterisio schrieb: 2006/4/28, Dave Goodchild [EMAIL PROTECTED]: Hi all - I am attempting to solve some maddening behaviour that has me totally stumped and before I take a blade to my throat I thought I would pick the brains of the group/hive/gang. I am working on a viral marketing application that uses multipart emails to notify entrants of their progress in the 'game'. I have a demo version which works fine, and the current rebranded version was also fine until the client asked for some changes then POW! I will try and define the issue as simply as I can. I am passing 11 arguments to a function called sendSantaMail (don't ask) and as a sanity check I have called mail() to let me know the values just before they are passed in to the function. I get this result: sendSantaMail That's just not a *declarative* way of naming a function. Do you know what santa means? No? so how can you tell it's not declarative. Santa could be a coded Mailer and that functions uses that specific Mailer Deamon called santa to send mails. Yeah you're right, I was thinking the exact same thing a while after I posted that. Maybe it was a correct name in the context used, but, I still think Santa is a really misleading name for a mailer, and not to mention that a mass mailer identifying itself as Santa mailer in the headers is asking to be send directly to spam. Anyway, I was wrong. Then, 11 arguments Errr, passing an associative array with the email parameters wouldn't have been a cleaner and better option? He just told he passes 11 arguments, never told how he does that. Well, if somebody tells you a function has 11 arguments what would you think? -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
[PHP] Session - when they expirate ?
Hi, I was looking all over the internet and I don't understand when and how does the PHP session expirate. I suppose that it happens when the user is inactive. On my website I don't use cookies for session and it has standard php.ini configuration: session.gc_maxlifetime = 1440 session.gc_divisor = 100 session.gc_probability = 1 session.cache_expire = 180 So, does this mean, that if the visitor is 180 minutes inactive it automatically deletes the session ?? Thanks, Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Syntax Oddity
2006/5/2, Richard Lynch [EMAIL PROTECTED]: Does anybody have a rational explanation for what purpose in life the following syntax is considered acceptable? ?php $query = UPDATE whatever SET x = 1; $query; ? Note that the line with just $query; on it doesn't, like, do anything. I suppose in a Zen-like sort of way, it exists and all, but, really, what's the point? Is there some subtle reason for this not being some kind of syntax error that's way over my head or something? This is not just philosophical minutiae -- Real-world beginners, with no programming experience, actually type the above (albeit with a lot more logic and whatnot in between) and then wonder why the query didn't execute. It even makes a wild sort of sense to type that, if you presume that a beginner might not grasp the distinctions between PHP and MySQL and the relationship yet. Does anybody actually USE this idiom in any meaningful way? ?php string; ? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/ ) To unsubscribe, visit: http://www.php.net/unsub.php I believe this is just C syntax legacy, although I think you can pass an argument to a C compiler to raise a warning when this kind of statements are found, that can't be done in PHP. Anyway, is just the way compiler/interpreters are made when a language has a C syntax style, it's just more efficient for the compiler to do what you're told and don't ask too many questions (if you mess up and your program is slow or buggy is your fault not the compiler's).