salve a tutti, sono appena arrivato, sto imparando php ma ho già un problema...
quando provo ad andare sulla pagina delle news(mtgforum.altervista.org/news/news.php),
mi dice che nn ho selezionato il database...
quando provo a inviarle...mi da questo:
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 'titolo=, testo=' at line 2...
Ora, non so dov' è il problema, perciò posto i codici:
db.inc.php:
Codice:<?php $dbcnx = @mysql_connect('localhost','xxxxxxxxx','xxxxxxx'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } $connect=mysql_select_db('my_mtgforum', '$dbcnx); if (!$connect) { exit('<p>Unable to locate the ' . 'database at this time.</p>'); } ?>
news.php:
Codice:<?php include ('db.inc.php') ; $novita=@mysql_query('select id, titolo from news'); if(!$news){ echo('<p>impossibile trovare il database delle news!' . 'errore:' . mysql_error() . '</p>');} while($novita=mysql_fetch_array($news)) { $id=$novita['id']; $titolo=htmlspecialchars($news['titolo']); echo '<a href="vedinews.php?id=$id">$titolo</a>'; } ?>
invianews.php:
questi sono solo i codici php, ma penso che l' errore non sia da altre parti...Codice:<?php include ('db.inc.php'); $titolo=$_POST['titolo']; $testo=$_POST['testo']; $sql='insert into news titolo=' . $titolo . ', testo=' . $testo . ' ;'; if (!mysql_query($sql)) { echo('<p>errore nell aggiunta della news:' . mysql_error() . '</p>'); }else{ echo('<p>nuova news aggiunta!!</p>'); } $nid=mysql_insert_id(); ?>
spero che mi aiuterete...
ciao![]()

LinkBack URL
About LinkBacks
