php-general Digest 14 Oct 2008 09:43:21 -0000 Issue 5734

Topics (messages 281837 through 281848):

Pure PHP Templating Class/AJAX Problem
        281837 by: Tom Shaw
        281844 by: Yeti

Re: How to know what current system is?
        281838 by: Shawn McKenzie
        281839 by: Tom Shaw

Csv issue
        281840 by: admin.buskirkgraphics.com
        281841 by: bruce
        281842 by: Ashley Sheridan
        281843 by: Shawn McKenzie

Sphinx Open Source Text Based Search
        281845 by: Hemant Patel
        281848 by: Stut

Re: Little regex help please...
        281846 by: Richard Heyes

Re: New to PHP
        281847 by: David Robley

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:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
I use a pure templating class similar to something that I found here
http://www.talkphp.com/advanced-php-programming/2568-pure-php-template-class
.html.  My question is how do you handle AJAX requests from XMLHttpRequest
(); My class pumps out the entire page over again after the AJAX request is
made. In other words the page is displaying twice. 

 

Thanks

 

 

Tom Shaw

[EMAIL PROTECTED]

 

"Common sense is the knack of seeing things as they are, and doing things as
they ought to be done." 

Harriet
<http://www.coolquotes.com/categories/harriet_elizabeth_beecher_stowe.html>
Elizabeth Beecher Stowe

 


--- End Message ---
--- Begin Message ---
Well after looking at the template thing you posted with your link it
seems to me like PHP is used to create working XML. So i wonder why
you are using AJAX here.
Now could it be that you use appendChild() ? That function would
simply add the XML again.

It's not easy to tell if you are not showing the JavaScript code ..
Still it simply depends on how you are importing the node you get from
XMLHttpRequest() or responseXML

Btw. importNode() is not working on all Browsers ..
Below is a code snipped I use for my AJAX class in JavaScript to copy
a node of one XML document (like from responseXML) into another. It
works in IE6+ and all W3C compliant browsers.
To make this work you will still have to make some ajustments.

xml_obj.prototype.xml_import_node = function(node, to_node,
all_children) { // cross browser importNode, NOTE: if toNode not
specified it will be set to current root_element
// appends node as a child to to_node
        // if all_children is true then all child nodes will be imported too
        /* NOTE TYPES:
        ELEMENT_NODE = 1;
        ATTRIBUTE_NODE = 2;
        TEXT_NODE = 3;
        CDATA_SECTION_NODE = 4;
        ENTITY_REFERENCE_NODE = 5;
        ENTITY_NODE = 6;
        PROCESSING_INSTRUCTION_NODE = 7;
        COMMENT_NODE = 8;
        DOCUMENT_NODE = 9;
        DOCUMENT_TYPE_NODE = 10;
        DOCUMENT_FRAGMENT_NODE = 11;
        NOTATION_NODE = 12;
        */
        if (!node) return false;
        if (!this.DOC) this.DOC = document;
        if (!to_node.nodeType) {
                if (!this.XML) return false;
                try {
                        to_node = this.XML.documentElement;
                        this.DOC = this.XML;
                } catch(e) {
                        return false;
                }
        }
        try {
                if (!node.nodeType) return false;
                switch (node.nodeType) {
                                case 1: // new element
                                        var new_node = 
this.DOC.createElement(node.nodeName);
                                        if (node.attributes && 
(node.attributes.length > 0)) { // if it
has attributes
                                                for (var count = 0; (count < 
node.attributes.length); count++) {
                                                        
this.xml_import_node(node.attributes[count], new_node);
                                                }
                                        }
                                        if (all_children && (node.childNodes && 
(node.childNodes.length >
0))) { // if child nodes
                                                var dump = null;
                                                for (var count = 0; (count < 
node.childNodes.length); count++) {
                                                        
this.xml_import_node(node.childNodes[count], new_node, true);
                                                }
                                        }
                                        to_node.appendChild(new_node);
                                        return new_node;
                                        break;
                                case 2: // new attribute
                                        var name = node.nodeName;
                                        switch (node.nodeName.toLowerCase()) {
                                                case 'onload':
                                                case 'onunload':
                                                case 'onblur':
                                                case 'onclick':
                                                case 'ondblclick':
                                                case 'onfocus':
                                                case 'onkeydown':
                                                case 'onkeypress':
                                                case 'onkeyup':
                                                case 'onmousedown':
                                                case 'onmousemove':
                                                case 'onmouseout':
                                                case 'onmouseover':
                                                case 'onmouseup':
                                                        var eval_code = 
'to_node.'+node.nodeName.toLowerCase();
                                                        eval_code += ' = 
function() { '+node.nodeValue+' };';
                                                        eval(eval_code);
                                                        break;
                                                case 'style':
                                                        to_node.style.cssText = 
node.nodeValue; // IE FIX
                                                        // no break
                                                case 'class':
                                                        to_node.className = 
node.nodeValue; //IE FIX
                                                        // no break
                                                default:
                                                        
to_node.setAttribute(node.nodeName, node.nodeValue);
                                        }
                                        return to_node;
                                        break;
                                case 3: // new text_node
                                case 4: // new cdata section
                                case 8: // new comment node
                                        
to_node.appendChild(this.DOC.createTextNode(node.nodeValue));
                                        return to_node;
                                        break;
                                case 5: // new entity reference
                                case 6: // new entity node
                                case 7: // new processing instruction
                                case 9: // new document node
                                case 10: // new document type node
                                case 11:  // new fragment node
                                case 12: // new notation node
                                        return null; // not needed. if you want 
it then implement it
                                        break;
                                default: return false;
                }
        } catch(e) {
                alert(e.message);
                return false;
        }
}

--- End Message ---
--- Begin Message ---
Jiang Miao wrote:
> Is there any function do that?
> when php in Linux it returns linux
> in windows it returns windows
> 
> I found phpinfo(INFO_GENERAL); output the string System => Linux ubuntu
> 2.6.24-19-server. but I have no idea to get that info.
> 
> Thanks
> Jiang Miao
> 

PHP_OS constant.

-Shawn

--- End Message ---
--- Begin Message ---
You can try, $_SERVER['SERVER_SOFTWARE']

-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Jiang Miao
Sent: Monday, October 13, 2008 3:44 PM
To: [EMAIL PROTECTED]
Subject: [PHP] How to know what current system is?

Is there any function do that?
when php in Linux it returns linux
in windows it returns windows

I found phpinfo(INFO_GENERAL); output the string System => Linux ubuntu 
2.6.24-19-server. but I have no idea to get that info.

Thanks
Jiang Miao


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
I am using a form to select a csv file and then import it into mysql and maybe 
im just drawling a blank here. But why is it blowing up.
This thing loads like 14 million records into the database and I am clue less 
how it can do that with a 2 record csv file.

<form enctype='multipart/form-data' action=? method=post>
Upload:<input type=file name=filename>
<input type=submit value='Upload'></form>


$row = 1;
$filename = $_POST['filename'];
$handle = fopen("$filename", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
}
fclose($handle);
print "Import done";

This will produce millions of lines until i go in and stop the process on the 
server. I know its stupid but im drawling a blank as to why its doing this. The 
csv file has 2 lines in period. 
<p> 0 fields in line 1: <br /></p>
<p> 0 fields in line 2: <br /></p>
ect for millions of records.

--- End Message ---
--- Begin Message ---
hi...

as a test... using the cli php... try to write a short app to read a file that 
simulates your input csv file, and then writes it out as well...

once you do this, you'll know you have the logic to read/write/manipulate the 
csv file.

after you can do this, go ahead and then create/work with a app to read a csv 
file from the user/input/form data from a test website.

finally, after you're sure of your ability to manipulate the csv file 
(read/write) than create the mysql process to insert the data..

you'll get it in no time...



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, October 13, 2008 2:56 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Csv issue


I am using a form to select a csv file and then import it into mysql and maybe 
im just drawling a blank here. But why is it blowing up.
This thing loads like 14 million records into the database and I am clue less 
how it can do that with a 2 record csv file.

<form enctype='multipart/form-data' action=? method=post>
Upload:<input type=file name=filename>
<input type=submit value='Upload'></form>


$row = 1;
$filename = $_POST['filename'];
$handle = fopen("$filename", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
}
fclose($handle);
print "Import done";

This will produce millions of lines until i go in and stop the process on the 
server. I know its stupid but im drawling a blank as to why its doing this. The 
csv file has 2 lines in period. 
<p> 0 fields in line 1: <br /></p>
<p> 0 fields in line 2: <br /></p>
ect for millions of records.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
On Mon, 2008-10-13 at 15:02 -0700, bruce wrote:
> hi...
> 
> as a test... using the cli php... try to write a short app to read a file 
> that simulates your input csv file, and then writes it out as well...
> 
> once you do this, you'll know you have the logic to read/write/manipulate the 
> csv file.
> 
> after you can do this, go ahead and then create/work with a app to read a csv 
> file from the user/input/form data from a test website.
> 
> finally, after you're sure of your ability to manipulate the csv file 
> (read/write) than create the mysql process to insert the data..
> 
> you'll get it in no time...
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 13, 2008 2:56 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Csv issue
> 
> 
> I am using a form to select a csv file and then import it into mysql and 
> maybe im just drawling a blank here. But why is it blowing up.
> This thing loads like 14 million records into the database and I am clue less 
> how it can do that with a 2 record csv file.
> 
> <form enctype='multipart/form-data' action=? method=post>
> Upload:<input type=file name=filename>
> <input type=submit value='Upload'></form>
> 
> 
> $row = 1;
> $filename = $_POST['filename'];
> $handle = fopen("$filename", "r");
> while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
> {
> $num = count($data);
> echo "<p> $num fields in line $row: <br /></p>\n";
> $row++;
> }
> fclose($handle);
> print "Import done";
> 
> This will produce millions of lines until i go in and stop the process on the 
> server. I know its stupid but im drawling a blank as to why its doing this. 
> The csv file has 2 lines in period. 
> <p> 0 fields in line 1: <br /></p>
> <p> 0 fields in line 2: <br /></p>
> ect for millions of records.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
I had this happen when trying to read in a binary file as a CSV. Are you
sure that the file is a CSV, and if so, is it delimited in the way you
expect? 


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
> I am using a form to select a csv file and then import it into mysql and 
> maybe im just drawling a blank here. But why is it blowing up.
> This thing loads like 14 million records into the database and I am clue less 
> how it can do that with a 2 record csv file.
> 
> <form enctype='multipart/form-data' action=? method=post>
> Upload:<input type=file name=filename>
> <input type=submit value='Upload'></form>
> 
> 
> $row = 1;
> $filename = $_POST['filename'];
> $handle = fopen("$filename", "r");
> while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
> {
> $num = count($data);
> echo "<p> $num fields in line $row: <br /></p>\n";
> $row++;
> }
> fclose($handle);
> print "Import done";
> 
> This will produce millions of lines until i go in and stop the process on the 
> server. I know its stupid but im drawling a blank as to why its doing this. 
> The csv file has 2 lines in period. 
> <p> 0 fields in line 1: <br /></p>
> <p> 0 fields in line 2: <br /></p>
> ect for millions of records.
Try:

print_r(file($_POST['filename']));

And see if you get what you expect.  You might also want to have
error_reporting at its highest and display_errors also.

-Shawn

--- End Message ---
--- Begin Message ---
Hello Everyone,                         I want to configure my text based
search with sphinx Search in PHP.Can anybody give any link to explore it
other than its own site.(Other Than Documentation....).I want to learn
thorough process followed by sphinx...How indexing and searching happen
in sphinx...?


With Regards,
Hemant Patel

--- End Message ---
--- Begin Message ---
On 14 Oct 2008, at 08:03, Hemant Patel wrote:
Hello Everyone, I want to configure my text based search with sphinx Search in PHP.Can anybody give any link to explore it
other than its own site.(Other Than Documentation....).I want to learn
thorough process followed by sphinx...How indexing and searching happen
in sphinx...?

Indexing happens in Sphinx, PHP does not get involved in that.

If you're having trouble following the official documentation I suggest you read the following article which introduces the core concepts in a tutorial format...

  http://www.ibm.com/developerworks/library/os-php-sphinxsearch/

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
> /http:\/\/www\.asdf\.com\/blah\/foobar\.php/i ... looks like a zig-zaggy 
> mess. :)

Perhaps it was meant to... :-)

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org

--- End Message ---
--- Begin Message ---
Juan Jose Rosales Rodriguez wrote:

> He i not speak very good englis, pliss can you tel me abaout list in
> spanich?

News version at news://news.php.net/php.general.es or via http at
http://news.php.net/group.php?group=php.general.es



Cheers
-- 
David Robley

Useless Invention: Self stick frying pan.
Today is Boomtime, the 68th day of Bureaucracy in the YOLD 3174. 


--- End Message ---

Reply via email to