Ankündigung

Einklappen
Keine Ankündigung bisher.

Fehler beim DB Connecten ...

Einklappen

Neue Werbung 2019

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

  • Fehler beim DB Connecten ...

    moin moin zusammen!

    ich will für mein projekt einen downloadbereich scripten. wenn man auf der downloadseite ist, und einen dl anklickt, öffnet sich ein popup in dem der counterstand hochgezählt wird und nach wenigen seks der download startet.

    nun lasse ich meine ganzen downloads aus einer db auslesen - klappt auch wunderbar -, jedoch bei dem popup läßt sich keine verbindung zur db aufbauen. und ich hab keine ahnung worans liegt.

    hier mal paar codeschnipsel:

    dbconnect.inc.php (die variablen werden aus ner config.inc.php gezogen uns sind alle definiert)
    PHP-Code:
    <?
    mysql_connect("$db_host","$db_user","$db_pass") or die
    ("Die Verbindung zur Datenbank konnte nicht hergestellt werden.");
    mysql_select_db("$db_name") or die
    ("Die Datenbank existiert nicht");
    ?>
    downloads.php (hier werden die downloads angezeigt)
    PHP-Code:
    <?php
    include("dbconnect.inc.php");
    ?>

    <script language="JavaScript">
    <!--
    function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
    {
      toolbar_str = toolbar ? 'no' : 'no';
      menubar_str = menubar ? 'no' : 'no';
      statusbar_str = statusbar ? 'no' : 'no';
      scrollbar_str = scrollbar ? 'no' : 'no';
      resizable_str = resizable ? 'no' : 'no';
      window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
    }

    // -->
    </script>

    <?php
    $textfile 
    fopen("lang/$lang/downloads.txt","r");
    $main_text fgets($textfile);
    fclose($textfile);
    $dlcat $_GET["dlcat"];
    $start $_GET["start"];
    if(
    $dlcat == "")
      {
      
    ?>
      <table class="boxes" cellpadding="0" cellspacing="0" width="100%">
        <tr class="header_boxes">
          <td class="header_boxes" colspan="2">Downloads</td>
        </tr>
        <tr>
          <td colspan="2"><?php echo $main_text?><br><br></td>
        </tr>
          <?php
          $dlcats 
    "SELECT * FROM rhs_".$prjct."_dlcats";
          
    $getdlcats mysql_query($dlcats) or die(__LINE__ ' ' mysql_error());;
          while(
    $row mysql_fetch_object($getdlcats))
            {
            echo 
    '<tr><td width="50%" align ="right"><a href="index.php?lang='.$lang.'&goto='.$goto.'&dlcat='.$row->dlcat.'&start=1'; if($row->entries == "0") { echo '&no_entry=yes'; } echo '">'.$row->dlcat_name.'</a>&nbsp;</td>
            <td width="50%">&nbsp;('
    .$row->entries.')</td></tr>';
            }
          
    ?>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
      </table>
      <?php
      
    }
      elseif(
    $no_entry != "yes")
      {
      
    ?>
      <table class="boxes" cellpadding="0" cellspacing="0" width="100%">
        <tr class="header_boxes">
          <td class="header_boxes">
          <?php
          $seldlcat 
    "SELECT * FROM rhs_".$prjct."_dlcats WHERE dlcat LIKE '".$dlcat."'";
          
    $getseldlcat mysql_query($seldlcat) or die(__LINE__ ' ' mysql_error());;
          while(
    $row mysql_fetch_object($getseldlcat))
            {
            echo 
    $row->dlcat_name;
            }
          
    ?>
          </td>
        </tr>
        <tr>
          <td>
            <?php
            $start_dl_sel 
    0;
            
    $dls "SELECT * FROM rhs_".$prjct."_files WHERE dlcat LIKE '".$dlcat."' LIMIT $start_dl_sel$number_of_sel_dls";
            
    $getdls mysql_query($dls) or die(__LINE__ ' ' mysql_error());;
            while(
    $row mysql_fetch_object($getdls))
              {
              
    $dl_id $row->id;
              
    $boardurl $row->boardurl;
              
    $filename $row->filename;
              
    $autor $row->autor;
              
    $downloads $row->downloads;
              
    $votes $row->votes;
              
    $img $row->img;
              
    $dls2 "SELECT * FROM rhs_".$prjct."_".$lang."_files WHERE dl_id LIKE '".$dl_id."'";
              
    $getdls2 mysql_query($dls2) or die(__LINE__ ' ' mysql_error());;
              while(
    $row mysql_fetch_object($getdls2))
                {
                
    ?>
                <table class="dltable">
                  <tr>
                    <td width="30%">
                      <p><a href="<?php echo $boardurl?>" target="_blank"><?php echo $row->title?></p>
                    </td>
                    <td width="70%">
                      <p><a href="javascript:na_open_window('win', 'download.php?dl_id=<?php echo "$dl_id"?>', 200, 200, 300, 200, 0, 0, 0, 0, 0)" target="_self" title="<?php echo $row->title?>"><?php echo 'Datei herunterladen'?></a></p>
                    </td>
                  </tr>
                  <tr>
                    <td width="30%">
                      <p><img src="dls/<?php echo $dlcat;?>/img/<?php echo $img?>" width="150" height="100"></p>
                    </td>
                    <td width="70%">
                      <p><?php echo $row->description?></p>
                    </td>
                  </tr>
                  <tr width="100%">
                    <td colspan="2">
                      <p>&nbsp;</p>
                    </td>
                  </tr>
                </table>
                <?php
                
    }
              }
            
    ?>
          <td>
        </tr>
      </table>
      <?php
      
    }
      else
      {
      
    ?>
      <table class="boxes" cellpadding="0" cellspacing="0" width="100%">
        <tr class="header_boxes">
          <td class="header_boxes">
            <p>Keine Downloads</p>
          </td>
        </tr>
        <tr>
          <td>
            <p align="center">In dieser Kategorie sind derzeit keine Downloads verfügbar. Schau zu einem späteren Zeitpunkt noch einmal nach.</p><br>
          </td>
        </tr>
      </table>
      <?php
      
    }
    ?>
    download.php (popupfenster, welches geöffnet wird)
    PHP-Code:
    <?php
    include("dbconnect.inc.php");

    $dl "SELECT filename, downloads FROM rhs_".$prjct."_files WHERE id = ".$dl_id." ORDER BY id";
    $get_dl mysql_query($dl) or die(mysql_error());
    while(
    $row mysql_fetch_object($get_dl))
      {
      
    $filename $row->filename;
      
    $downloads $row->downloads;
      }
    mysql_free_result($get_dl);

    $downloads++;

    $new_dl_count "UPDATE rhs_".$prjct."_files Set downloads = '$downloads' WHERE id = ".$dl_id."";
    $insert_new_dl_count mysql_query($new_dl_count);

    ?>

    <html>

    <head>
    <title><?php echo $site_title?></title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta http-equiv="refresh" content="2; URL=dls/<?php echo $filename?>">
    </head>

    <body>
    <table border="0px" width="100%">
      <tr>
        <td width="100%">
          <p align="center">Sollte der Download nicht automatisch starten, klicke bitte<br><br><a href="dls/<?php echo $filename?>">- HIER -</a></p>
        </td>
      </tr>
      <tr>
        <td width="100%">
          <p align="center"><br><br><a href="" onClick="JavaScript:self.close()">- Fenster schließen -</a></p>
        </td>
      </tr>
    </table>
    </body>
    als Fehlermeldung kommt NUR bei dem popup, der download.php:
    Die Datenbank existiert nicht
    ick verzweifel bald. danke schonmal für hilfe.

  • #2
    Wo wird die config.inc.php includet?

    Bist du dir SICHER, dass alle Variablen den Inhalt haben den du erwartest - hast du das ÜBERPRÜFT oder vermutest du das nur?

    Was sagt ein mysql_error() was sagt ein print_r($db_name); ERROR_REPORTING() mal auf E_ALL geschaltet?
    [URL="https://www.quizshow.io/"]Create your own quiz show.[/URL]

    Kommentar


    • #3
      Zitat von agrajag Beitrag anzeigen
      Wo wird die config.inc.php includet?
      jetzt auch in der download.php - daran lag es.

      vielen dank für den hinweis.

      Kommentar

      Lädt...
      X