0

Hey guys im trying to connect to an database and collect some data out of the table zuordnung but it doesn't work correct everything i get is a white page im frustated because i can't find the error mabye another pair of eyes sees it so here is what i have so far:

<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php
    include ("db_login.php");

    $link = mysql_connect($host, $user, $pass) or die ("Keine Verbindung zu der Datenbank moeglich.");
    mysql_select_db($db, $link);

    $sql = "SELECT ID_Zuordnung, HW_Typ, Hostname_alt, Username, Emailadresse, Datum_Ausgabe, Abteilung 
        FROM zuordnung
        WHERE Status_Tausch='OK' AND Status_Altgeraet='NOK'
        ORDER BY Hostname_alt;";

    $result = mysql_query($sql);
    $resultarray = mysql_fetch_array($result); 
            echo('<p>'.$resultarray['HW_Typ']."</p>");
            echo('<p>'.$resultarray['Hostname_alt']."</p>");
            echo('<p>'.$resultarray['Username']."</p>");
            echo('<p>'.$resultarray['Emailadresse']."</p>");
            echo('<p>'.$resultarray['Datum_Ausgabe']."</p>");
            echo('<p>'.$resultarray['Abteilung']."</p>");
    ?> 
 </body>
</html>
5
  • your include command has a space inside, I would guess that this makes trouble. Commented Oct 8, 2012 at 13:01
  • test if mysql_select_db works. Test if $result is valid. Call mysql_last_error(). Basically - debug it! Commented Oct 8, 2012 at 13:01
  • @AndrewHall how can i do this? Commented Oct 8, 2012 at 13:11
  • Have a look at this: php.net/manual/en/function.mysql-error.php Commented Oct 8, 2012 at 13:25
  • @AndrewHall ok tried their sample and got an 0 what does this now mean for me? Commented Oct 8, 2012 at 13:38

3 Answers 3

1
while($resultarray = mysql_fetch_array($result))
{
            echo('<p>'.$resultarray['HW_Typ']."</p>");
            echo('<p>'.$resultarray['Hostname_alt']."</p>");
            echo('<p>'.$resultarray['Username']."</p>");
            echo('<p>'.$resultarray['Emailadresse']."</p>");
            echo('<p>'.$resultarray['Datum_Ausgabe']."</p>");
            echo('<p>'.$resultarray['Abteilung']."</p>");

}
Sign up to request clarification or add additional context in comments.

1 Comment

I think there is no data in your database . check whether is it single data ?
0

try this

require_once($_SERVER['DOCUMENT_ROOT']."db_login.php");

instead of Include

and u need to echo resultarray in a while loop if u are having more than 1 record.

Comments

0

are u forgotten to loop
use loop,like this.

while($resultarray = mysql_fetch_array($result))
{
echo('<p>'.$resultarray['HW_Typ']."</p>");
            echo('<p>'.$resultarray['Hostname_alt']."</p>");
            echo('<p>'.$resultarray['Username']."</p>");
            echo('<p>'.$resultarray['Emailadresse']."</p>");
            echo('<p>'.$resultarray['Datum_Ausgabe']."</p>");
            echo('<p>'.$resultarray['Abteilung']."</p>");

}

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.