Frage zu Query

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Frage zu Query

    Hi,

    ich erhalte diese Meldung:

    Query was empty

    ok, ich habe das query gefunden. Nun würde ich gerne mal wissen was das schief läuft. Seit dem ich auf mySQL 5 gewechselt bin, geht dies nämlich nicht mehr _;(

    Hier das Query:

    PHP-Code:
        $result db_query(xss("update ".DB_PREFIX."projekte
                                    set 
    $sql_string
                                        personen='"
    .serialize($personen)."',
                                        gruppe='
    $user_group',
                                        parent='
    $parent',
                                        depend_mode = '
    $depend_mode',
                                        depend_proj = '
    $depend_proj',
                                        next_mode = '
    $next_mode',
                                        next_proj = '
    $next_proj',
                                        probability = '
    $probability',
                                        acc='
    $acc',
                                        acc_write = '
    $acc_write'
                                    where ID = '
    $ID'")) or db_die();
                
                
    print_r($result); 
    pdas prinr wirf mir nicht raus. In der Umgebung wo es noch funktioniert (Testumgebung) da erhalte ich eine "1".

    Wie kann ich mir das Query printen lassen, damit ich es mal im phpmyadmin absetzen kann?

    Ciao

  • #2
    welche db ist es?

    PHP-Code:
    $sql 'update...';
    echo 
    $sql;
    # statement $sql ausführen 

    Kommentar


    • #3
      Die DB heisst "phprojekt"... meinst du das?

      Auf der mySQL 3.23 Umgebung funktrioniert dies alles einwandfrei.

      Kommentar


      • #4
        nein, ich meine, ob es mysql, postgre, oracle, sqlite oder was auch immer ist.

        dann würde nämlich mysql_error() sowie die zusammengestellte query interessieren.

        Kommentar


        • #5
          was mach xss? ich vermute irgendwas gegen SQL-Injection

          versuch mal so

          PHP-Code:
          $sql xss("update ".DB_PREFIX."projekte
                                          set 
          $sql_string
                                              personen='"
          .serialize($personen)."',
                                              gruppe='
          $user_group',
                                              parent='
          $parent',
                                              depend_mode = '
          $depend_mode',
                                              depend_proj = '
          $depend_proj',
                                              next_mode = '
          $next_mode',
                                              next_proj = '
          $next_proj',
                                              probability = '
          $probability',
                                              acc='
          $acc',
                                              acc_write = '
          $acc_write'
                                          where ID = '
          $ID'");
          echo 
          $sql

          Kommentar


          • #6
            mysql

            Kommentar


            • #7
              xss =


              // This is a black list filter, that allows all tags and takes out
              // some known xss issues. It is _not_ secury, as there are always new
              // scripting issues in the browser being found. But at least it works
              // with FCKedit generated content.
              // taken from Horde_MIME_Viewer, licensed under GPL
              // Authors: Anil Madhavapeddy, Jon Parise, Michael Slusarz

              wenn ich dein Script oben nehme erhalte ich:

              "Resource id #12"

              und die Meldung "Query was empty" kommt auch nicht. Es wird aber nichts in die DB geschrieben ....
              Zuletzt geändert von FRAD; 05.02.2007, 15:42.

              Kommentar


              • #8
                dann nimm die funktion xss() weg.

                Kommentar


                • #9
                  nehme ich das xss weg, funktioniert es )

                  PHP-Code:
                  $result db_query("update ".DB_PREFIX."projekte
                                                  set 
                  $sql_string
                                                      personen='"
                  .serialize($personen)."',
                                                      gruppe='
                  $user_group',
                                                      parent='
                  $parent',
                                                      depend_mode = '
                  $depend_mode',
                                                      depend_proj = '
                  $depend_proj',
                                                      next_mode = '
                  $next_mode',
                                                      next_proj = '
                  $next_proj',
                                                      probability = '
                  $probability',
                                                      acc='
                  $acc',
                                                      acc_write = '
                  $acc_write'
                                                  where ID = '
                  $ID'") or db_die(); 
                  Aber warum? Hier die XSS Function

                  PHP-Code:

                  function xss($data) {
                      
                  /* Deal with <base> tags in the HTML, since they will screw up
                       * our own relative paths. */
                      
                  if (($i stristr($data'<base ')) && ($i stristr($i'http')) &&
                          (
                  $j strchr($i'>'))) {
                          
                  $base substr($i0strlen($i) - strlen($j));
                          
                  $base preg_replace('|(http.*://[^/]*/?).*|i''\1'$base);
                          if (
                  $base[strlen($base) - 1] != '/') {
                              
                  $base .= '/';
                          }
                          
                  /* Recursively call _cleanHTML() to prevent clever fiends
                          * from sneaking nasty things into the page via $base. */
                          
                  $base html_out2($base);
                      }

                      
                  /* Change space entities to space characters. */
                      
                  $data preg_replace('/&#(x0*20|0*32);?/i'' '$data);

                      
                  /* Nuke non-printable characters (a play in three acts). */

                      /* Rule 1). If we have a semicolon, it is deterministically
                       * detectable and fixable, without introducing collateral
                       * damage. */
                      
                  $data preg_replace('/&#x?0*([9A-D]|1[0-3]);/i''&nbsp;'$data);

                      
                  /* Rule 2). Hex numbers (usually having an x prefix) are also
                       * deterministic, even if we don't have the semi. Note that
                       * some browsers will treat &#a or &#0a as a hex number even
                       * without the x prefix; hence /x?/ which will cover those
                       * cases in this rule. */
                      
                  $data preg_replace('/&#x?0*[9A-D]([^0-9A-F]|$)/i''&nbsp\\1'$data);

                      
                  /* Rule 3). Decimal numbers without trailing semicolons. The
                       * problem is that some browsers will interpret &#10a as
                       * "\na", some as "&#x10a" so we have to clean the &#10 to be
                       * safe for the "\na" case at the expense of mangling a valid
                       * entity in other cases. (Solution for valid HTML authors:
                       * always use the semicolon.) */
                      
                  $data preg_replace('/&#0*(9|1[0-3])([^0-9]|$)/i''&nbsp\\2'$data);

                      
                  /* Remove overly long numeric entities. */
                      
                  $data preg_replace('/&#x?0*[0-9A-F]{6,};?/i''&nbsp;'$data);

                      
                  /* Get all attribute="javascript:foo()" tags. This is
                       * essentially the regex /(=|url\()("?)[^>]*script:/ but
                       * expanded to catch camouflage with spaces and entities. */
                      
                  $preg '/((&#0*61;?|&#x0*3D;?|=)|' .
                      
                  '((u|&#0*85;?|&#x0*55;?|&#0*117;?|&#x0*75;?)\s*' .
                      
                  '(r|&#0*82;?|&#x0*52;?|&#0*114;?|&#x0*72;?)\s*' .
                      
                  '(l|&#0*76;?|&#x0*4c;?|&#0*108;?|&#x0*6c;?)\s*' .
                      
                  '(\()))\s*' .
                      
                  '(&#0*34;?|&#x0*22;?|"|&#0*39;?|&#x0*27;?|\')?' .
                      
                  '[^>]*\s*' .
                      
                  '(s|&#0*83;?|&#x0*53;?|&#0*115;?|&#x0*73;?)\s*' .
                      
                  '(c|&#0*67;?|&#x0*43;?|&#0*99;?|&#x0*63;?)\s*' .
                      
                  '(r|&#0*82;?|&#x0*52;?|&#0*114;?|&#x0*72;?)\s*' .
                      
                  '(i|&#0*73;?|&#x0*49;?|&#0*105;?|&#x0*69;?)\s*' .
                      
                  '(p|&#0*80;?|&#x0*50;?|&#0*112;?|&#x0*70;?)\s*' .
                      
                  '(t|&#0*84;?|&#x0*54;?|&#0*116;?|&#x0*74;?)\s*' .
                      
                  '(:|&#0*58;?|&#x0*3a;?)/i';
                      
                  $data preg_replace($preg'\1\8HordeCleaned'$data);

                      
                  /* Get all on<foo>="bar()". NEVER allow these. */
                      
                  $data preg_replace('/([\s"\']+' .
                      
                  '(o|&#0*79;?|&#0*4f;?|&#0*111;?|&#0*6f;?)' .
                      
                  '(n|&#0*78;?|&#0*4e;?|&#0*110;?|&#0*6e;?)' .
                      
                  '\w+)\s*=/i''\1HordeCleaned='$data);

                      
                  /* Remove all scripts since they might introduce garbage if
                      * they are not quoted properly. */
                      
                  $data preg_replace('|<script[^>]*>.*?</script>|is''<HordeCleaned_script />'$data);

                      
                  /* Get all tags that might cause trouble - <object>, <embed>,
                      * <base>, etc. Meta refreshes and iframes, too. */
                      
                  $malicious = array(
                      
                  '/<([^>a-z]*)' .
                      
                  '(s|&#0*83;?|&#x0*53;?|&#0*115;?|&#x0*73;?)\s*' .
                      
                  '(c|&#0*67;?|&#x0*43;?|&#0*99;?|&#x0*63;?)\s*' .
                      
                  '(r|&#0*82;?|&#x0*52;?|&#0*114;?|&#x0*72;?)\s*' .
                      
                  '(i|&#0*73;?|&#x0*49;?|&#0*105;?|&#x0*69;?)\s*' .
                      
                  '(p|&#0*80;?|&#x0*50;?|&#0*112;?|&#x0*70;?)\s*' .
                      
                  '(t|&#0*84;?|&#x0*54;?|&#0*116;?|&#x0*74;?)\s*/i',

                      
                  '/<([^>a-z]*)' .
                      
                  '(e|&#0*69;?|&#0*45;?|&#0*101;?|&#0*65;?)\s*' .
                      
                  '(m|&#0*77;?|&#0*4d;?|&#0*109;?|&#0*6d;?)\s*' .
                      
                  '(b|&#0*66;?|&#0*42;?|&#0*98;?|&#0*62;?)\s*' .
                      
                  '(e|&#0*69;?|&#0*45;?|&#0*101;?|&#0*65;?)\s*' .
                      
                  '(d|&#0*68;?|&#0*44;?|&#0*100;?|&#0*64;?)\s*/i',

                      
                  '/<([^>a-z]*)' .
                      
                  '(b|&#0*66;?|&#0*42;?|&#0*98;?|&#0*62;?)\s*' .
                      
                  '(a|&#0*65;?|&#0*41;?|&#0*97;?|&#0*61;?)\s*' .
                      
                  '(s|&#0*83;?|&#x0*53;?|&#0*115;?|&#x0*73;?)\s*' .
                      
                  '(e|&#0*69;?|&#0*45;?|&#0*101;?|&#0*65;?)\s*' .
                      
                  '[^line]/i',

                      
                  '/<([^>a-z]*)' .
                      
                  '(m|&#0*77;?|&#0*4d;?|&#0*109;?|&#0*6d;?)\s*' .
                      
                  '(e|&#0*69;?|&#0*45;?|&#0*101;?|&#0*65;?)\s*' .
                      
                  '(t|&#0*84;?|&#x0*54;?|&#0*116;?|&#x0*74;?)\s*' .
                      
                  '(a|&#0*65;?|&#0*41;?|&#0*97;?|&#0*61;?)\s*/i',

                      
                  '/<([^>a-z]*)' .
                      
                  '(j|&#0*74;?|&#0*4a;?|&#0*106;?|&#0*6a;?)\s*' .
                      
                  '(a|&#0*65;?|&#0*41;?|&#0*97;?|&#0*61;?)\s*' .
                      
                  '(v|&#0*86;?|&#0*56;?|&#0*118;?|&#0*76;?)\s*' .
                      
                  '(a|&#0*65;?|&#0*41;?|&#0*97;?|&#0*61;?)\s*/i',

                      
                  '/<([^>a-z]*)' .
                      
                  '(o|&#0*79;?|&#0*4f;?|&#0*111;?|&#0*6f;?)\s*' .
                      
                  '(b|&#0*66;?|&#0*42;?|&#0*98;?|&#0*62;?)\s*' .
                      
                  '(j|&#0*74;?|&#0*4a;?|&#0*106;?|&#0*6a;?)\s*' .
                      
                  '(e|&#0*69;?|&#0*45;?|&#0*101;?|&#0*65;?)\s*' .
                      
                  '(c|&#0*67;?|&#x0*43;?|&#0*99;?|&#x0*63;?)\s*' .
                      
                  '(t|&#0*84;?|&#x0*54;?|&#0*116;?|&#x0*74;?)\s*/i',

                      
                  '/<([^>a-z]*)' .
                      
                  '(i|&#0*73;?|&#x0*49;?|&#0*105;?|&#x0*69;?)\s*' .
                      
                  '(f|&#0*70;?|&#0*46;?|&#0*102;?|&#0*66;?)\s*' .
                      
                  '(r|&#0*82;?|&#x0*52;?|&#0*114;?|&#x0*72;?)\s*' .
                      
                  '(a|&#0*65;?|&#0*41;?|&#0*97;?|&#0*61;?)\s*' .
                      
                  '(m|&#0*77;?|&#0*4d;?|&#0*109;?|&#0*6d;?)\s*' .
                      
                  '(e|&#0*69;?|&#0*45;?|&#0*101;?|&#0*65;?)\s*/i');

                      
                  $data preg_replace($malicious'<HordeCleaned_tag'$data);

                      
                  /* Comment out style/link tags, only if we are viewing inline.
                       * NEVER show style tags to Netscape 4.x users since 1) the
                       * output will really, really suck and 2) there might be
                       * security issues. */
                       
                  $pattern = array('/\s+style\s*=/i',
                        
                  '|<style[^>]*>(?:\s*<\!--)*|i',
                        
                  '|(?:-->\s*)*</style>|i',
                        
                  '|(<link[^>]*>)|i');
                        
                  $replace = array(' HordeCleaned=',
                        
                  '<!--',
                        
                  '-->',
                        
                  '<!-- $1 -->');
                        
                  $data preg_replace($pattern$replace$data);

                      
                  /* A few other matches. */
                      
                  $pattern = array('|<([^>]*)&{.*}([^>]*)>|',
                      
                  '|<([^>]*)mocha:([^>]*)>|i',
                      
                  '|<([^>]*)binding:([^>]*)>|i');
                      
                  $replace = array('<&{;}\3>',
                      
                  '<\1HordeCleaned:\2>',
                      
                  '<\1HordeCleaned:\2>');
                      
                  $data preg_replace($pattern$replace$data);

                      
                  /* Attempt to fix paths that were relying on a <base> tag. */
                      
                  if (!empty($base)) {
                          
                  $pattern = array('|src=(["\'])/|i',
                          
                  '|src=[^\'"]/|i',
                          
                  '|href= *(["\'])/|i',
                          
                  '|href= *[^\'"]/|i');
                          
                  $replace = array('src=\1' $base,
                          
                  'src=' $base,
                          
                  'href=\1' $base,
                          
                  'href=' $base);
                          
                  $data preg_replace($pattern$replace$data);
                      }

                      
                  /* Check for phishing exploits. */
                      
                  if (preg_match('/href\s*=\s*["\']?\s*(http|https|ftp):\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/i'$data)) {
                          
                  /* Check 1: Check for IP address links. */
                          
                  $phish_warn true;
                      } elseif (
                  preg_match_all('/href\s*=\s*["\']?\s*(?:http|https|ftp):\/\/([^\s"\'>]+)["\']?[^>]*>\s*(?:(?:http|https|ftp):\/\/)?(.*?)<\/a/i'$data$m)) {
                          
                  /* $m[1] = Link; $m[2] = Target
                          * Check 2: Check for links that point to a different host than
                          * the target url; if target looks like a domain name, check it
                          * against the link. */
                          
                  $links count($m[0]);
                          for (
                  $i 0$i $links$i++) {
                              
                  $m[2][$i] = strip_tags($m[2][$i]);
                              if (
                  preg_match('/^[.-_\da-z]+\.[a-z]{2,}/i'$m[2][$i]) &&
                              
                  strpos(urldecode($m[1][$i]), $m[2][$i]) !== &&
                              
                  strpos($m[2][$i], urldecode($m[1][$i])) !== 0) {
                                  
                  /* Don't consider the link a phishing link if the domain
                                  * is the same on both links (e.g. adtracking.example.com &
                                  * [url]www.example.com[/url]). */
                                  
                  preg_match('/\.?([^\.\/]+\.[^\.\/]+)\//'$m[1][$i], $host1);
                                  
                  preg_match('/\.?([^\.\/]+\.[^\.\/]+)(\/.*)?$/'$m[2][$i], $host2);
                                  if (!(
                  count($host1) && count($host2)) ||
                                  
                  strcasecmp($host1[1], $host2[1]) !== 0) {
                                      
                  $phish_warn true;
                                  }
                              }
                          }
                      }

                      return 
                  $data;

                  Macht da etwas PRobleme in PHP5??

                  Kommentar


                  • #10
                    du kannst ja mal schrittweise debuggen, dann wirst du schon heraus finden, woran es lag.

                    Kommentar


                    • #11
                      kannst du mir einen kurzen Tip geben bzgl. debuggen ...

                      Danke

                      Kommentar


                      • #12
                        wenn du keinen echten Debugger hast und somit breakpoints setzen kannst, dann eben nur mit echo und exit schrittweise die Ausgabe kontrollieren bis der Fehler lokalisiert wird. Andererseits verstehe ich nicht, warum man nichts für ein vernünftiges Werkzeug investieren will, wenn man sonst alles schon umsonst bekommt. PHPEdit kann ich sehr empfehlen. Kostet auch nicht die Welt, im Vergleich zu Visual Studio & Co.
                        Zuletzt geändert von asp2php; 05.02.2007, 20:53.

                        Kommentar


                        • #13
                          puhh in einer Funktion debuggen.... kannst du mir mal ein beispiel geben, dann werde ich damit mal spielen...

                          Kommentar


                          • #14
                            Original geschrieben von FRAD
                            puhh in einer Funktion debuggen.... kannst du mir mal ein beispiel geben, dann werde ich damit mal spielen...
                            ...
                            Original geschrieben von asp2php
                            dann eben nur mit echo und exit schrittweise die Ausgabe kontrollieren bis der Fehler lokalisiert wird.

                            Ein netter Guide zum übersichtlichen Schreiben von PHP/MySQL-Code!

                            bei Klammersetzung bevorzuge ich jedoch die JavaCoding-Standards
                            Wie man Fragen richtig stellt

                            Kommentar


                            • #15
                              Naja es gibt auch kostenlose PHP-IDEs mit Debugging-Möglichkeiten. Hier zum Beispiel ein kleiner Appetithappen: http://www-128.ibm.com/developerwork...y/i-osource13/

                              Kommentar

                              Lädt...
                              X