Programmieren & Softwareentwicklung

2.479 Mitglieder, 27.582 Beiträge

Problem mit falscher Darstellung des Euro-Zeichens (€) in FPDF (erscheint als "â")?

Die restlichen Inhalte werden korrekt dargestellt, aber das Euro-Zeichen scheint nicht richtig kodiert zu werden. Meine Vermutung ist, dass es an der Zeichenkodierung (UTF-8 oder ISO-8859-1) oder an der verwendeten Schriftart liegt. Hat jemand eine Idee, wie ich dieses Problem beheben kann? Vielen Dank im Voraus für eure Hilfe! <?php session_start(); include "db.php"; // Holen der Bestelldaten $query = "SELECT u.vorname, u.nachname, b.bestelldatum, b.bestelladresse, bp.anzahl, bp.preis, p.produktname FROM user u JOIN bestellungen b ON u.id_user = b.id_user JOIN bestellungen_products bp ON b.id_bestellung = bp.id_bestellung JOIN products p ON bp.id_product = p.id_product WHERE b.id_bestellung = ?"; $id_order = $_GET["order_id"]; $stmt = $conn->prepare($query); $stmt->bind_param("i", $id_order); $stmt->execute(); $result = $stmt->get_result(); $order = $result->fetch_assoc(); $rechnungs_nummer = $id_order; $rechnungs_datum = $order["bestelldatum"]; $lieferdatum = date("Y-m-d", strtotime($rechnungs_datum . " +2 weeks")); // Neues PDF erstellen require_once(&apos;fpdf/fpdf.php&apos;); $pdf = new FPDF(); $pdf->AddPage(); // Titel und Rechnungsinformationen $pdf->SetFont(&apos;Helvetica&apos;, &apos;B&apos;, 16); $pdf->Cell(190, 10, &apos;Rechnung&apos;, 0, 1, &apos;C&apos;); $pdf->SetFont(&apos;Helvetica&apos;, &apos;&apos;, 12); $pdf->Cell(100, 10, &apos;Rechnungsnummer: &apos; . $rechnungs_nummer); $pdf->Cell(90, 10, &apos;Rechnungsdatum: &apos; . $rechnungs_datum, 0, 1); $pdf->Cell(100, 10, &apos;Lieferdatum: &apos; . $lieferdatum, 0, 1); // Empfängerinformationen $pdf->Ln(10); $pdf->Cell(100, 10, &apos;Kunde:&apos;); $pdf->Ln(5); $pdf->Cell(100, 10, $order["vorname"] . " " . $order["nachname"]); $pdf->Ln(5); $pdf->Cell(100, 10, $order["bestelladresse"]); // Postenübersicht $pdf->Ln(15); $pdf->SetFont(&apos;Helvetica&apos;, &apos;B&apos;, 12); $pdf->Cell(90, 10, &apos;Produkt&apos;, 1); $pdf->Cell(30, 10, &apos;Menge&apos;, 1); $pdf->Cell(30, 10, &apos;Preis&apos;, 1); $pdf->Cell(40, 10, &apos;Gesamt&apos;, 1, 1); $pdf->SetFont(&apos;Helvetica&apos;, &apos;&apos;, 12); $gesamtpreis = 0; do { $produktname = $order["produktname"]; $anzahl = $order["anzahl"]; $preis = $order["preis"]; $gesamt = $anzahl * $preis; $gesamtpreis += $gesamt; $pdf->Cell(90, 10, $produktname, 1); $pdf->Cell(30, 10, $anzahl, 1, 0, &apos;C&apos;); $pdf->Cell(30, 10, number_format($preis, 2, &apos;,&apos;, &apos;&apos;) . &apos; €&apos;, 1, 0, &apos;R&apos;); $pdf->Cell(40, 10, number_format($gesamt, 2, &apos;,&apos;, &apos;&apos;) . &apos; €&apos;, 1, 1, &apos;R&apos;); } while ($order = $result->fetch_assoc()); // Gesamtsumme $pdf->SetFont(&apos;Helvetica&apos;, &apos;B&apos;, 12); $pdf->Ln(5); $pdf->Cell(150, 10, &apos;Gesamtsumme:&apos;, 0, 0, &apos;R&apos;); $pdf->Cell(40, 10, number_format($gesamtpreis, 2, &apos;,&apos;, &apos;&apos;) . &apos; €&apos;, 0, 1, &apos;R&apos;); // Ausgabe des PDFs $pdf->Output(&apos;F&apos;, &apos;Rechnung_&apos; . $rechnungs_nummer . &apos;.pdf&apos;); //header("location:mail.php?order_id=$id_order") header("location:confirmation.php?order_id=$id_order") ?>

Pc Windows Script host?

Hallo, seit kurzer Zeit bekomme ich oft (jede 5 min) eine Fehlermeldung auf meinen pc. Der Windows Script host versucht die ganze Zeit ein Skript durchzuführen und schmeißt mich dann auf den Desktop und stört vor allem wenn ich etwas spiele. Der Fehler der mir angezeigt wird lautet: Die Skriptdatei ... wurde nicht gefunden und, Der Angegebenen Datei ist keine Anwendung zugeordnet. Wie kann ich diese scripte stoppen oder wenigstens das andauernde benachrichtigen verhindern ? Danke schonmal im Vorraus

Warum wirft htmlspecialchars einen Syntaxfehler in meinem PHP-Webshop-Code?

<?php include &apos;db.php&apos;; $query = "SELECT * FROM products"; $result = $conn->query($query); ?> <!DOCTYPE html> <html> <head> <title>Webshop</title> <style> /* Basic styling for the body */ body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 20px; display: flex; flex-direction: column; align-items: center; } /* Styling for the main heading */ h1 { color: #333; margin-bottom: 20px; } /* Container for all products */ .products-container { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; } /* Individual product card */ .product-card { background-color: #fff; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); overflow: hidden; width: 200px; text-align: center; padding: 15px; transition: transform 0.2s; } .product-card:hover { transform: scale(1.05); } /* Styling for the product image */ .product-card img { width: 100%; height: auto; border-radius: 8px; transition: opacity 0.2s; } .product-card img:hover { opacity: 0.8; } /* Styling for product name */ .product-card h2 { font-size: 1.2em; color: #333; margin: 10px 0; } /* Styling for product description and price */ .product-card p { color: #666; font-size: 0.9em; margin: 5px 0; } .product-card .price { font-weight: bold; color: #2a9d8f; } /* Link styling */ a { text-decoration: none; color: inherit; } </style> </head> <body> <h1>Products</h1> <div class="products-container"> <?php while ($product = $result->fetch_assoc()): ?> <div class="product-card"> <a href="product.php?id_product=<?= htmlspecialchars( $product[&apos;id_product&apos;]) ?>"> <h2><?= htmlspecialchars( $product[&apos;produktname&apos;]) ?></h2> <!-- Make the image clickable to open the product details page --> <img src="<?= htmlspecialchars($product[&apos;image_url&apos;]) ?>" alt="<?= htmlspecialchars($product[&apos;produktname&apos;]) ?>"> <p><?= htmlspecialchars($product[&apos;produktbeschreibung&apos;]) ?></p> <p class="price">Price: €<?= htmlspecialchars($product[&apos;preis_pro_prod&apos;]) ?></p> </a> </div> <?php endwhile; ?> </div> </body> </html>

Python discord NonType Error?

Ich habe einen Error in meinem Code: async def on_submit(self, interaction2: discord.Interaction): response = await sendRequests(str(self.username), str(self.email), str(self.password)) if response == "email": await interaction2.response.send_message("Incorrect email format", ephemeral=True) return if response == "password": await interaction2.response.send_message("Incorrect password format. The password must meet these requirements: \nOne Uppercase letter \nOne lowercase letter \nOne number\n A special character ", ephemeral=True) return if response == "maintenance": await interaction2.response.send_message("The system is currently under maintenance. Please look in #news for more infos.", ephemeral=True) query = "INSERT INTO users VALUES (?, ?, ?, ?)" main.cursor.execute(query, (interaction2.user.id, str(self.username), str(self.email), str(self.password))) main.database.commit() await interaction2.response.send_message("You are now in the registration process. This can take up to one hour.", ephemeral=True) channel = main.bot.get_channel(1309925591146958933) await channel.send("make a recaptcha, registration from user : " + str(interaction2.user.name) + " with id: " + str(interaction2.user.id)) Error: [2024-11-23 19:32:43] [ERROR ] discord.ui.modal: Ignoring exception in modal <RegisterModal timeout=None children=3>: Traceback (most recent call last): File ".venv\Lib\site-packages\discord\ui\modal.py", line 189, in _scheduled_task await self.on_submit(interaction) File "TestButton.py", line 41, in on_submit await channel.send("make a recaptcha, registration from user : " + str(interaction2.user.name) + " with id: " + str(interaction2.user.id)) ^^^^^^^^^^^^ AttributeError: &apos;NoneType&apos; object has no attribute &apos;send&apos;

Warum funktioniert password_verify nicht?

ich habe ein Login-System in PHP gebaut, aber aus irgendeinem Grund funktioniert die Passwortüberprüfung mit password_verify nicht, obwohl die Eingaben korrekt zu sein scheinen. Hier ist der relevante Codeabschnitt: <?php // login.php session_start(); include &apos;db.php&apos;; if ($_SERVER[&apos;REQUEST_METHOD&apos;] == &apos;POST&apos;) { $username = filter_input(INPUT_POST, "username", FILTER_SANITIZE_SPECIAL_CHARS); $password = filter_input(INPUT_POST, "password", FILTER_SANITIZE_SPECIAL_CHARS); $stmt = $conn->prepare("SELECT * FROM user WHERE username = ?"); $stmt->bind_param("s", $username); $stmt->execute(); $result = $stmt->get_result(); $user = $result->fetch_assoc(); if ($user && password_verify($_POST[&apos;password&apos;], $user[&apos;password&apos;])) { $_SESSION[&apos;id_user&apos;] = $user[&apos;id_user&apos;]; $_SESSION[&apos;role&apos;] = $user[&apos;role&apos;]; header(&apos;Location: index.php&apos;); } else { echo "Invalid credentials"; } } ?> <!DOCTYPE html> <html> <head> <title>Login</title> </head> <body> <h1>Login</h1> <form method="POST"> <input type="text" name="username" placeholder="Username" required> <input type="password" name="password" placeholder="Password" required> <button type="submit">Login</button> </form> </body> </html>

Ist Python Anfängerfreundlich?

Also mein eigentliches ziel ist es einen Discord Bot zu coden der quasi so ein kleines gatcha game ist wo man auf unserem server dann halt stündlich "ziehen" und halt sachen sammeln kann. Nach etwas Recherche kam ich dann auf Python zum umsetzen, allerdings habe ich noch nie irgendwas programmiert... ist mein Vorhaben realistisch? Ich denke halt nicht das es so schwer sein kann andererseits habe ich halt paar bedenken weil ich halt keine erfahrung habe/es halt nicht kann bzw. erst lernen muss

Raspberry Pi WLan Acces Point?

Guten Abend, ich habe einen Raspberry Pi 3 b (mit Pi OS Desktop 64 Bit) und möchte ihn so programmieren, dass er beim booten ein Wlan Acces point erstellt (ohne Internetzugang) und wenn sich ein Gerät damit verbindet öffnet sich eine html website, die der Pi sendet. Auf Der Website sieht man live Bilder von der Webcam am Pi und kann per Knöpfe die Servos am Pi bedienen. [Ferngesteuertes FPV Auto]. Jedoch ist GPT nicht hilfreich Youtube auch nciht und auch ich bin mit meinem Latein am Ende. Könnte mir da jemand bitte helfen?