Gegen Bilderklau - Das Original (https://www.gegen-bilderklau.net/index.php)
- Design, Website, Copyright (https://www.gegen-bilderklau.net/board.php?boardid=80)
--- Homepagehilfe (https://www.gegen-bilderklau.net/board.php?boardid=27)
---- Homepagehilfe - Archiv (https://www.gegen-bilderklau.net/board.php?boardid=139)
----- [PHP & MySQL] Suchfunktion (https://www.gegen-bilderklau.net/thread.php?threadid=94157)
Geschrieben von SammyLG am 10.01.2007 um 12:57:
Suchfunktion
Ich hab jetzt eine Suchfunktion, doch sie zeigt immer einen Fehler an. Das ist der Code:
php: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
|
<?php
mysql_connect("localhost","spiritanimals","verratnet") or die("Verbindung zur Datenbank gescheitert");
mysql_select_db("spiritanimals") or die("Datenbank nicht vorhanden");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Horses of Freedom</title>
</head>
<body>
<form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="post">
Wähle eine Farbe aus: <br>
<select name="color">
<option>Schimmel</option>
<option>Rappe</option>
<option>Brauner</option>
<option>Fuchs</option>
<option>Pinto</option>
<option>Falbe</option>
</select>
<input type="submit" name="send" value="Finden!">
</form>
<?php
if (isset($_POST[send])) {
$color = $_POST[color];
$sql_select = "SELECT * FROM aussehen WHERE farbe='$color'";
$res = mysql_query($sql_select);
while ($row = mysql_fetch_assoc($res)) {
echo "<table width=400>
<tr><td>Nr. $row[id]</td><td><b>$row[color]</b></td></tr>
<tr><td colspan=2><img src=$row[datei] alt=$row[id], $row[color]></td></tr>
</table>";
?>
</body>
</html>
|
|
Und das ist die Fehlermeldung:
Parse error: syntax error, unexpected $end in /usr/export/www/vhosts/funnetwork/hosting/spiritanimals/lillybereich/vph/la
tinoneu/aussehen/suche.php on line 36
Aber es gibt überhaupt gar keine Reihe 36! Deswegen ja...
Geschrieben von Unicorn am 10.01.2007 um 13:21:
Das Problem liegt vermutlich daran, dass du If/While-Klammern angefangen, aber nicht wieder beendet hast.. füge doch vor ?> noch }} ein (es sind ja zwei, die nicht abgeschlossen sind, wenn ich richtig geschaut habe), und sag, ob es geht.. diese Fehlermeldung ist typisch dafür, dass etwas nicht ordnungsgemäss geschlossen wurde.
Geschrieben von SammyLG am 10.01.2007 um 17:33:
Die Suchfunktion wird angezeigt, aber dann kommt wieder Fehler.
Der neue Code:
php: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
|
<?php
mysql_connect("localhost","spiritanimals","verratnet") or die("Verbindung zur Datenbank gescheitert");
mysql_select_db("spiritanimals") or die("Datenbank nicht vorhanden");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Horses of Freedom</title>
</head>
<body>
<form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="post">
Wähle eine Farbe aus: <br>
<select name="color">
<option>Schimmel</option>
<option>Rappe</option>
<option>Brauner</option>
<option>Fuchs</option>
<option>Pinto</option>
<option>Falbe</option>
</select>
<input type="submit" name="send" value="Finden!">
</form>
<?php
if (isset($_POST[send])) {
$color = $_POST[color];
$sql_select = "SELECT * FROM aussehen WHERE farbe='$color'";
$res = mysql_query($sql_select);
while ($row = mysql_fetch_assoc($res)) {
echo "<table width=400>
<tr><td>Nr. $row[id]</td><td><b>$row[color]</b></td></tr>
<tr><td colspan=2><img src=$row[datei] alt=$row[id], $row[color]></td></tr>
</table>"; }}
?>
</body>
</html> |
|
Geschrieben von _-PinkPunker-_ am 10.01.2007 um 17:50:
Gehört das nicht so..?
php: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
|
<?php
if (isset($_POST[send])) {
$color = $_POST[color];
$sql_select = "SELECT * FROM aussehen WHERE farbe='$color'";
$res = mysql_query($sql_select);
}
while ($row = mysql_fetch_assoc($res)) {
echo "<table width=400>
<tr><td>Nr. $row[id]</td><td><b>$row[color]</b></td></tr>
<tr><td colspan=2><img src=$row[datei] alt=$row[id], $row[color]></td></tr>
</table>";
}
?> |
|
Jetzt ist alles geschlossen,oder? =D
Geschrieben von SammyLG am 10.01.2007 um 18:03:
Ne, geht nicht.
Das ist der neue Code:
php: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
|
<?php
mysql_connect("localhost","spiritanimals","verratnet") or die("Verbindung zur Datenbank gescheitert");
mysql_select_db("spiritanimals") or die("Datenbank nicht vorhanden");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Horses of Freedom</title>
</head>
<body>
<form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="post">
Wähle eine Farbe aus: <br>
<select name="color">
<option>Schimmel</option>
<option>Rappe</option>
<option>Brauner</option>
<option>Fuchs</option>
<option>Pinto</option>
<option>Falbe</option>
</select>
<input type="submit" name="send" value="Finden!">
</form>
<?php
if (isset($_POST[send])) {
$color = $_POST[farbe];
$sql_select = "SELECT * FROM aussehen WHERE farbe='$farbe'";
$res = mysql_query($sql_select);
}
while ($row = mysql_fetch_assoc($res)) {
echo "<table width=400>
<tr><td>Nr. $row[id]</td><td><b>$row[color]</b></td></tr>
<tr><td colspan=2><img src=$row[datei] alt=$row[id], $row[farbe]></td></tr>
</table>";
}
?>
</body>
</html> |
|
Geschrieben von Unicorn am 10.01.2007 um 19:03:
Was gibt es denn jetzt für eine Fehlermeldung aus?
Geschrieben von SammyLG am 10.01.2007 um 19:26:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /usr/export/www/vhosts/funnetwork/hosting/spiritanimals/lillybereich/vph/la
tinoneu/aussehen/suche.php on line 30
Das ist die Fehlermeldung.
@May-Britt: Hab ich, geht trotzdem nicht.
Geschrieben von Punkverraeter am 10.01.2007 um 21:52:
ich bin ja kein php experte oder so aber was passiertd ennw enn du
code: |
1:
2:
3:
4:
5:
6:
|
$sql_select = "SELECT * FROM aussehen WHERE farbe='$farbe'";
$res = mysql_query($sql_select);
}
while ($row = mysql_fetch_assoc($res)) {
|
|
durch
code: |
1:
2:
3:
4:
5:
6:
|
$sql_select = "SELECT * FROM aussehen WHERE farbe='$farbe'";
}
while ($row = mysql_fetch_assoc(mysql_query($sql_select))) {
|
|
ersetzt?
ich weiß es istd as gleiche aber die pcs musds man net verstehen
auf jedenfall liegt der fehler irgfendwo in der funktion/variable
mysql_fetch_assoc()
Geschrieben von .Maybe am 10.01.2007 um 22:17:
Lass dir mal $sql_select ausgeben - vielleicht liegts ja gar nicht am code xD
Geschrieben von SammyLG am 10.01.2007 um 22:31:
edit: Problem hat sich gelöst. Bei PHPmyAdmin hatte ich die Datei Aussehen genannt, und im PHP code aussehen. Also Groß und klein Schreibungsfehler!
Forensoftware: Burning Board, entwickelt von WoltLab GmbH