php-general Digest 17 Aug 2009 05:24:10 -0000 Issue 6289

2009-08-16 Thread php-general-digest-help
php-general Digest 17 Aug 2009 05:24:10 - Issue 6289 Topics (messages 296836 through 296865): Re: Issue with the huge import script 296836 by: Phpster Re: How do I extract link text from anchor tag as well as the URL from the href attribute 296837 by: chrysanhy

[PHP] How do I extract link text from anchor tag as well as the URL from the href attribute

2009-08-16 Thread chrysanhy
I have the following code to extract the URLs from the anchor tags of an HTML page: $html = new DOMDocument(); $htmlpage-loadHtmlFile($location); $xpath = new DOMXPath($htmlpage); $links = $xpath-query( '//a' ); foreach ($links as $link) { $int_url_list[$i++] = $link-getAttribute( 'href' ) . \n;

Re: [PHP] Another date exercise

2009-08-16 Thread Lester Caine
tedd wrote: Hi gang: Here's another exercise to consider. This is a date entry problem where the user can enter a date in various forms, but the return will be in a consistent format. For example, a user might enter a date in the form of: August 5, 2009 Aug 05 2009 Aug 5, 9 08/05/09 8-5-9

[PHP] Re: How do I extract link text from anchor tag as well as the URL from the href attribute

2009-08-16 Thread Ralph Deffke
try $link-nodeValue() or $link-getContent() im not shure which one works on an image link which is indeed a child of a so u could also check if the node has a child, if so its an image with, in good practice. an alt attribute to use haven't tried but should work. let me know pls

Re: [PHP] Re: Issue with the huge import script

2009-08-16 Thread Ashley Sheridan
On Sun, 2009-08-16 at 04:06 +0200, Ralph Deffke wrote: Hi, this sounds huge, and cries for a sql version of the import. Are both databases the same? MySQL? I give u a draft for MySQL u export the data u have, then u got a textfile with 10+ sql statments in the php script u open the

Re: [PHP] Another date exercise

2009-08-16 Thread Ashley Sheridan
On Sun, 2009-08-16 at 08:36 +0100, Lester Caine wrote: tedd wrote: Hi gang: Here's another exercise to consider. This is a date entry problem where the user can enter a date in various forms, but the return will be in a consistent format. For example, a user might enter a date

Re: [PHP] Re: Issue with the huge import script

2009-08-16 Thread Ralph Deffke
because I assume always that a requester got some intelligence, so in that case there must be a reasonsble reason why he wants to do it in PHP im not like u assuming everybody is a thumb ralph Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1250413427.2344.51.ca...@localhost...

Re: [PHP] Re: Issue with the huge import script

2009-08-16 Thread Ashley Sheridan
On Sun, 2009-08-16 at 11:05 +0200, Ralph Deffke wrote: because I assume always that a requester got some intelligence, so in that case there must be a reasonsble reason why he wants to do it in PHP im not like u assuming everybody is a thumb ralph Ashley Sheridan

Re: [PHP] Re: Issue with the huge import script

2009-08-16 Thread Ralph Deffke
so then tell me tell me what my first sentence means this sounds huge, and cries for a sql version of the import. it looks like u have no experience in working as consultant hotlines Ash first the folk is asking for a sulotion of HIS php implying a general solution in PHP with a hint to the

Re: [PHP] Re: Issue with the huge import script

2009-08-16 Thread Ashley Sheridan
On Sun, 2009-08-16 at 11:25 +0200, Ralph Deffke wrote: so then tell me tell me what my first sentence means this sounds huge, and cries for a sql version of the import. it looks like u have no experience in working as consultant hotlines Ash first the folk is asking for a sulotion of HIS

[PHP] Re: Issue with the huge import script

2009-08-16 Thread Ollisso
On Sun, 16 Aug 2009 04:15:12 +0300, Devendra Jadhav devendra...@gmail.com wrote: Is it because of the size of the records or something else...? Please suggest me some solution which is faster, safe and easy to code :D What about using insert ignore ? :) 1. add UNIQUE constraint on a key

Re: [PHP] Re: Issue with the huge import script

2009-08-16 Thread Ralph Deffke
better consider if u r insulting I've seen a view posts of u falling into that category i w'ld recomment respect posters first approaches even if they r stupid and incorporate the respect in the way u answer the comment you r crying ... is an insult. Ashley Sheridan a...@ashleysheridan.co.uk

Re: [PHP] Issue with the huge import script

2009-08-16 Thread Phpster
On Aug 15, 2009, at 9:15 PM, Devendra Jadhav devendra...@gmail.com wrote: Hi, I have to import data from one database to another, I have to import around 10(1Lac) records. First I need to check if the record is already imported or not and import only those records which are not

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the href attribute

2009-08-16 Thread chrysanhy
It did not work. Both gave me a Call to undefined method fatal error. On Sun, Aug 16, 2009 at 1:43 AM, Ralph Deffke ralph_def...@yahoo.de wrote: try $link-nodeValue() or $link-getContent() im not shure which one works on an image link which is indeed a child of a so u could also check

[PHP] Dan Brown

2009-08-16 Thread Angus Mann
Dan Brown is a frequent poster here and developer on the PHP team. Dan has not posted to the PHP list for quite a while and is not responding to my emails directly to him. Does anyone know if he's OK? If anyone has knowledge can they please reply to me directly - off list. Thanks, Angus

[PHP] Re: How do I extract link text from anchor tag as well as the URL from the href attribute

2009-08-16 Thread Ralph Deffke
did u try it something like this foreach ($links as $link) { $int_url_list[$i][href] = $link-getAttribute( 'href' ); $int_url_list[$i++][linkText] = $link-getContent( ); // nodeValue(); } that should work send ur code then please ralph_def...@yahoo,de chrysanhy

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the href attribute

2009-08-16 Thread chrysanhy
WHile waiting for suggestions for extracting the link text from the DOM, I tried a brute force approach using the URLs I had found with getAttribute(), but found myself baffled by my results. I boiled down my issue with this approach to the following snippet. $htmldata =EOB

[PHP] Cannot exec in my own directory

2009-08-16 Thread Dotan Cohen
I have a script in /home/username/script.sh with permissions 777. I can SSH into the server and execute ./script.sh to run the script, but calling it from exec in PHP does not run it. What should I start checking? Thanks. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP

Re: [PHP] Dan Brown

2009-08-16 Thread Per Jessen
Angus Mann wrote: Dan Brown is a frequent poster here and developer on the PHP team. Dan has not posted to the PHP list for quite a while and is not responding to my emails directly to him. Does anyone know if he's OK? If anyone has knowledge can they please reply to me directly - off list.

Re: [PHP] Cannot exec in my own directory

2009-08-16 Thread Sudheer Satyanarayana
Dotan Cohen wrote: I have a script in /home/username/script.sh with permissions 777. I can SSH into the server and execute ./script.sh to run the script, but calling it from exec in PHP does not run it. What should I start checking? Thanks. Check the include path. Try using the complete

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the href attribute

2009-08-16 Thread Ralph Deffke
well the immage goes inside the a.. img... /a on ur html the node a has no value however u should not get a error this is pergect jtml link a href=thema.htmimg src=button4.jpg width=160 height=34 border=0 alt=THEMA/a ralph chrysanhy phpli...@hyphusonline.com wrote in message

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the href attribute

2009-08-16 Thread Ralph Deffke
this worked here: ?php $html = new DOMDocument(); $html-loadHtmlFile(testHtml.html); $links = $html-getElementsByTagName('a'); echo pre; foreach ($links as $item) { echo $item-getAttribute( 'href' ). \n; echo --- . $item-nodeValue . \n; } echo /pre; ? Im sending u the 2 files directly

[PHP] Sanitizing mysql inserts of user data

2009-08-16 Thread Dotan Cohen
I am sanitizing user-entered data before storing in mysql with this function: function clean_mysql ($dirty) { $dirty=trim($dirty); $dirty=str_replace (--, , $dirty); $dirty=str_replace (;, , $dirty); $clean=mysql_real_escape_string($dirty); return $clean; } Is this good

[PHP] brainstorm/samples on _autoload() needed

2009-08-16 Thread Ralph Deffke
anybody out there with a ultimate solution, speed optimzed? im going now for an ultimate solution, this repeating problem sucks ralph_def...@yahoo.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Cannot exec in my own directory

2009-08-16 Thread Dotan Cohen
Check the include path. Try using the complete path to the file. And make sure the user PHP is running has read permissions to the directories upwards the hierarchy. Thanks. I am using the complete path to the script: exec(/home/username/script.sh); In the /home/username/ directory there are

RE: [PHP] Sanitizing mysql inserts of user data

2009-08-16 Thread Caner Bulut
Hi Dotan, You can use htmlentities(), htmlspecialchars() and strip_tags() functions when you show your saved data on your web pages. mysql_real_escape_string function saved data into mysql DB with a secure way. But when you try to show data you still have to control it. Thanks. Caner.

RE: [PHP] Cannot exec in my own directory

2009-08-16 Thread Caner Bulut
Dotan, Please copy your script in the Linux include paths. Such as /usr/local/bin and give it neccecary permission and try your script again. If you still have any problem, we understand that it is no related script path problem and permissions. Maybe there is some problems on your php script.

Re: [PHP] Sanitizing mysql inserts of user data

2009-08-16 Thread Adam Randall
What you are doing here is potentially altering valid user information coming into MySQL. For example, if someone legitimately enters in -- or ; into some string that is going to be put into MySQL, some comment or such, then what is put in, and then put out if you display it, won't be the same.

Re: [PHP] Sanitizing mysql inserts of user data

2009-08-16 Thread Dotan Cohen
You should in pretty much all cases be safe with just using the mysql_real_escape_string, which takes care of the - for you as well. If I remember correctly, TFM once stated that mysql_real_escape_string does not prevent SQL injection attacks, though I am hard pressed to think of what it _is_

Re: [PHP] Sanitizing mysql inserts of user data

2009-08-16 Thread Dotan Cohen
2009/8/16 Caner Bulut caner...@gmail.com: Hi Dotan, You can use htmlentities(), htmlspecialchars() and strip_tags() functions when you show your saved data on your web pages. mysql_real_escape_string function saved data into mysql DB with a secure way. But when you try to show data you

Re: [PHP] Cannot exec in my own directory

2009-08-16 Thread Dotan Cohen
Please copy your script in the Linux include paths. Such as /usr/local/bin and give it neccecary permission and try your script again. I do not have root access on this machine. That is why I run the script from /home/username/ -- Dotan Cohen http://what-is-what.com http://gibberish.co.il

Re: [PHP] Another date exercise

2009-08-16 Thread Paul M Foster
On Sun, Aug 16, 2009 at 08:36:17AM +0100, Lester Caine wrote: tedd wrote: Hi gang: Here's another exercise to consider. This is a date entry problem where the user can enter a date in various forms, but the return will be in a consistent format. For example, a user might enter a date in

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the href attribute

2009-08-16 Thread chrysanhy
The code snippet below worked! Thank you so much for your time helping me with this! On Sun, Aug 16, 2009 at 11:26 AM, Ralph Deffke ralph_def...@yahoo.dewrote: this worked here: ?php $html = new DOMDocument(); $html-loadHtmlFile(testHtml.html); $links = $html-getElementsByTagName('a');

[PHP] running str_replace, it misbehaves!

2009-08-16 Thread Allen McCabe
Hi friends, I'm trying to get an encrypting program working to possibly use for password insertion into a db. I set up a function that runs str_replace on a string (user supplied) two times. It searches for a single letter or number, and replace it with a pair. The next str_replace searches that

Re: [PHP] Another date exercise

2009-08-16 Thread Ralph Deffke
i agree on date pickers and js is well use individual fields for day month and year, make month and year as drop down and u have no problem at all make live easier ralph Paul M Foster pa...@quillandmouse.com wrote in message news:20090816202217.gs2...@quillandmouse.com... On Sun, Aug 16,

[PHP] link to a css file requires .css ???

2009-08-16 Thread Daniel Kolbo
Hello, I realize this is more of an html question than a php, but I was hoping someone here would know what's going on. I am linking to a stylesheet and it is requiring me to use *.css extension. I want to use a .php extension (and have the php engine generate css). However, whenever i use a

Re: [PHP] link to a css file requires .css ???

2009-08-16 Thread Nitsan Bin-Nun
Of course not, just send the corresponding mime type to the file extension .css Probably header('Content-Type: text/css'); Good luck ;) On Sun, Aug 16, 2009 at 11:37 PM, Daniel Kolbo kolb0...@umn.edu wrote: Hello, I realize this is more of an html question than a php, but I was hoping

Re: [PHP] link to a css file requires .css ???

2009-08-16 Thread Daniel Kolbo
Daniel Kolbo wrote: Hello, I realize this is more of an html question than a php, but I was hoping someone here would know what's going on. I am linking to a stylesheet and it is requiring me to use *.css extension. I want to use a .php extension (and have the php engine generate css).

Re: [PHP] link to a css file requires .css ???

2009-08-16 Thread Adam Shannon
On Sun, Aug 16, 2009 at 4:37 PM, Daniel Kolbo kolb0...@umn.edu wrote: Hello, I realize this is more of an html question than a php, but I was hoping someone here would know what's going on. I am linking to a stylesheet and it is requiring me to use *.css extension. I want to use a .php

Re: [PHP] Re: File or directory?

2009-08-16 Thread George Langley
is_dir() http://ca3.php.net/is_dir is_file() http://ca3.php.net/manual/en/function.is-file.php George Langley On 15-Aug-09, at 5:45 PM, Clancy wrote: On Sat, 15 Aug 2009 10:33:07 +0100, a...@ashleysheridan.co.uk (Ashley Sheridan) wrote: On Sat, 2009-08-15 at 09:56 +0200, Ralph Deffke