-
Operatori logici
Altro problema con sql .
uso una stringa sql come questa :
Select * from domande where id > 1
Mi restituisce il seguente errore :
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 '> 1' at line 1
Cosa c'è che non va?
Grazie moltissimo.
-
prova a metteri apici
Codice PHP:
SELECT * FROM domande WHERE id > '1'
fammi sapere :)
-
Purtroppo niente da fare mi dà lo stesso errore con l'aggiunta degli apipi.
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 '= '1'' at line 1
-
Puoi postare la query per intero e se possibile la struttura della tabella?
-
La struttura della tabella è la seguente :
Codice:
DOMANDE
-------------------------
ID PRYMARY KEY
DOMANDA VARCHAR (100)
RISPOSTA TEXT
DATA DATE
SUCCESSO FLOAT
_LINK VARCHAR (100)
La query si esplica attraverso il seguente codice php:
Codice PHP:
if (trim($id) <> "")
{
if (trim($idsel) == "uguale") {
$sql = $sql . " id = '" . trim($id) . "' and ";
}
if (trim($idsel) == "maggiore") {
$sql = $sql . " id > " . trim($id) . " and ";
}
if (trim($idsel) == "minore") {
$sql = $sql . " id < " . trim($id) . " and ";
}
if (trim($idsel) == "diverso") {
$sql = $sql . " id <> " . trim($id) . " and ";
}
if (trim($idsel) == "ugualemaggiore") {
$sql = $sql . " id >= " . trim($id) . " and ";
}
if (trim($idsel) == "ugualeminore") {
$sql = $sql . " id <= " . trim($id) . " and ";
}
}
if (trim($dom) <> "")
{
$sql = $sql . " domanda like " . trim($dom) . " and ";
}
if (trim($risp) <> "")
{
$sql = $sql . " risposta like " . trim($risp) . " and ";
}
if (trim($link) <> "")
{
$sql = $sql . " _link = " . trim($link) . " and ";
}
if (trim($data) <> "")
{
$sql = $sql . " data = " . trim($data) . " and ";
}
if (trim($ril) == "Valore0") {
$sql = $sql . " rilevanza = 0 and ";
$s = "0";
}
if (trim($ril) == "Valore1") {
$sql = $sql . " rilevanza = 1 and ";
$s = "1";
}
if (trim($ril) == "Valore2") {
$sql = $sql . " rilevanza = 2 and ";
$s = "2";
}
if (trim($ril) == "Valore3") {
$sql = $sql . " rilevanza = 3 and ";
$s = "3";
}
if (trim($ril) == "Valore4") {
$sql = $sql . " rilevanza = 4 and ";
$s = "4";
}
if (trim($ril) == "Valore5") {
$sql = $sql . " rilevanza = 5 and ";
$s = "5";
} //13-9
$lunghezza = strlen($sql) - 4;
$sql = substr($sql,0,$lunghezza);
$aggiunta = $sql;
$sql = "select * from domande where " . $sql;
//print $sql;
if (ricerca_database($sql) == false) // guardo se il goal dell'sql è positivo
{
print "<table><tr><td><p class='style2'>Dati da eliminare non trovati.</p></td></tr></table>";
linea();
conclusione();
exit;
}
if (lista_dom($aggiunta) == false ) { // faccio la lista degli elementi che corrispondono
}