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.

blob

Empfohlene Antworten

Hallo

ich lese aus der MySql- Datenbank Werte und Bilder als blob aus. Jedoch hat es in meinem script einen fehler, der die Bilder nur als ascii anzeigt und nicht als echte Bilder. Ich habe im www bis jetzt noch nicht wirklich etwas brauchbares gefunden dass mir weiterhilft!

mein code:

//Datenbank abfrage

$res = mysql_query("select * from reisemobile ORDER BY Hersteller ASC");

?>

<table border="1" cellspacing="2" cellpadding="0">

<tr>

<td><b>Hersteller</b></td>

<td><b>Modell</b></td>

<td><b>Laenge (m)</b></td>

<td><b>Motor</b></td>

<td><b>Km</b></td>

<td><b>Jahrgang</b></td>

<td><b>Ausstattung</b></td>

<td><b>Preis (Sfr.)</b></td>

<td><b>360° Bild</b></td>

<?php while($result = mysql_fetch_row($res))

{ ?>

<tr>

<td><?php echo $result[1]; ?></td>

<td><?php echo $result[2]; ?></td>

<td><?php echo $result[3]; ?></td>

<td><?php echo $result[4]; ?></td>

<td><?php echo $result[5]; ?></td>

<td><?php echo $result[6]; ?></td>

<td><?php echo $result[7]; ?></td>

<td><?php echo $result[8]; ?></td>

<?php $pic = $result[9]; ?>

<td><?php echo" <img src=\"$pic\" width=130 height=160>";?>

<?php

}

?>

</tr>

</table>

wer kann mir das Problem in rot lösen?????

Danke

PHP braucht auf deinem Webserver in irgendeinem Verzeichnis Schreibberechtigung. Dort erstellst du ein temporäres Bild und bindest das in deinem Script ganz normal mit img ein.


//an der roten Stelle:
<?php
$fh = fopen("/irgendwo/temp_bild.jpg","w");
if ($fh !== FALSE)
{
fwrite($fh,$result[9]);
fclose($fh);

echo "<img src=\"/irgendwo/temp_bild.jpg\"/>";
}
?>
[/PHP]

Die Fehlerbehandlung und das zufällige Auswählen des Dateinamens mußt du halt noch ergänzen.

Hallo Abraham,

die Referenz auf ein Bild muss eine URL enthalten und nicht die Bilddaten selber - darum wird das Bild nicht korrekt ausgegeben.

Erstelle ein zusätzliches Script welches die id des datensatzes bekommt, und sich um die Ausgabe des Bildes kümmert, z.B.:

Ich gehe mal davon aus, dass das Result-Array an 1. Stelle die ID des Datensatzes enthält ($result[0]).


<?php $picid = $result[0]; ?>

<?php echo" <img src=\"pic.php?picid=$picid\" width=130 height=160>";?>

Und im Script pic.php:

<?php


//uebergabeparameter picid abfangen

if (isset($_GET["picid"]) && !empty($_GET["picid"])) {

	$picid = $_GET["picid"];

} elseif (isset($HTTP_GET_VARS["picid"]) && !empty($HTTP_GET_VARS["picid"])) {

	$picid = $HTTP_GET_VARS["picid"];

} else {

	//hier optional code einfügen, wenn keine picid übergeben wurde

	return;

}


//datenbank abfrage

$res    = mysql_query("SELECT name_der_spalte_welches_das_bild_enthaelt FROM reisemobile WHERE name_der_spalte_fuer_id = $picid");

$result = mysql_fetch_row($res);


if (is_array($result)) {

	//bild ausgeben

	echo $result[0];

} else {

	//hier optional code einfügen, wenn das bild aus der db nicht ausgelesen wurde

}


?>

Gruß

xmurrix

Ich tippe mal darauf, dass du nicht den richtigen Header gesetzt hast. PHP schickt standartmäßig text/html raus.

Damit Bilder auch als Bilder erkannt werden solltest du aber image/jpeg oder ähnliches schicken.


// so könnte der Link aussehen
<img src="bild.php?id=123" />
[/PHP]

[PHP]
// das macht dann bild.php:
header("Content-Type: image/$type");
echo $blob;

$type ist die Art des Bildes (jpeg, gif, png) und $blob deine ASCII-Bilddaten.

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.