wieso PHP Parse error: syntax error, unexpected token ";" in /home/emmanuel/Downloads/hp.php on line 11?
<link rel="stylesheet" href="style.css">
<?php
$db = unserialize(file_get_contents('data.php'));
if($db == false){
        $db = array();
}
if($_POST['mail'] == ''){
        if($_POST['name'] == ''){
                if($_POST['pass'] == ''){a
                        if(!array_key_exists($_POST['mail'], $db){
                                $db[$_POST['mail']] = [$_POST['name'], []];
                                file_put_contents('data.php', serialize($db));
                        } 
                }
        }
}
?>
<form action="" method="post">
    <center>
        <label for="firma_name" >name:</label><br>
        <input type="text" class="input" name="name" autocomplete="off"><br>
        <label for="produkte">email:</label><br>
        <input type="text"  class="input" name="mail" autocomplete="off"><br>
        <label for="adresse">pass:</label><br>
        <input type="text"  class="input" name="pass" autocomplete="off"><br>
        <input type="submit" class="anmelde_button" value="anmelden">
    </center>
</form>

wieso PHP Parse error: syntax error, unexpected token ";" in /home/emmanuel/Downloads/hp.php on line 11?

HTML, Webseite, CSS, JavaScript, HTML5, Datenbank, JQuery, MySQL, PHP, Programmiersprache, Webdesign, Webentwicklung, phpMyAdmin
warum funktioniert dieses xslt script nur im Internet Explorer abere nicht in chrome oder edge?

Hallo,

ich habe ein XSLT Script das eine xml zu einer Tabelle umformen soll. Das Script funktioniert nur in IE11 aber nicht in den anderen Browsern.

...

$index_file="index_station.php";

...

echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
echo '<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" >';
?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
    xmlns:js="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
 

...
      <?php include "index_station_checkbox.php"; ?>
      <hr/>   
      </td></tr>
         <xsl:apply-templates select="KKHABG/PATIENT">
         <xsl:sort select="<?php echo $xmlsort; ?>" />
         </xsl:apply-templates>
        </TABLE> 
     </BODY>
  </HTML>
</xsl:template>

<xsl:template match="PATIENT">
   <tr>
   <td valign="top" class="patientname">
      <xsl:element name="a">
      <xsl:attribute name="href">
      <xsl:value-of select="PatID/@VALUE"/>
      </xsl:attribute>
      <xsl:value-of select="nachname"/>, <xsl:value-of select="vorname"/>
      </xsl:element>
      <br/><xsl:value-of select="alter"/> - Zi./Bett: <xsl:value-of select="FALL/Behand/ort"/></td>
      <td valign="top" widht="100%">
      <table class="befund">
         <xsl:apply-templates select="FALL/Befund" >
         <xsl:sort select="BefZeit" order="descending"/>
         </xsl:apply-templates>   
      </table>
   </td>
   </tr>
   <tr><td colspan="2"><hr/></td></tr>
</xsl:template>

<xsl:template match="FALL/Befund">
<xsl:if test="<?php echo $sourcexml; ?>">
   <tr>
   <td valign="top" width="100px"><xsl:value-of select="Source"/></td>
   <td valign="top" width="40px">
      <div class="tooltip">
      <xsl:element name="a">
      <xsl:attribute name="href">
      <xsl:value-of select="ID/@ZIEL"/>
      <?php echo $var.'&amp;befart='.$befart.'&amp;befundid=';?><xsl:value-of select="ID/@VALUE"/>
      </xsl:attribute>
      <b><xsl:value-of select="ID"/></b>
      </xsl:element>
      <span class="tooltiptext2"><xsl:value-of select="ID/@TOOLTIP"/>      
      </span>
      </div>
   </td>   
   <td valign="top" width="150px"><xsl:value-of select="BefZeit"/></td>
   <td valign="top">
      <div class="tooltip">
      <xsl:choose>
      <xsl:when test="BefArt/@VALUE">
      <xsl:element name="a">
      <xsl:attribute name="href">
      <xsl:value-of select="BefArt/@VALUE"/>
      </xsl:attribute>
      <xsl:attribute name="target" >_blank</xsl:attribute>
      <b><xsl:value-of select="BefArt"/></b>
      </xsl:element>
      </xsl:when>
      <xsl:otherwise>
      <b><xsl:value-of select="BefArt"/></b>   
      </xsl:otherwise>
      </xsl:choose>
      <span class="tooltiptext">
         <!-- <b><xsl:value-of select="BefArt"/></b><br/> /-->
         <xsl:value-of select="BefText" disable-output-escaping="yes"/>
         <br/><br/>
      </span>
      </div>
      </td>
   </tr>
   </xsl:if>
</xsl:template>
</xsl:stylesheet>
HTML, PHP, Webentwicklung, XML
Spotify API Get Methode Blocked?

Moin, hab mal ne Frage, da ich es einfach nicht hin bekomme. Ich habe vor sowas wie eine Musikwunsch Seite für ein Schul Projekt zu coden. Dafür will ich die Spotify API nutzen, damit man über diese Songs suchen kann. Es kommt aber immer in der Netzwerkanalyse der Fehler NS_BINDING_ABORTED, obwohl mein Access Token korrekt ist. Hier ist meine script.js

const API_ENDPOINT = "https://api.spotify.com/v1/search";
const ACCESS_TOKEN = "your_access_token";

function searchSong() {
    let songName = document.getElementById("song-name").value;

    fetch(`${API_ENDPOINT}?q=${songName}&type=track`, {
        headers: {
            "Authorization": `Bearer ${ACCESS_TOKEN}`
        }
    })
    .then(response => response.json())
    .then(data => {
        let songResults = data.tracks.items;

        if (songResults.length > 0) {
            let songList = document.createElement("ul");

            for (let i = 0; i < songResults.length; i++) {
                let song = songResults[i];

                let songItem = document.createElement("li");
                songItem.innerHTML = `<a href="javascript:void(0)" onclick="selectSong('${song.id}')">${song.name} by ${song.artists[0].name}</a>`;

                songList.appendChild(songItem);
            }

            let songResultsDiv = document.getElementById("song-results");
            songResultsDiv.innerHTML = "";
            songResultsDiv.appendChild(songList);
        } else {
            let songResultsDiv = document.getElementById("song-results");
            songResultsDiv.innerHTML = "Sorry, no songs found.";
        }
    })
    .catch(error => {
        const errorMessage = document.getElementById("error-message");
        errorMessage.innerText = error;
    });
}

function selectSong(songId) {
    fetch("db.php", {
        method: "POST",
        body: JSON.stringify({songId: songId}),
        headers: {
            "Content-Type": "application/json"
        }
    })
    .then(response => response.json())
    .then(data => {
        if (data.success) {
            alert("Song added to the list!");
        } else {
            alert("Error adding song to the list.");
        }
    })
    .catch(error => {
        console.log(error);
    });
}

Hier ist dann noch die Index.html:

 <!DOCTYPE html>
<html>
<head>
    <title>DJ Song Request</title>
    <script src="script.js"></script>
</head>
<body>
    <h1>DJ Song Request</h1>
    <form>
        <label for="song-name">Enter song name:</label>
        <input type="text" id="song-name" name="song-name">
        <button type="submit" onclick="searchSong()">Search</button>
    </form>
    <div id="song-results"></div>
</body>
</html>

Vielleicht kann mir ja jemand helfen, da ich echt nicht mehr weiter weiß, im vorraus schon mal Vielen Dank ;D

HTML, Webseite, JavaScript, PHP, Spotify
Zahl mit Arduino an MySQL Datenbank senden?

Moin,

Vielleicht kann mir jemand helfen. Ich will, dass mein Arduino den Wert einer stinknormalen Variable an eine MySQL-Datenbank schickt. Ich bin mehr oder weniger am Verzweifeln, weil mir niemand helfen kann... Es kann doch nicht so schwer sein, ne blöde Zahl irgendwie in Form einer Variable an die Datenbank zu senden...

Ich benutze einen normales Arduino Uno, und ein W5100 ethernet shield

Mein bisheriger Ansatz war so: (Logindaten der Datenbank entfernt)

#include <Ethernet.h>

#include <MySQL_Connection.h>

#include <MySQL_Cursor.h>

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server_addr('localhost'); 

char user[] = "root";       

char password[] = "secret";    

// Sample query

char INSERT_SQL[] = "INSERT INTO Test (Sensor) VALUES ('3')";

EthernetClient client;

MySQL_Connection conn((Client *)&client);

void setup() {

 Serial.begin(115200);

 while (!Serial);

 Ethernet.begin(mac_addr);

 Serial.println("Connecting...");

 if (conn.connect(server_addr, 3306, user, password)) {

  delay(1000);

 }

 else

  Serial.println("Connection failed.");

}

void loop() {

 delay(2000);

 Serial.println("Recording data.");

 

 MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);

 cur_mem->execute(INSERT_SQL);

 delete cur_mem;

}

SQL, HTML, Webseite, programmieren, Java, Cplusplus, Arduino, Datenbank, MySQL, PHP, Programmiersprache, Python, Softwareentwicklung, Webentwicklung, phpMyAdmin, Raspberry Pi
Warum kann dieser php code keine Verbindung zur Datenbank herstellen?

Ich sitze hier und verzweifle förmlich daran, warum sich die eingegebenen Daten aus:

<!DOCTYPE html>
<html>
  <head>
    <h1>Der Weg ins Paradies</h1>
    <link rel="stylesheet" href="GL.css">
  </head>
    <p>Die Welt dadraußen ist trist, doch <br> sein kein Schaf, sei ein Wolf</p>
    <form method="post" action="Registrierungsseite.php">
      <p><label>Name:<br><input type="text" name="Name"></label></p>
      <p><label>E-Mail:<br><input type="text" name="Mail"></label></p>
      <p><label>Passwort:<br><input type="password" name="Passwort"></label></p>
      <p><label>IBAN:<br><input type="text" name="IBAN"></label></p>
      <p><input type="submit" value="Registrieren"></p>
    </form>
  </body>
</html>

nicht in der MySQL-Datenbank wiederfinden.

Meine PHP-Datei ist diese hier:

<?php
  // Get the form data
  $name = $_POST['name'];
  $email = $_POST['email'];
  $password = $_POST['password'];
  $iban = $_POST['iban'];

  // Connect to the MySQL database
  $db = mysqli_connect("localhost", "root", "", "paradies");

  // Check if the connection was successful
  if (mysqli_connect_errno()) {
    // If the connection failed, display an error message and exit
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    exit;
  }

  // Insert the form data into the MySQL database
  $query = "INSERT INTO paradies (name, email, password,iban) VALUES ('$name', '$email', '$password', '$iban')";

  if (mysqli_query($db, $query)) {
    // If the insert was successful, redirect the user to the login page
    header("Location: GL.php");
    exit;
  }
  else {
    // If the insert failed, display an error message
    echo "Error: " . $query . "<br>" . mysqli_error($db);
  }

  // Close the MySQL connection
  mysqli_close($db);
?>

Ich sehe den Fehler einfach nicht, da sobald man die Daten absendet, es zwar zur PHP-Datei weitergeleitet wird, dann jedoch lediglich der Code zu sehen ist. Die Datenbank hat dann natürlich auch keinen Eintrag.

Danke im Voraus.

HTML, Datenbank, MySQL, PHP, phpMyAdmin
Wert einer HTML Tabelle an Popup übergeben?

Ich habe eine, mit PHP dynamisch erzeugte Tabelle. In dieser Tabelle möchte ich die ID aus der ersten Spalte auslesen, die einem bestimmten Datensatz innerhalb meiner Datenbank zugeordnet ist. Wenn ich auf eine besstimmte Zeile klicke möchte ich auch die ID aus dieser Zeile haben. Diese soll wiederum an ein Popup übergeben werden, damit ich innerhalb dieses Popups Daten aus meiner Datenbank auslesen kann. Anbei findet ihr noch Bilder zu meiner Tabelle und dem Popup. Ich freue mich über jede Hilfe, bin schon seit Stunden am suchen.

    <form>
    <tr onclick="dialogOeffnen('loslegen-dialog')">
    <td>
            <?php echo $row["ID"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Vorname"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Nachname"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Vorname2"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Nachname2"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Vorname3"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Nachname3"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Vorname4"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Nachname4"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Titel"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Standort"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Klasse"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Beginn"] . "<br>"; ?>
          </td>
          <td>
            <?php echo $row["Abgabe"] . "<br>"; ?>
          </td>
          <td>
            <center><a href=<?php echo "uploads/" . $FileActualName?>">Link</a></center>
          </td>
          <td>
            <input  type="submit" onclick="dialogOeffnen('loslegen-dialog')" value="<?php echo $row["Genehmigt"]?>">
          </td>
          <td>
            <?php echo $row["Erstellt"] . "<br>"; ?>
          </td>
      </tr>
  </form>

Aktuell wird immer nur der Titel der letzten Zeile übergeben.

Bild zum Beitrag
HTML, Webseite, Datenbank, PHP, Webentwicklung
c# http post request?

C#

            var httpClient = new HttpClient();
            var values = new Dictionary<string, string>
            {
                { "username", UsernameTextBox.Text },
                { "email", EmailTextBox.Text }
            };

            var content = new FormUrlEncodedContent(values);

            var response = await httpClient.PostAsync("http://subdomain.domain.tld/file.php", content);

            var responseString = await response.Content.ReadAsStringAsync();
            FSCMessageBox.Show(responseString);

PHP

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHP/PHPMailer/src/Exception.php';
require 'PHP/PHPMailer/src/PHPMailer.php';
require 'PHP/PHPMailer/src/SMTP.php';
$mail = new PHPMailer(true);
$whitelist = array("...");
$auth = false;
foreach($whitelist as $ip)
{
    if($ip == $_SERVER['REMOTE_ADDR']) {$auth = true;}
}
if(!$auth)
{
    http_response_code(403);
    exit();
}
try
{
    $code = "";
    for ($i = 0; $i < 8; $i++)
    {
        $ascii = rand(48, 122);
        if ($ascii > 57 && $ascii < 65 || $ascii > 90 && $ascii < 97)
        {
            $ascii -= 7;
        }
        $code .= chr($ascii);
    }
    echo $code;
    $mail->SMTPDebug = 2;                                       
    $mail->isSMTP();                                            
    $mail->Host       = "...";                    
    $mail->SMTPAuth   = true;                             
    $mail->Username   = "...";                 
    $mail->Password   = "...";                        
    $mail->SMTPSecure = "tls";                              
    $mail->Port       = 587;  
    $mail->setFrom("...", "...");           
    $mail->addAddress($_POST['email']);          
    $mail->isHtml();       
    $mail->Subject = "Verification Code";
    $mail->Body    = 
    "
    <h1>Hello, ".$_POST['username']."!</b1>
    <h4>Your verification code is ".$code.".</h4>
    <p>If you don't know why you received this E-Mail, you can safely ignore and delete it.</p>
    ";
    $mail->send();
    http_response_code(200);
}
catch (Exception $e)
{
    http_response_code(503);
    exit(); 
}
?>

Ist da ein Fehler? Wenn ich den php code ohne dem Post Request und mit festen Werten ausführe, geht alles. Also muss es doch am c# code liegen, oder?

Wenn ich es mit dem Post Request versuche, wird im Programm eine MessageBox angezeigt, wo einfach garnichts drin steht.

FSCMessageBox.Show(responseString);

Email wird auch nicht verschickt.

Die Daten wie host, username, password, email etc. sind alle richtig, da liegt der Fehler nicht.

HTML, Webseite, PHP, Webentwicklung
PHPMailer schickt unendlich E-Mails?

Ich habe eine index.php Datei auf meinem Webspace:

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '.../PHPMailer/src/Exception.php';
require '.../PHPMailer/src/PHPMailer.php';
require '.../PHPMailer/src/SMTP.php';
$mail = new PHPMailer(true);
try
{
    $mail->SMTPDebug = 2;                                       
    $mail->isSMTP();                                            
    $mail->Host       = "...";                    
    $mail->SMTPAuth   = true;                             
    $mail->Username   = "...";                 
    $mail->Password   = "...";                        
    $mail->SMTPSecure = "tls";                              
    $mail->Port       = 587;  
    $mail->setFrom("...", "...");           
    $mail->addAddress("email1@...");
    $mail->addAddress("email2@...");      
    $mail->isHTML();                        
    $mail->Subject = "...";
    $mail->Body    = "<h1>...</h1>
    <h3>...</h3>
    <p>...</p>";
    $mail->send();
    echo "E-Mail geschickt!";
}
catch (Exception $e)
{
    echo "Konnte nicht geschickt werden! Mailer Error: {$mail->ErrorInfo}";
}
?>

Das funktioniert auch, wenn man auf die Website geht, steht da "E-Mail geschickt", und die Emails kommen auch an.

Problem: Jetzt werden jede 1-30 min Emails verschickt, bei der email1 email adresse ist alles normal, bei email2 ist der ganze Text zitiert. Wieso werden jetzt immer E-Mails verschickt? Wieso ist der Text bei email2 zitiert?

Webseite, PHP, Webentwicklung

Meistgelesene Fragen zum Thema PHP