i'm new in studing php/mysql so.... HELP ME! :) thx
the query doesn't flow...
What's wrong in this code?!
in the DB there are 2 tables, here you are the queries to create them:
-table autori:
CREATE TABLE autori (
nome varchar(50) NOT NULL default '',
mail varchar(50) default NULL,
PRIMARY KEY (nome)
) TYPE=MyISAM;
table news:
CREATE TABLE news (
id int(5) unsigned NOT NULL auto_increment,
titolo varchar(255) NOT NULL default '',
testo text NOT NULL,
data int(11) default NULL,
nome varchar(50) default NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
Instead, this is the code of update_go.php:
<?
include ("config.inc.php");
include ("top_foot.inc.php");
//intestazione
top();
if ($pass != $password):
echo "Password errata";
elseif (trim($titolo) == "" OR trim($testo) == ""):
echo "I campi Titolo e Testo devono essere riempiti!";
else:
$titolo = addslashes(stripslashes($titolo));
$nome = addslashes(stripslashes($nome));
$mail = addslashes(stripslashes($mail));
$testo = addslashes(stripslashes($testo));
$titolo = str_replace("<", "<", $titolo);
$titolo = str_replace(">", ">", $titolo);
$nome = str_replace("<", "<", $nome);
$nome = str_replace(">", ">", $nome);
$testo = str_replace("<", "<", $testo);
$testo = str_replace(">", ">", $testo);
$testo = nl2br($testo);
$data = mktime("0", "0", "0", $mese, $giorno, $anno);
$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE)
die ("Errore nella connessione. Verificare i parametri nel file config.inc.php");
mysql_select_db($db_name, $db)
or die ("Errore nella selezione del database. Verificare i parametri nel file
config.inc.php");
$query1 = "UPDATE news,autori SET news.titolo='$titolo', news.testo='$testo',
news.data='$data', news.nome='$nome', autori.mail='$mail' WHERE news.nome =
autori.nome AND id='$id'";
print $query1;
if (mysql_query($query1, $db))
echo "L'articolo � stato modificato correttamente";
else
echo "Errore durante la modifica $query";
endif;
echo "<br><a href=index.php>Torna alla pagina iniziale</a><br>";
// chiusura pagina
foot();
?>