User Profile

Collapse

Profile Sidebar

Collapse
Gulzor
Gulzor
Last Activity: Oct 22 '09, 04:05 PM
Joined: Jul 23 '08
Location: Brussels, Belgium
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Gulzor
    started a topic Validate (X)HTML with custom tags with PHP DOM API
    in PHP

    Validate (X)HTML with custom tags with PHP DOM API

    Hi,

    I have defined a set of custom tags that I put among regular HTML tags. E.g.

    <body>
    <div id="regular_id" >
    <namespace:cont ainer id="something" type="article" />
    </div>
    </body>

    At this time, I use PHP preg_* functions to parse the HTML file and trigger actions when I detect a tag that starts with the string...
    See more | Go to post

  • I tried but it still doesn't work.

    mb_detect_encod ing($str.'a', 'ISO-8859-1,UTF-8')

    does not return the same value than

    mb_detect_encod ing($str.'a', 'UTF-8,ISO-8859-1')

    When I output debug messages, it looks like that strings that I send back to the server and the strings returned from the server are the same...

    Aaaargh !!! it is getting on my nerves
    See more | Go to post

    Leave a comment:


  • Didn't work. I really don't know what I can do...
    See more | Go to post

    Leave a comment:


  • Of course ! Will do. Thank you.
    See more | Go to post

    Leave a comment:


  • I tried this when I used DOM::loadHTML to query the HTML for the data but the problem remains the same :

    When I send back the data to the server (through HTTP POST), it seems that the data are corrupted.

    Note that my script does not print out and executes on the command line.
    See more | Go to post

    Leave a comment:


  • Gulzor
    started a topic Does PHP send out corrupted string ? (charset issue)
    in PHP

    Does PHP send out corrupted string ? (charset issue)

    Hi,

    I fetch web pages using Zend_Http (I send out POST data, fetch the results, and so on)
    I have no problem with that.

    I did a mb_detect_encod ing() of the returned HTML and the function says it's UTF-8 encoded.

    Parts of the returned HTML must be send back to the server. I store these parts into PHP strings.

    The problem is that when I send back these PHP strings, all special characters...
    See more | Go to post

  • Gulzor
    replied to Regex to Extract an Email Address
    in PHP
    I wrote that script to extract all email addresses contained into a file : (don't forget to replace page.html with your file)

    [php]
    <?php

    $buffer=file_ge t_contents('pag e.html');

    /* pas de ^ et $ car plusieurs emails par lignes !*/
    $regex='`([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})`';


    $matches=array( );
    preg_match_all( $regex, $buffer,...
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to Regex to Extract an Email Address
    in PHP
    Hi,

    I use the following regular expression to extract emails from files :

    ^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$

    source : http://www.developer.com/lang/php/article.php/3290141
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to PHPMailer Complications
    in PHP
    We use PHPMailer in several projects and we never have that kind of issues. But we like to keep things simple.

    Do you use the last version of PHPMailer ? Are you sure that your SMTP server is configured correctly ?

    That is weird.
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to XSLT vs DOM
    in PHP
    Personaly :

    I would first have a look at the complexity of the xml structure. If it's too simple, I would loop into it with just the dom api and I generate the html "by hand".

    If it is not (like 2 or more depth levels), I go DOM+XSLT without hesitation.

    In both cases I try to save the result (the outputted html) into a file in order to avoid unecessary processing.
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to PHPMailer Complications
    in PHP
    Try this :
    [php]
    $PHPMailer->SMTPAuth = true;
    $PHPMailer->SMTPSecure = "ssl";
    [/php]

    Also, set $PHPMailer->Port with the correct port value if necessary.
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to Passing values from PHP to JavaScript
    in PHP
    You should not use this <?=$var?> (on its way to deprecation), but this <?php echo $var; ?> instead....
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to How to read HTTP request using php
    in PHP
    Did you have a look at Zend Framework ? The Zend_Http could help, but you need PHP5...
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to Is PHP-Nuke Good Enough? Need Opinions
    in PHP
    I had a one month mission in a public administration that uses php-nuke. They needed new tailored modules to be integrated into the cms.

    I can't remember what version of php-nuke it was but I can tell you this :

    The code was so bad that each line of it can be reported at thedailywtf.com ! The developer didn't even know what OOP is because I've seen none in the cms core !

    My advise : don't rely on it
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to Passing values from PHP to JavaScript
    in PHP
    A simple output does the job :

    [php]
    <script type="text/javascript">
    function hello(name) {
    alert("hello "+name);
    }

    <?php
    while ( $rec = mysql_fetch_ass oc($query) ) {
    echo 'hello("',$rec['firstname'],'");', "\n";
    }
    ?>

    // or

    hello("<?php echo $var; ?>");
    ...
    See more | Go to post

    Leave a comment:


  • I don't know much about DocBook but you might want to look at it.
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to about preg_match_all statement
    in PHP
    I don't understand what your problem is now... not only <p> tag hold texts. <li>, <td>, <span> and more also do....
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to about preg_match_all statement
    in PHP
    These are "just" warnings resulting in wrong or unsupported html entities or something else. It's just impossible to parse a html document without getting these warnings...

    If your texts are not between <p></p>, you can replace //p by //td. Like I said, you need to adapt it to your needs.
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to opening a application and updating database
    in PHP
    If you are using the header() func to redirect make sure that you do not output anything before that.

    If you open a connection to a database before the call to header() and that the connection fails, the error message echoed by php will bug the call to header() too.
    See more | Go to post

    Leave a comment:


  • Gulzor
    replied to about preg_match_all statement
    in PHP
    If you are working with PHP5, you can use the DOM API for that.

    Adapt this to your needs :
    [php]
    <?php
    $htmlString = file_get_conten ts('url_or_path _to_html_file') ;
    $htmlDoc = DOMDocument::lo adHTML($htmlStr ing);
    $xpath = new DOMXPath($htmlD oc);

    /* fetch the content of all <p> tags */
    $pNodesList = $xpath->query('//p');
    for ($i=0; $i<$pNodesList->length;...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...