Dobry den
uz dlhsiu dobu mam takyto problem:
zapisujem do tbl takimto prikazom :
$sql = "CREATE TABLE IF NOT EXISTS info_ziaci ( ".
"id INT NOT NULL AUTO_INCREMENT, ".
"meno text not null, ".
"priezvisko text not null, ".
"pohlavie text not null, ".
"datum_narodenia date not null, ".
"miesto_narodenia text not null, ".
"contact text not null, ".
"datum_nastupu date NOT NULL, ".
"obr BLOB NOT NULL, ".
"PRIMARY KEY ( id )); ";
@$vysledek = MySQL_Query("INSERT INTO info_ziaci VALUES
(null, '$meno','$priezvisko','$pohlavie','$datum_narodenia','$miesto_narodenia','$contact','$datum_nastupu','$obr')");
potom si zobrazim tbl a mam tam input type text pre vyhladavanie v tabulke:
$sql = "SELECT id,meno,priezvisko,pohlavie,datum_narodenia,miesto_narodenia,contact,obr,DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(datum_narodenia)), '%Y')+0 AS age, DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(datum_nastupu)), '%Y')+0 AS class FROM info_ziaci";
if (isset($_POST['search']))
{
$search_term = mysql_real_escape_string($_POST['search_box']);
$sql .= "WHERE miesto_narodenia = '{$search_term}'";
$sql .= "OR meno = '{$search_term}'";
$sql .= "OR priezvisko = '{$search_term}'";
$sql .= "OR datum_narodenia = '{$search_term}'";
$sql .= "OR pohlavie = '{$search_term}'";
$sql .= "OR contact = '{$search_term}'";
$sql .= "OR class = '{$search_term}'";
$sql .= "OR age = '{$search_term}'";
}
$query = mysql_query($sql) or die (mysql_error());
samotny input je nastaveny nasledovne: <td><input type="text" name="search_box" value="" /></td>
potom co si zadam napr. vyhladavat podla mena my zakazdim vrati nasledovnu chybu:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 'Richard'OR meno = 'Richard'OR priezvisko = 'Richard'OR datum_narodenia = 'Ric' at line 1
Vedeli by ste mi prosim poradit?
Dakujem
S pozdravom Rici.