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.

Probleme mit PHP-Script

Empfohlene Antworten

Veröffentlicht

Guten Morgen Allerseits.

Habe mal wieder ein kleines Problemchen.

Habe ein Progrämmchen in PHP geschrieben, welches sich aber nicht ausführt.

Könnt ihr mir sagen woran es liegt?

Hier mal der code:


<?php

$host = "***";
$nutzer = "***";
$pw = "***";
$dbname = "***";
$connect = mysql_connect($host, $nutzer, $pw);
$j=0;
$handle=opendir('H:\\F_200pcx\\');

while (false !== ($file = readdir($handle)))
{
if($j<2)
{
echo "nein<br>";
}
else
{
$altdatei = $file;
$blattnummer1 = substr($file, 0, 4).substr($file, 5, 1);
$i=0;
$koorddatei = fopen("koordinaten.txt", "r");
do
{
$i++;
if($i<617)
{
$contents = fread ($koorddatei, 51);
$blattnummer2 = "0".substr($contents, 13, 4);
if($blattnummer2==$blattnummer1)
{
$y = substr($contents, 22, 11);
$x = substr($contents, 38, 11);
$ox = $x + 250;
$oy = $y + 250;
$values = ' "'.$altdatei.'", "'.$blattnummer.'", "'.$x.'", "'.$y.'", "'.$ox.'", "'.$oy.'" ';
$sql = " INSERT INTO koordinaten (datei, blattnummer, luX, luY, roX, roY) VALUES ($values); ";
if(mysql_query($sql))
{
echo "Eintrag $i Erfolgreich in die Datenbank eingefügt!";
}
}
}
else
{
$contents = fread ($koorddatei, 52);
$blattnummer2 = substr($contents, 13, 5);
if($blattnummer2==$blattnummer1)
{
$y = substr($contents, 23, 11);
$x = substr($contents, 39, 11);
$ox = $ox + 250;
$values = ' "'.$altdatei.'", "'.$blattnummer.'", "'.$x.'", "'.$y.'", "'.$ox.'", "'.$oy.'" ';
$sql = " INSERT INTO koordinaten (datei, blattnummer, luX, luY, roX, roY) VALUES ($values); ";
if(mysql_query($sql))
{
echo "Eintrag $i Erfolgreich in die Datenbank eingefügt!";
}
}
}
}
while($blattnummer2!=$blattnummer1);
fclose ($koorddatei);
}
$j++;
};
closedir($handle);
?>[/PHP]

Er startet das Script nichtmal. Zmindest lädt und lädt er. Aber nix passiert. Habe versucht nen echo ""; an dateianfang zu setzen, aber nichtmal das macht er.

Wäre nett wenn ihr mir helfen könnt.

Gruß FiSiHRO

was soll er auch bei echo ""; machen... echo "foo"; mal probiert?

[doofer post].......................

Ja. Na Selbstverständlich habe ich da schon nen text reingesetzt *gg*

War nur zur veranschaulichung gedacht *g*

Gruß FisiHRO

Naja aber funzt eigentlich auch.

Hatte es vorher für ein anderes Script, was ähnlich gearbeitet hat.

Da hatte ich ledglich andere Daten in Dateien geschrieben.

Nun will ich neue Daten genauso auslesen wie die alten und in die DB packen aber nichts geht mehr *hmpf*

Gruß FiSiHRO

für sowas benutze ich meistens file() und explode() um dann mit arrays zu arbeiten.

sonst halt php-debugging, sprich alles mal ausgeben und angucken...

muss nu nochmal arbeiten :D

Der gute alte Debuger ^^

Fehler gefunden. Mal wieder DB-Zeilen die falschen Datentypen zugewiesen *grrrrrr*

Danke für die Hilfe.

Gruß FiSiHRO

okay doch keine entwarnung o.O

nu geht das wieder los keine ahnung warum.

Also fehlermeldung ist:

File 'c:\mysql\share\charsets\?.conf' not found (Errcode: 2) Character set '#48' is not a compiled character set and is not specified in the 'c:\mysql\share\charsets\Index' file

was heisst das? Ich tippe mal auf falschen datentyp?

$y = substr($contents, 22, 11);

$x = substr($contents, 38, 11);

$ox = $x + 250;

$oy = $y + 250;

$values = ' "'.$altdatei.'", "'.$blattnummer.'", "'.$x.'", "'.$y.'", "'.$ox.'", "'.$oy.'" ';

$sql = " INSERT INTO koordinaten (datei, blattnummer, luX, luY, roX, roY) VALUES ($values); ";

In DB:

datei ist varchar(50)

blattnummer ist int(10)

luX ist varchar(20)

luY ist varchar(20)

roX ist float

roY ist float

Ist das so korrekt?

Guß FiSiHRO

gib doch einfach mal den inhalt von $sql

File 'c:\mysql\share\charsets\?.conf' not found (Errcode: 2) Character set '#48' is not a compiled character set and is not specified in the 'c:\mysql\share\charsets\Index' file

was heisst das? Ich tippe mal auf falschen datentyp?

verwendet deine tabelle einen exotischen zeichensatz?

schau mal bei SHOW TABLE STATUS

schau, ob der charset in der statusanzeige des servers überhaupt gelistet ist, andernfalls hast du keinen support für diesen zeichensatz.

versuch das ganze testweise mal mit einem anderen charset:

ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name;

achtung, dabei könnten daten beschädigt werden oder verloren gehen.

s'Amstel

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.