hallo bin am php buch lesen und bau ein bsp. nach, doch leider ohne erfolg
habe ein html formular
	
mit suche.php
	
doch ich bekomme einen fehler
	
		
gebe ich die abfrage in den query browser mit werten statt variablen geht es einwandfrei. verstehe ich nicht
gruß
					habe ein html formular
PHP-Code:
	
	
<html>
<body>
Anzeige der Personen mit einem Gehalt zwischen:
<form action = "suche.php" method = "post">
    <input name = "ug"> Untergrenze<p>
    und <p>
    <input name = "og"> Obergrenze<p>
    <input type = "submit">
    <input type = "reset">
</form>
</body>
</html> 
PHP-Code:
	
	
<html>  <body>    
<?php     mysql_connect(localhost,root);     mysql_select_db("test");       
$sqlab = " SELECT gehalt FROM personen WHERE gehalt >=" . $_POST['ug'] . " AND gehalt <=" . $_POST['og'];         
$res = mysql_query($sqlab);     
$num = mysql_num_rows($res);     
if ($num==0) echo "keine passenden Datensätze gefunden";       
while ($dsatz = mysql_fetch_assoc($res))    
 {        echo $dsatz["name"] . ", "           . $dsatz["gehalt"] . "<br>";     }       
echo mysql_error();  ?>    </body>  </html>
doch ich bekomme einen fehler
			
			
				You have an error in your SQL syntax; 
check the manual that corresponds to your
MySQL server version for the right syntax
to use near 'AND gehalt <=' at line 1
	check the manual that corresponds to your
MySQL server version for the right syntax
to use near 'AND gehalt <=' at line 1
gruß
 
          

Kommentar