[PHP & MySQL] Suchfunktion

SammyLG
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...
Unicorn
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.
SammyLG
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>
_-PinkPunker-_
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
SammyLG
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>
Unicorn
Was gibt es denn jetzt für eine Fehlermeldung aus?
SammyLG
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.
Punkverraeter
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()
.Maybe
Lass dir mal $sql_select ausgeben - vielleicht liegts ja gar nicht am code xD
SammyLG
edit: Problem hat sich gelöst. Bei PHPmyAdmin hatte ich die Datei Aussehen genannt, und im PHP code aussehen. Also Groß und klein Schreibungsfehler!