Hallo Leute,
ich lerne gerade PHP und MySql, als Übung schreibe ich zur Zeit ein Suchformular. Dafür habe ich habe 2 Datein erstellt. Auf dem Server läuft XAMPP 1.4.12 mit (MySql 4.1.10 und PHP 5.0.3)
suche.html Code:
<html>
<head><title>Suche</title></head>
<body>
<form action="suche_f.php" method="post">
<div>SUCHE</div>
<table border="0" align="center">
<tr>
<td width="180">Name, Vorname
<input type="text" size="35" name="name"></td>
</tr>
<tr>
<td width="180">Firma
<input type="text" size="35" name="firma"></td>
</tr>
<tr>
<td align="right"><input type="submit" value="Suchen"></td>
</tr>
</table>
</form>
</html>
suche_f.php PHP-Code:
<?php
<html>
<head><title>Suche</title></head>
<body>
<table border="0" cellspacing="2" cellpadding="0" width="100%">
<?php
$name = $_POST["name"];
$firma = $_POST["firma"];
$mysqlhost="localhost";
$mysqluser="root";
$mysqlpw="";
$mysqldb="abc";
$connect = mysql_connect($mysqlhost, $mysqluser, $mysqlpwd) or die("Verbindungsversuch fehlgeschlagen");
mysql_select_db($mysqldb, $connect) or die("Konnte die Datenbank nicht waehlen.");
$r = mysql_query('SELECT name,firma FROM abc WHERE name ='$name' AND firma='$firma' ');
if (!$r) {
die('Ungültige Abfrage: ' . mysql_error());
}
while($a = mysql_fetch_array($r))
echo "<tr><td>" .$a['name'] ."</td><td>" .$a['firma'] ."</td>" ;
</div>
</body>
</html>
Nun bekomme ich aber keine Treffer sondern nur ein Fehler:
Parse error: syntax error, unexpected T_VARIABLE in C:\XAMPP\xampp\htdocs\neuneu\suche_f.php on line 15
Kann mir jemand ein Tipp geben? Wie bekomme ich das hin das als Ergebniss nur das angezeigt wird was zuvor als Suchbegriff
in der SUCHE.HTML angegeben worde (und am besten nicht genau, es reicht wenn der Begriff vorkommt).
Vielen Dank