Jump to content

sachavdk

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Posts posted by sachavdk

  1. Hi,

     

    I have 2 regexes here:

     

    #{view:[a-z]+(?::[a-z]+)?(?: [a-z]+=["'].*?["'])*}#is

    and

    #{view:[a-z]+(?::[a-z]+)?(?: [a-z]+=["'].*?["'])* /}#is

     

    the first one to match

    {view:food:cheese type="old"}

    or

    {view:car}

    or

    {view:car engine="boxer"}

     

    the second to match

    {view:food:cheese type="old" /}

    or

    {view:car /}

    or

    {view:car engine="boxer" cc='2394' /}

     

    The first regex matches correctly the first three tags, but it also matches the second three tags with the close slash and I can't figure out what I'm doing wrong.

     

    Anyone else maybe sees it?

     

    Thanks

  2. Hi,

     

    I'm having a problem here that confuses me a little.

    I'm working on

    http://157.176.112.4/site/en-uk/read-guestbook/index.php

    and I'd like to require

    http://157.176.112.4/inc/ModuleLoader.php

    but using

    require_once( "/inc/ModuleLoader.php" );

    gives me an error:

     

    PHP Warning: main(/inc/site.php) [function.main]: failed to open stream: No such file or directory in J:\WEBSERVER\www\beta\site\en-uk\read-guestbook\index.php on line 2 PHP Fatal error: main() [function.require]: Failed opening required '/inc/site.php' (include_path='.;C:\php5\pear') in J:\WEBSERVER\www\beta\site\en-uk\read-guestbook\index.php on line 2

     

    file_exists( "/inc/ModuleLoader.php" ); fails as well.

    using require_once( "../../../inc/ModuleLoader.php" ); does work.

    any suggestions?

     

    thanks

     

    edit: I can't use relative paths because the structure of the <site> class isn't really written to deal with this.

  3. I've got a regex pattern here, partitionally working.

     

    it should match                          {{m}{module_name}{parameter1|parameter2|...}}

     

    What I already have is  "#^\{\{[a-z]*\}\{[a-z0-9_/]*\}(.*)\}$#i", which matches  {{m}{module_name}(.*)} correctly.

     

    Now I can't get the parameter part working.

    It should leave {parameterlist} optional and the pipe-seperated parameters should be stored in the backreference (using preg_match).

    Any help is appreciated :) .

  4. maybe some last questions, what is the "is" doing after the @delimiter?

    and if I just replace style with body, it doesn't work

     

    I'm doing:

     

    $fread = fread($cont, filesize($file));

    preg_match("@<body[^>]+(type=['\"]?[^'\"]+['\"]?)?[^>]+?>(.+?)</body>@is", $fread, $fbody);

    preg_match("@<style[^>]+(type=['\"]?[^'\"]+['\"]?)?[^>]+?>(.+?)</style>@is", $fread, $fstyle);

     

    $fstyle[2] contains the content between the style tags, but $fbody[2] is empty.

    and last, shouldn't $fread[1] contain "text/css"? because it is empty...

  5. Both methods give errors.

    The first one gives

    Warning: preg_match() [function.preg-match]: Unknown modifier 'c' in ...

    The second:

    Warning: preg_match() [function.preg-match]: Compilation failed: unmatched parentheses at offset 53 in ...

  6. I'm trying to get the css code out of the style tags of a html documents like this:

    <style type="text/css">

    <!--

    .style1 {

    font-size: 11px;

    }

    -->

    </style>

    I'm trying to get

    <!--

    .style1 {

    font-size: 11px;

    }

    -->

     

    This is what I have now

     

    preg_match("/(<style type=\"text\/css\">)+([.])+(<\/style>)/", $fread, $style);

  7. Well, "SELECT * FROM tbl_name" can be a damn heavy query.
    Probably you don't have transactions within milliseconds, so what you simply can do is just selecting the highest id from the table.

    SELECT MAX(id_column_name) FROM table_name

    It will return just one row with the latest inserted id.
    [color=red]Quick edit:[/color] execute the queries directly after eachother:

    ....
    mysql_query("INSERT ....");
    mysql_query("SELECT ....");
    // do the rest of your code
    .....
  8. Hi,

    I'm trying to write a function that loops through a folder I specify,
    if a specific file is also a folder, the function itself is called again with the new directory path,
    it loops through this one, ...

    But the error I get is:
    [b]The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:[/b]
    (No headers are sent with it).
    Here's the function (var $tpls is not used yet but I don't think that'll be the problem):
    [b]$tpls = "";
    $dir = "styles/main/tpl/";
    function loopDirs($dir, $tpls) {
    if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
    while (($file = readdir($dh)) !== false) {
    if (is_dir($dir . "/" . $file . "/")) {
    loopDirs($dir . "/" . $file . "/", $tpls);
    }
    else {
    echo $dir . "/" . $file."<br />";
    }
    }
    closedir($dh);
    }
    }
    }
    loopDirs($dir, $tpls);[/b]
  9. Guess it's working now :)
    I'm gonna try it with other combinations.

    But actually I need that count ;)
    Not in the query (in my program) but I forgot to do an expression on the field and select it.

    The SELECT should actually be
    g.group_id,
    g.name,
    CONCAT((g.maxmem-gu.num), '/', g.maxmem) freeplaces

    But thx for your help
  10. Hi,

    I've got a query here:
    [code]SELECT DISTINCT
    g.group_id,
    g.name,
    g.maxmem maxmem
    FROM
    groups g,
    (SELECT
    COUNT(* ) num,
    group_id
    FROM usergroup
    GROUP BY group_id) ug
    WHERE
    g.group_id NOT IN (ug.group_id);[/code]
    When I remove the where, it gives me 3 results which is correct with my current rows)
    When I set the were to [color=blue]g.group_id IN (ug.group_id)[/color], it gives me 2 results (also ok).
    But when I use NOT IN (like the full query above) it gives me the 3 results as without the where.
    But it should be 1 result. So where does it go wrong?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.