php-general Digest 5 Mar 2006 15:06:46 -0000 Issue 3999
php-general Digest 5 Mar 2006 15:06:46 - Issue 3999 Topics (messages 231460 through 231474): [JOB] LAMP Developer, Washington, D.C. | 80k 231460 by: Beau Gould [JOB] LAMP Developers, Los Angeles | 70-120k 231461 by: Beau Gould Re: Prepared statements 231462 by: Julius Hacker 231463 by: Anthony Ettinger 231464 by: Julius Hacker 231467 by: chris smith ¡¶¸ß¶û·ò³¤´ò¾øÕС·¡¶¸ß¶û·òʵսÐÄ·¨¡· 231465 by: znbju6 Re: php/mysql/phpMyAdmin on an iBook? 231466 by: chris smith help with this error message please 231468 by: Mark 231469 by: Mark 231470 by: chris smith Re: Mysql Rows 231471 by: tedd 231472 by: chris smith Re: output Today's date 231473 by: tedd Contact List Grabber 231474 by: Ahmed Abdel-Aliem Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: php-general@lists.php.net -- ---BeginMessage--- LAMP Developer, Washington, D.C. | 80k Candidate must have solid skills and experience in developing robust web applications, using object oriented programming languages and techniques, and possess database design and optimization skills. You will interact with clients, co-workers and managers. Strong ability to partner and work in a fast-paced, collaborative team environment is a must. This is a web programming position, not a web design position. Requirements (please have a majority of these skills): * 2+ years of experience in PHP development * 2+ years experience in MySQL, Oracle, PostgreSQL, Stored Procedures, database management and scripting/development * Object Oriented Programming concepts and application experience * XML, XSL, XSLT, XSL:FO * SQL * JavaScript * CSS * HTML * Familiarity with Linux and/or the UNIX command line * Experience dealing with Apache as a web server * Able to trouble shoot other developers' code To be considered for this position, candidates: MUST live in the tri-state (D.C., VA, MD) area. MUST work on-site at clients Washington, D.C location. MUST be a US Citizen or GC holder If you are interested in this position and live in the DC, VA or MD area, please submit resume, a paragraph or cover letter highlighting your experience as it pertains to this job and your salary requirements to [EMAIL PROTECTED] Linux Jobs: http://groups.yahoo.com/group/linuxjobz Ruby/Rails Jobs: http://groups.yahoo.com/group/rubyrailsjobs Python/Zope Jobs: http://groups.yahoo.com/group/pythonzopejobs Open Source Jobs: http://groups.yahoo.com/group/opensourcejobs LAMP Jobs: http://groups.yahoo.com/group/LAMPjobs -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 268.1.2/274 - Release Date: 3/3/2006 ---End Message--- ---BeginMessage--- LAMP Developers, Los Angeles | 70-120k LAMP Developers needed at all skill levels for multiple Los Angeles clients for full time, on-site jobs ranging from 70-120k + full benefits. Candidates must be authorized to work in the United States and be local to the Los Angeles, CA area. * At least 2 years of professional PHP web development experience * Good to expert knowledge of PHP, including knowledge of OO programming a plus * Strong experience with MySQL/SQL and creating database schemas. * Experience with HTML, CSS and JavaScript. * Knowledge of Unix/Linux. * Knowledge of Apache web server. Please send resume and full time salary requirements to [EMAIL PROTECTED] -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 268.1.2/274 - Release Date: 3/3/2006 ---End Message--- ---BeginMessage--- One other thing: If I do the bind_param within the loop, it just works. The curious is that I have to prepared statements for this loop (one for inserting data and one for updating data) and the one for updating data works and that for inserting don't. Both statements are 100% valid. Julius Hacker wrote: Hi, so I need help again: I want to use prepared statements to insert lots of data in my MySQL-database. For that I use foreach because I have an array containing all necessary information. Before that foreach, I use mysqli_stmt_init, mysql_stmt_prepare and mysql_stmt_bind_param. In the foreach-loop I give the variables, which I bound with bind_param, their values and want to execute the statement. But now MySQL returns always an error. It seems that the values I gave the variables in the loop aren't used because I used bind_param before that. In the example for mysql_bind_param they do it like me. Is the example also wrong or do I have to consider something special? -- Regards Julius Hacker http://www.julius-hacker.de [EMAIL PROTECTED] OpenPGP-Key-ID: 0x4B4A486E
Re: [PHP] Prepared statements
MySQL returns Column 'auction_house' cannot be null. Here're some parts of my code: --- code --- $update = $this-sql-stmt_init(); $update-prepare(UPDATE auctions SET name=?, auction_house=?, link=?, prize=?, runtime=?, bids=?, picture=? WHERE link=?); $update-bind_param(sisdsiss, $auction_parts[name], $auction_house[id], $auction_parts[link], $auction_parts[prize], $auction_parts[runtime], $auction_parts[bids], $auction_parts[picture], $auction_parts[link]); $insert = $this-sql-stmt_init(); $insert-prepare(INSERT INTO auctions (auction_house, name, link, prize, runtime, bids, picture) VALUES (?, ?, ?, ?, ?, ?, ?)); $insert-bind_param(issdsis, $auction_house[id], $auction_parts[name], $auction_parts[link], $auction_parts[prize], $auction_parts[runtime], $auction_parts[bids], $auction_parts[picture]); --- /code --- after this, there's the loop, in which I do either $update-execute(); or $insert-execute(); - the $update-execute(); runs without problems but the $insert-execute runs into the described problem. So at some point the $auction_parts['id'] is empty. As you go into the loop, print out the $auction_house[id], then work backwards... -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help with this error message please
Can anyone tell me why i am getting this message when trying to login to the admin section, i am running the script off my local machine. Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at C:\VertrigoServ\_htdocs\mytipperV4.1\settings.php:2) in C:\VertrigoServ\_htdocs\mytipperV4.1\checkadmin.php on line 44 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help with this error message please
Can anyone tell me why i am getting this message when trying to login to the admin section, i am running the script off my local machine. Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at C:\VertrigoServ\_htdocs\mytipperV4.1\settings.php:2) in C:\VertrigoServ\_htdocs\mytipperV4.1\checkadmin.php on line 44 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with this error message please
On 3/5/06, Mark [EMAIL PROTECTED] wrote: Can anyone tell me why i am getting this message when trying to login to the admin section, i am running the script off my local machine. Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at C:\VertrigoServ\_htdocs\mytipperV4.1\settings.php:2) in C:\VertrigoServ\_htdocs\mytipperV4.1\checkadmin.php on line 44 It tells you the problem: output started at C:\VertrigoServ\_htdocs\mytipperV4.1\settings.php:2 Maybe there's a space or blank line before a php open tag? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql Rows
R O B said: That Rod guy, he's such a card! I'd add something, but Jay has already covered my list in a more recent email than this one to which I'm responding :) jblanchard (who I think is Rod) said: A SQL question on a PHP mailing list usually gets more than ribbing. ;) No harm done -- I been hammered much worse and occasionally for good reason. But you're right, I should have directed my question to a mysql group. I just joined and expanded an ongoing thread on this subject. However, my apologies to the group for going off-PHP just one more time. For sake of argument, let's agree that renumbering dB's is not a good idea -- so if you want to sequentially step through the records, then how do you do it? Thanks -- I do appreciate the feedback (even ribbing). tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql Rows
On 3/6/06, tedd [EMAIL PROTECTED] wrote: R O B said: That Rod guy, he's such a card! I'd add something, but Jay has already covered my list in a more recent email than this one to which I'm responding :) jblanchard (who I think is Rod) said: A SQL question on a PHP mailing list usually gets more than ribbing. ;) No harm done -- I been hammered much worse and occasionally for good reason. But you're right, I should have directed my question to a mysql group. I just joined and expanded an ongoing thread on this subject. However, my apologies to the group for going off-PHP just one more time. For sake of argument, let's agree that renumbering dB's is not a good idea -- so if you want to sequentially step through the records, then how do you do it? The simplest example (most recent to oldest): select * from table order by datefield desc; To get them in the order they were entered: select * from table order by id asc; To get them in reverse order: select * from table order by id desc; Depends what data you have and what you are trying to do exactly. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] output Today's date
Hi all, ls there anyway I can set the date to the timezone of the clients timezone? For example, if a person opens the web page at 3/6 12:01 EST and another person opens the same page at 3/5 10:01 MST I would like the date to be the above days on the client computers. I know everyone knows this but the way I described this the two people accessed the webpage at the same time but I want the correct date for the client computer to be outputted. Thank you, Paul Paul: You might look into strftime() Also: http://www.weberdev.com/get_example-3289.html http://www.weberdev.com/get_example-471.html tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Contact List Grabber
Hi i would like to make a script to import contact list from msn, yahoo and gmail instant messenger. any ideas or tutorial on how to do that. any help will be appreciated thanks in advance -- Ahmed Abdel-Aliem Web Developer www.SafariStudio.net +20101108551 registered Linux user number 382789 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] output Today's date
[snip] ls there anyway I can set the date to the timezone of the clients timezone? For example, if a person opens the web page at 3/6 12:01 EST and another person opens the same page at 3/5 10:01 MST I would like the date to be the above days on the client computers. I know everyone knows this but the way I described this the two people accessed the webpage at the same time but I want the correct date for the client computer to be outputted. [/snip] A client side problem requires a client side solution, you will need JavaScript to do this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Mysql Rows
[snip] R O B said: That Rod guy, he's such a card! I'd add something, but Jay has already covered my list in a more recent email than this one to which I'm responding :) jblanchard (who I think is Rod) said: [/snip] I am definitely not Rod. [snip] For sake of argument, let's agree that renumbering dB's is not a good idea -- so if you want to sequentially step through the records, then how do you do it? [/snip] You must have a column that is sequential in some way. An auto-incremented column, timestamp, or some other device that will allow you to step through regardless of gaps in sequence. If you do not have such a column then you could add one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: DOMElement::setAttribute() manual example question
Hi Rob! Rob wrote: ?php $doc = new DOMDocument(1.0); $node = $doc-createElement(root); $node-setAttribute(align, left); $doc-appendChild($node); echo $doc-saveXML(); ? Both ways are perfectly valid. $node and $newnode refer to the same object. It was written the 1st way to demonstrate the return value of appendChild(), because in many cases people create the element differently. i.e. $newnode = $doc-appendChild($doc-createElement(root)); or $newnode = $doc-appendChild(new DOMElement(root)); Thank you very much for confirming that! I was not sure if it's really the same. Also, in the event $node is created using the new DOMElement syntax: $node = new DOMElement(root); the node is read only and must be appended into the tree before it can be modified, so the example just tries to be neutral here regarding the syntax used. $node = new DOMElement(root); is read only, while $node = $doc-createElement(root); is not? Why? btw., I think this: http://news.php.net/php.internals/22117 is a very, very, very good idea! I hope the patch will make it into core soon! best regards Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: DOMElement::setAttribute() manual example question
Andreas Korthaus wrote: $node = new DOMElement(root); is read only, while $node = $doc-createElement(root); is not? Why? $node = new DOMElement(root); In this case the element is not associated with a document. In DOM, you really aren't supposed to have a node not associated with any document, but this syntax allows the DOM classes to be extended in PHP. Once the node is associated with a document, you then have full editing capabilities. Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prepared statements
chris smith wrote: So at some point the $auction_parts['id'] is empty. As you go into the loop, print out the $auction_house[id], then work backwards... I output already some variables in the loop and all are set with correct values. As I said, if I do the bind_param inside the loop it works without problems. So there's a difference in doing it before the loop and inside the loop causing this problem. -- Regards Julius Hacker http://www.julius-hacker.de [EMAIL PROTECTED] OpenPGP-Key-ID: 0x4B4A486E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql Rows
On Sun, Mar 05, 2006 at 08:01:07AM -0500, tedd wrote: R O B said: That Rod guy, he's such a card! I'd add something, but Jay has already covered my list in a more recent email than this one to which I'm responding :) jblanchard (who I think is Rod) said: A SQL question on a PHP mailing list usually gets more than ribbing. ;) So, Jay is Rod, who is this Rob person? Now I'm really confused. Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [JOB] LAMP Developers, Los Angeles | 70-120k
Maybe I'm being hypocritic, and possibly wouldn't have this problem, if it was a job that only EU Citizens(as opposed to only US Citizens) could apply for, but I think it's a bit disrespectful, sending mails like this to an international audience - especially when you send so many of them. On 3/5/06, Beau Gould [EMAIL PROTECTED] wrote: LAMP Developers, Los Angeles | 70-120k LAMP Developers needed at all skill levels for multiple Los Angeles clients for full time, on-site jobs ranging from 70-120k + full benefits. Candidates must be authorized to work in the United States and be local to the Los Angeles, CA area. * At least 2 years of professional PHP web development experience * Good to expert knowledge of PHP, including knowledge of OO programming a plus * Strong experience with MySQL/SQL and creating database schemas. * Experience with HTML, CSS and JavaScript. * Knowledge of Unix/Linux. * Knowledge of Apache web server. Please send resume and full time salary requirements to [EMAIL PROTECTED] -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 268.1.2/274 - Release Date: 3/3/2006 -- PHP General Mailing List ( http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql/phpMyAdmin on an iBook?
I'm thinking of getting an iBook for reasons not really to do with webbing but really need to do occasional php/mysql stuff to justify the expense. I believe that they all come with an Apache testing server installed and wondered if anyone had any success with getting php/mysql/phpMyAdmin working on one of these machines. No problem at all. Mac OS X comes with PHP installed (but not activated). There are precompiled binaries of both PHP and MySQL available from www.entropy.ch and mysql.com, respectively. phpMyAdmin runs on anything that can run PHP and MySQL. No problem at all! Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [JOB] LAMP Developers, Los Angeles | 70-120k
Job postings dont really belong on this list, expecially ones that appear on a regular basis for a paticular company. Consider what would happen if sites like dice.org, monster.com, etc... started posting positions that matched the keyword 'php' on a regular basis. Curt. On Sun, Mar 05, 2006 at 06:56:52PM +0100, Rory Browne wrote: Maybe I'm being hypocritic, and possibly wouldn't have this problem, if it was a job that only EU Citizens(as opposed to only US Citizens) could apply for, but I think it's a bit disrespectful, sending mails like this to an international audience - especially when you send so many of them. On 3/5/06, Beau Gould [EMAIL PROTECTED] wrote: LAMP Developers, Los Angeles | 70-120k LAMP Developers needed at all skill levels for multiple Los Angeles clients for full time, on-site jobs ranging from 70-120k + full benefits. Candidates must be authorized to work in the United States and be local to the Los Angeles, CA area. * At least 2 years of professional PHP web development experience * Good to expert knowledge of PHP, including knowledge of OO programming a plus * Strong experience with MySQL/SQL and creating database schemas. * Experience with HTML, CSS and JavaScript. * Knowledge of Unix/Linux. * Knowledge of Apache web server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] output Today's date
On Sat, Mar 04, 2006 at 07:01:55PM -0700, Paul Goepfert wrote: Hi all, ls there anyway I can set the date to the timezone of the clients timezone? For example, if a person opens the web page at 3/6 12:01 EST and another person opens the same page at 3/5 10:01 MST I would like the date to be the above days on the client computers. I know everyone knows this but the way I described this the two people accessed the webpage at the same time but I want the correct date for the client computer to be outputted. There are some tools that you can detect where the person is located and and you would be able to use the timezone from that information. One site I found from a quick google search: http://www.ip2location.com/ The cheapest and simpliest method would be to use some javascript to detect the timezone. Or let the user specify which one he wants to use. Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prepared statements
On Sun, Mar 05, 2006 at 04:03:17AM +0100, Julius Hacker wrote: On 3/4/06, Julius Hacker [EMAIL PROTECTED] wrote: Before that foreach, I use mysqli_stmt_init, mysql_stmt_prepare and mysql_stmt_bind_param. In the foreach-loop I give the variables, which I bound with bind_param, their values and want to execute the statement. But now MySQL returns always an error. It seems that the values I gave the variables in the loop aren't used because I used bind_param before that. In the example for mysql_bind_param they do it like me. Is the example also wrong or do I have to consider something special? ... MySQL returns Column 'auction_house' cannot be null. Here're some parts of my code: --- code --- ... $insert = $this-sql-stmt_init(); $insert-prepare(INSERT INTO auctions (auction_house, name, link, prize, runtime, bids, picture) VALUES (?, ?, ?, ?, ?, ?, ?)); $insert-bind_param(issdsis, $auction_house[id], $auction_parts[name], $auction_parts[link], $auction_parts[prize], $auction_parts[runtime], $auction_parts[bids], $auction_parts[picture]); --- /code --- I assume your loop is something like: while(condition) { $auction_parts['id'] = 'some value'; $auction_parts['name'] = 'some value'; ... $insert-execute(); } My first guess would be, if not aleady done, initialize $auction_parts before you do your bind_param() with something like: $auction_parts = array('id' = null, 'name' = null, ...); $insert-bind_param(issdsis, $auction_house[id], ...); Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] simplify DOM api
Hi Rob! Rob wrote: $node = new DOMElement(root); In this case the element is not associated with a document. In DOM, you really aren't supposed to have a node not associated with any document, but this syntax allows the DOM classes to be extended in PHP. Once the node is associated with a document, you then have full editing capabilities. Again, very helpful information - thanks a lot! I have to do something like: ?php $array_of_book_objects = array('...'); $doc = new DOMDocument('1.0'); $books = $doc-appendChild(new DOMElement('books')); foreach($array_of_book_objects as $book_data) { $book = $books-appendChild(new DOMElement('book')); $book-setAttribute('isbn', xml_entity_encode($book_data-isbn)); $book-appendChild(new DOMElement('title', xml_entity_encode($book_data-title))); $book-appendChild(new DOMElement('description', xml_entity_encode($book_data-description))); $author = $book-appendChild(new DOMElement('author')); $author-appendChild(new DOMElement('name', xml_entity_encode($book_data-author_name))); } echo $doc-saveXML(); ? Because my script is by far more complex (but does not use more advanced DOM features), I'd like to simplify the DOM api a little bit more. With extending DOMElement I think I have found a nice way: ?php class SimpleDOMElement extends DOMElement { function addChild($name, $value=NULL) { if (is_null($value)) { return $this-appendChild(new SimpleDOMElement($name)); } else { return $this-appendChild(new SimpleDOMElement($name, xml_entity_encode($value))); } } function addAttribute($name, $value) { return $this-setAttribute($name, xml_entity_encode($value)); } } class Books extends DOMDocument { private $books_element; function __construct() { parent::__construct('1.0'); $this-books_element = $this-appendChild( new SimpleDOMElement('books')); } function addBook($book_object) { $book = $this-books_element-addChild('book'); $book-addAttribute('isbn', $book_object-isbn); $book-addChild('title', $book_object-title); $book-addChild('description', $book_object-description); $author = $book-addChild('author'); $author-addChild('name', $book_object-author_name); } } $array_of_book_objects = array('...'); $books = new Books; foreach ($array_of_book_objects as $book_data) { $books-addBook($book_data); } echo $books-saveXML(); ? I think this should be OK, or shouldn't I do it this way? Perhaps you have seen that I've used a xml_entity_encode() function. This function works like htmlspecialchars(), but replaces ' with apos; and not #039;. Or do all of you use htmlspecialchars()? Does it work with Unicode strings? best regards Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prepared statements
On 3/5/06, Curt Zirzow [EMAIL PROTECTED] wrote: On Sun, Mar 05, 2006 at 04:03:17AM +0100, Julius Hacker wrote: On 3/4/06, Julius Hacker [EMAIL PROTECTED] wrote: Before that foreach, I use mysqli_stmt_init, mysql_stmt_prepare and mysql_stmt_bind_param. In the foreach-loop I give the variables, which I bound with bind_param, their values and want to execute the statement. But now MySQL returns always an error. It seems that the values I gave the variables in the loop aren't used because I used bind_param before that. In the example for mysql_bind_param they do it like me. Is the example also wrong or do I have to consider something special? ... MySQL returns Column 'auction_house' cannot be null. Here're some parts of my code: --- code --- ... $insert = $this-sql-stmt_init(); $insert-prepare(INSERT INTO auctions (auction_house, name, link, prize, runtime, bids, picture) VALUES (?, ?, ?, ?, ?, ?, ?)); $insert-bind_param(issdsis, $auction_house[id], $auction_parts[name], $auction_parts[link], $auction_parts[prize], $auction_parts[runtime], $auction_parts[bids], $auction_parts[picture]); --- /code --- I assume your loop is something like: while(condition) { $auction_parts['id'] = 'some value'; $auction_parts['name'] = 'some value'; ... $insert-execute(); } My first guess would be, if not aleady done, initialize $auction_parts before you do your bind_param() with something like: $auction_parts = array('id' = null, 'name' = null, ...); $insert-bind_param(issdsis, $auction_house[id], ...); Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php might want to read up on bind_param. I'ts been awhile since I did this in Perl. -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How can I tell if an output stream is finished?
I have a page that resizes an image to be included in a html page, using: echo img src=\$rel_mapfile\ alt=\Course Map\\n; unlink($rel_mapfile); I need the other html stuff on the page so I need to fetch a file from the server to include in the page. So, I resized the image and saved it as a file. That works fine. After sending the temporary resized file I want to delete it. Obviously, an unlink($rel_mapfile) is executed before the echo img src=\$rel_mapfile\ ... is finished. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] create xml root-element with xmlns and xsd link (using DOM)
Hi! The XML-Code I have to create (http://news.php.net/php.general/231486), needs a root-element, with xmlns and XML schema link, something like that: Test xmlns=http://example.com/test; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://example.com/test test.xsd Does DOM provide any means to add a XML schema link to the doc? Now I'm doing it this way (which seems to work): ?php $doc = new DOMDocument; $root = $doc-appendChild(new DOMElement('root', NULL, 'http://example.com/test')); $root-setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', 'http://example.com/test test.xsd'); echo $doc-savexml(); ? Does DOM provide nothing else? Does anybody see any problems with this approach? Best regards Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I tell if an output stream is finished?
I don't think you can. Each element in a web page is transmited over a separate connection, when the browser parses an included element, such as an image, an iframe, a stylesheet, an included script file or whatever, it opens a new connection to the server (or another server in the same domain) and from then on, they run completely asychronous, any of them can finish at any time, depending on many factors completely out of you control (such as caching so that an element might be taken from the local cache instead of picked from the server, which wouldn't be the case with dinamically generated images as your situation, but I mention it just as an example). So, the answer to the question in the subject line is no, you cannot, the thread serving your main HTML document might end before the server even started serving the included image, or the other way around, and once your script if finished, you have no further control. Holding your script until the image is served might get it hang forever, since the image might not even be requested, if taken from the browser cache on the client side, so you might be waiting forever. If you want to clean up dynamically generated files, you have to do it via a cron job every so often. Another alternative is serving the included images via a separate script, thus you would have to have: echo 'img src=imageserver.php?img=' , urlencode($rel_mapfile) , ' alt=Course Map' , CRLF; Then imageserver.php would pick the image, serve it and when it is finished you delete it, nevertheless, this takes more CPU time, so I would still take the other option. If you can attach a script to the end of a session, and you put all dynamically generated content under a directory named after the SessionId, when the session is over, you delete the complete directory with everything it had. (I know IIS does that, but I never had to manage an Apache server, someone can help on that?). This one doesn't take any overhead on a per-page basis, just once per session and keeps the disk storage clean. Just some sugestions, I hope they help. Satyam - Original Message - From: Al [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Sunday, March 05, 2006 9:17 PM Subject: [PHP] How can I tell if an output stream is finished? I have a page that resizes an image to be included in a html page, using: echo img src=\$rel_mapfile\ alt=\Course Map\\n; unlink($rel_mapfile); I need the other html stuff on the page so I need to fetch a file from the server to include in the page. So, I resized the image and saved it as a file. That works fine. After sending the temporary resized file I want to delete it. Obviously, an unlink($rel_mapfile) is executed before the echo img src=\$rel_mapfile\ ... is finished. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I tell if an output stream is finished?
Many thinks for your input... The sessions approach seems like a good one. Since posting my question, I thought of writing the file in a tmp dir and using it. Then scan the tmp dir for all files older than an hour or so and unlinking them. Sorta like a cron job without the extra effort. Our site has a low usage so there will never be many obsolete files in the temp dir. Again, thanks Satyam wrote: I don't think you can. Each element in a web page is transmited over a separate connection, when the browser parses an included element, such as an image, an iframe, a stylesheet, an included script file or whatever, it opens a new connection to the server (or another server in the same domain) and from then on, they run completely asychronous, any of them can finish at any time, depending on many factors completely out of you control (such as caching so that an element might be taken from the local cache instead of picked from the server, which wouldn't be the case with dinamically generated images as your situation, but I mention it just as an example). So, the answer to the question in the subject line is no, you cannot, the thread serving your main HTML document might end before the server even started serving the included image, or the other way around, and once your script if finished, you have no further control. Holding your script until the image is served might get it hang forever, since the image might not even be requested, if taken from the browser cache on the client side, so you might be waiting forever. If you want to clean up dynamically generated files, you have to do it via a cron job every so often. Another alternative is serving the included images via a separate script, thus you would have to have: echo 'img src=imageserver.php?img=' , urlencode($rel_mapfile) , ' alt=Course Map' , CRLF; Then imageserver.php would pick the image, serve it and when it is finished you delete it, nevertheless, this takes more CPU time, so I would still take the other option. If you can attach a script to the end of a session, and you put all dynamically generated content under a directory named after the SessionId, when the session is over, you delete the complete directory with everything it had. (I know IIS does that, but I never had to manage an Apache server, someone can help on that?). This one doesn't take any overhead on a per-page basis, just once per session and keeps the disk storage clean. Just some sugestions, I hope they help. Satyam - Original Message - From: Al [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Sunday, March 05, 2006 9:17 PM Subject: [PHP] How can I tell if an output stream is finished? I have a page that resizes an image to be included in a html page, using: echo img src=\$rel_mapfile\ alt=\Course Map\\n; unlink($rel_mapfile); I need the other html stuff on the page so I need to fetch a file from the server to include in the page. So, I resized the image and saved it as a file. That works fine. After sending the temporary resized file I want to delete it. Obviously, an unlink($rel_mapfile) is executed before the echo img src=\$rel_mapfile\ ... is finished. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql Rows
- Original Message - From: tedd [EMAIL PROTECTED] To: php-general@lists.php.net Cc: Gustav Wiberg [EMAIL PROTECTED]; Robert Cummings [EMAIL PROTECTED] Sent: Sunday, March 05, 2006 12:58 AM Subject: Re: [PHP] Mysql Rows Hi: Gustav said: No, maybe not when it's a small db, but when you try to delete 50.000 posts I have a strong feeling this would be very much slower then if you don't alter table after each deletion. First, I'm not deleting 50,000 records -- I dropping a table and renumbering it. In any event, I just tested your claim on my host and I was able to renumber 50,000 records in less than 1/2 second. Even though I tried it several times, the results were never above 0.47 seconds. If I was dealing with a database that was accessible to others, then I would either lock tables or use transaction and then renumber -- but in either case the difference in time is less than additional 1/10 of a second. Ok, it wasn't really a claim, it was more a feeling, but I couldn't say it for sure, so I applogize for misleading you there! :-) Half a second or 0.47 seconds may not be a big issue, but as I see it this could be unessescary time, if you could achieve the same functionality (without doing some alter-statements) faster and without have to lock the db. Have you tested without the alter-table statement? *just curious* Aha... I missed the part ... I was dealing with a database that was accessible to others Only YOU are using the db? Ok, then it would not be a problem. I don't know if 1/2 second is a big deal in your world, or not, but it seems a bit slow to me. I wrote splay binary tree search routine that would perform 100,000 searches in a two million record dB in less than one second on my Mac. And if you know what a splay algorithm is, then you also know that it not only preforms a search but then reorders the tree each time a search is successful and thus is very laborious. Yet the time it took to preform 100,000 searches and reorders was still less than one second. Perhaps my host is running something slower -- after all, I'm only paying $7.00 per year for the service. But with all things considered, a half second is not that significant with a small 50,000 record dB. That's probably less than the majority of web sites that use MySQL, don't you think? Ok, I got your point! :-) But there is another side to it , and that is scalability. Ok, you don't have so many posts in your database. Ok, it does take less then a second... What if you had do make the db visible to other users? Then this link that might intrest you: (it's about pitfalls with transactions as may see in the link) http://www.onlamp.com/pub/a/php/2003/12/18/transaction_pitfalls.htmlhttp://www.onlamp.com/pub/a/php/2003/12/18/transaction_pitfalls.html But what If you suddenly hade to change host for some reason... The new host server maybe wouldn't be as fast as yours is today. And as someone mentioned, what about if your db was growing to include a couple of million posts. Of course, if you don't think your db will grow so much, and it works fine, then of course you could contiuning doing the ALTER-statement thing, but there's always two sides of the story... ;-) That's probably less than the majority of web sites that use MySQL, don't you think? I really have no clue, I could only guess... :-) Rod said: *LOL* I knew those MySQL people shouldn't have made the ALTER TABLE syntax available to just anyone. Gun -- foot -- *BLAM*. I hope to God you never get your hands on a real database with millions of entries. I'm glad that you were amused. Considering that I was talking about a flat dB, then you have already shot yourself in the foot if your real database is in the millions of entries and is flat. I hope to God that normalization may be something you consider in your next database design. In any event, it's interesting that I posted a question here and I expected some ribbing, but I also expected something of value. If the ALTER TABLE statement is prone to error, then I would like to know that and why. However, I suspect that claim isn't true, it's just that it's misuse has generated an urban myth of Don't do that! That's dangerous! without any real substance other than for programer error. *LOL* I have to say, that I agree with you on this one. I've searched on issues/regarding ALTER TABLE, and could only find errors regarding this when Microsoft was involved ;-) Of course, I've run into windozes programmers who accept the occasional crash and burn as it comes with the territory, but that's unfortunate to apply this apprehension to MySQL. :-) In my previous post I pleaded for someone to point out the error of my ways and to give me an alternative, but that hasn't happened yet -- so, does anyone want to tell me why I should not renumber a flat database and give me an alternative? I'm all ears... I have thought of this... ...but isn't