Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Verbindung zu Datenbank

Empfohlene Antworten

Veröffentlicht

Hallo Leute,

meine sql-Datenbank liegt auf einem LINUX-Server. Mit Linux habe ich leider nicht viel zu tun. Nun möchte ich gerne die Datenbank ansprechen, aber leider funktioniert das nicht so wie ich es mir vorstelle.

Ich möchte per Browser an die Datenbank gelangen.

<?php

// Verbindung zum SQL-Server aufbauen....

// Sicherheitsabfrage im Falle eines Fehlschlages

// Verwendung des @-Zeichens werden automatische Fehlermeldung unterlassen

$hostname = "agent.hans.loc";

$verzeichnis = "root";

$password = "";

$dbconn = @mysql_connect($hostname,$verzeichnis,$password);

if (!$dbconn){

echo("<p>Verbindung zum Datenbankserver zur Zeit nicht möglich.</p>");

exit();

}

// Datenbank auswählen mit der gearbeitet werden soll

$db_name = "ORGSYS";

if (! @mysql_select_db("ORGSYS")){

echo("<p>Auswahl der ORGSYSdatenbank zur Zeit nicht möglich.</p>");

exit();

}

?>

Als Fehlermeldung bzw ich bekomme den Text Verbindung zum datenbankserver zur zeit nicht möglich...

Gebe ich las hostname "http://agent.hans.loc/"

funktioniert das auch nicht....

was muss ich tun??

Hi,

ich frage mich wieso du die Mysql Fehlermeldungen unterdrückst und nichtssagene eigene ausgibst? :confused:

Passe folgendes an deine Daten an und schau mal was dann passiert.


<?php
/* Connecting, selecting database */
$link = mysql_connect("mysql_host", "mysql_user", "mysql_password")
or die("Could not connect : " . mysql_error());
echo "Connected successfully";
mysql_select_db("my_database") or die("Could not select database");

/* Performing SQL query */
$query = "SELECT * FROM my_table";
$result = mysql_query($query) or die("Query failed : " . mysql_error());

/* Printing results in HTML */
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);
?>
[/php]

Gruß Jaraz

bekomme folgende fehlermeldung

Warning: Unknown MySQL Server Host 'http' (2) in /var/www/index2.php on line 3

Warning: MySQL Connection Failed: Unknown MySQL Server Host 'http' (2) in /var/www/index2.php on line 3

Could not connect : Unknown MySQL Server Host 'http' (2)

was ist eigentlich die() für ein befehl??

Original geschrieben von azubi-tigerente

was ist eigentlich die() für ein befehl??

beendet das Skript direkt.

host ist entweder der full qualified domain name (myhost.tld), localhost, oder direkt die ip.

http ist ein Protokoll und hat hier nix zu suchen.

Gruß Jaraz

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.