<?php
error_reporting(-1);
ini_set('display_errors', 'On');
?>
<?php
$servername = "xxxx";
$username = "xxxx";
$password = "xxxx";
$dbname= "xxxx";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
<?php
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="req.php" method="post">
<table>
<tr>
<td>Nome</td>
<td><input type="text" name="nome"/></td>
</tr><tr>
<td>Cognome</td>
<td><select name="cognome">
<?php
$stmt = $conn->prepare("SELECT id, cognome FROM req_table");
$stmt->execute();
// set the resulting array to associative
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
foreach($row as $value) {
echo '<option value="' . $row['id'] . '">';
echo '<option value="' . $row['cognome'] . '</option>';
}
}
</select></td>
</tr><tr>
<td>Indirizzo</td>
<td><select name="indirizzo">
<?php
$stmt = $conn->prepare("SELECT id, indirizzo FROM req_table");
$stmt->execute();
// set the resulting array to associative
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
foreach($row as $value) {
echo '<option value="' . $row['id'] . '">';
echo '<option value="' . $row['indirizzo'] . '</option>';
}
}
</select></td>
</tr><tr>
<td colspan="2" style="text-align: center;">
<input type="submit" name="Invia" value="Submit" />
</td>
</tr>
</table>
</form>
</body>
</html>
?>
- Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.43, 5.5.24 - 5.5.27, 5.6.8 - 5.6.11
- Parse error: syntax error, unexpected '<' in /in/SaDv4 on line 24
Process exited with code 255. - Output for 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '<' in /in/SaDv4 on line 24
Process exited with code 255. - Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected '{' in /in/SaDv4 on line 12
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- Parse error: parse error, unexpected '{' in /in/SaDv4 on line 12
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/SaDv4 on line 12
Process exited with code 255.
preferences:
192.01 ms | 1399 KiB | 141 Q