-1

I have been searching for the error for quite a while, but it seems like I can not find out, what is wrong. I am working as a working student at the Chair for Marketing and we do have our own homepage, whose maintenance is my job. Someone has written the code years ago and so far there was never a problem. But today, I have noticed that suddenly the database content is not shown on our homepage. Here is the code and I hope, you can help me to identify the problem.

    <div id="gContent">

        <?php include("inc/navmain.inc"); ?>
        <?php include ("v2/db/db.php"); ?>
    <?php 
    $sql_ueber = "SELECT ". 
                "ws.*, p.*". 
            "FROM ". 
                "workshop ws, coeContacts p ". 
            "WHERE ". 
                "(ws.Umkreis = 'ueber' AND ws.KontaktPerson = p.id)ORDER BY -ws.Anfang DESC";

    $sql_muenster = "SELECT ". 
                "ws.*, p.*". 
            "FROM ". 
                "workshop ws, coeContacts p ". 
            "WHERE ". 
                "(ws.Umkreis = 'reg_muenster' AND ws.KontaktPerson = p.id) ORDER BY -ws.Anfang DESC";

    $sql_berlin = "SELECT ". 
                "ws.*, p.*". 
            "FROM ". 
                "workshop ws, coeContacts p ". 
            "WHERE ". 
                "(ws.Umkreis = 'reg_berlin' AND ws.KontaktPerson = p.id) ORDER BY -ws.Anfang DESC"; 

    $sql_koeln = "SELECT ". 
                "ws.*, p.*". 
            "FROM ". 
                "workshop ws, coeContacts p ". 
            "WHERE ". 
                "(ws.Umkreis = 'reg_koeln' AND ws.KontaktPerson = p.id) ORDER BY -ws.Anfang DESC";      


    $result_ueber = mysql_query ($sql_ueber); 
    $result_muenster = mysql_query ($sql_muenster); 
    $result_berlin = mysql_query ($sql_berlin);
    $result_koeln = mysql_query ($sql_koeln);


    ?>



    <script src="js/jquery-1.7.1.min.js"></script>
     <!--Script zum Anzeigen der Infos pro Uni und zum aktualisieren des Submen¸s -->
     <script>
     function toggleMe(info, link){
      var ids = ["table_Ueberregional", "table_Muenster", "table_Berlin","table_Koeln"];
      var infLink = ["termineUberregional", "termineMuenster", "termineBerlin","termineKoeln"];
      var length = ids.length;
      for(var i=0; i < length; i++){
        document.getElementById(ids[i]).style.display="none";
        $("#" + infLink[i]).removeClass("active");
      }
        document.getElementById(info).style.display="block";
        $("#" + link).addClass("active");
      return true;
    }
 $(document).ready(function(){
    $("#termineUberregional").click(function(event){
      toggleMe('table_Ueberregional','termineUberregional');
      });

    $("#termineMuenster").click(function(event){
      toggleMe('table_Muenster','termineMuenster');
        });
    $("#termineBerlin").click(function(event){
      toggleMe('table_Berlin','termineBerlin');
        });
        $("#termineBerlin").click(function(event){
      toggleMe('table_Berlin','termineBerlin');
        });

        $("#termineKoeln").click(function(event){
      toggleMe('table_Koeln','termineKoeln');
      });
    });
    </script>

            <div id="table_Berlin" style="display:none">
                <h1>Termine f&uuml;r Berlin</h1>
                <table id="table_termine">
                <th>Kooperationspartner</th><th>Zeitraum</th><th>Ansprechpartner</th><th>Anhang</th>
                <?php 
                    while($data = mysql_fetch_array($result_berlin) ) {
                    if($data["Umkreis"] != "reg_berlin"){
                        continue 1;
                    }
                        else{
                            echo '<tr>';
                            echo '<td>';
                                echo $data["Partner"];
                            echo '</td>';
                            echo '<td>';
                                if($data["Anfang"]){
                                    echo date('d/m/Y',strtotime($data["Anfang"])). ' - ';
                                    if($data["Ende"]){
                                        echo date('d/m/Y',strtotime($data["Ende"])) ;
                                    }
                                }
                                else {
                                    echo 'Ank&uuml;ndigung folgt';
                                }
                            echo '</td>';
                            echo '<td>';
                                echo '<a href="mailto:'.$data["email"]. '">'. $data["First_Name"]. " " . $data["Last_Name"];
                            echo '</td>';
                            echo '<td>';
                            if($data["Anhang"] == "N/A"){
                                echo "";
                            }
                            else {
                                echo '<a href="upload/'.$data["Anhang"].'" target="_blank"><img src="images/pdf_icon.gif" height="18px" width="18px"/></a>';
                            }
                            echo '</td>';
                            echo '</tr>';
                        }
                    };
                ?>
                </table>
                <p class="information">Nur CoEM-Studierende der Hochschule Berlin k&ouml;nnen sich f&uuml;r diese Workshops anmelden. Die Workshops werden bestm&ouml;glich nach Pr&auml;ferenz zugewiesen.</p>
            </div>
5
  • Please stop! Look, and realize that the use of the mysql_* series of functions is depreciated, and also removed in php 7. Code for the future, switch to mysqli/PDO! Jan 15, 2018 at 16:14
  • Also look into utilizing error catching and display for mysqli (mysqli_error), so you can display sql errors to know why certain queries are not working. Jan 15, 2018 at 16:16
  • So you say, I have to write the whole code new? I am absolutely not into PHP or programming in general and was only responsible for easy maintenance :( Jan 15, 2018 at 16:28
  • Oh, this is OLD code you are fixing? You may be able to hold off, just fix whats broken. However know that any PHP upgrade may render all of the code unusable! :( Jan 15, 2018 at 16:33
  • I don't know whether it is old cold or not, as written before, I am absolutely not into PHP or in general into script languages and so far only maintained, when for example a new statement or new announcement, picture needed to be uploaded. So you think it's not required to completely change the code and adapt to mysqli? Jan 16, 2018 at 14:01

1 Answer 1

1
display:none

this is the problem, remove it.

8
  • Sry, still not working :( I removed it, but I can still not see content of my DB table... Jan 15, 2018 at 15:52
  • what is database connection used, and what is in $result_berlin variable? There's no error in the code except style property
    – user8713979
    Jan 15, 2018 at 15:57
  • I have added further code into my initial post. I also think that there might be a db connection error, but the settings seem to be correct. $result_berlin variable contains an sql_query that only shows workshop dates, which take place in Berlin. I have added the code, maybe you can have a look at it. thank you very much for your help! Jan 15, 2018 at 16:00
  • "ws.*, p.*". at this line add a space in ending up and var dump results if necessary! happy coding
    – user8713979
    Jan 15, 2018 at 16:05
  • Thanks a lot. But what do you mean with add a space? There is already a space between ws.* and p.* or do you mean something else? And shall I create a var dump result? Jan 15, 2018 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.