-
my sql
Salve ho un piccolo problema.
sto cercando di creare un guestbook sul mio sito. ho impostato tutto bene si nome sia psw e sia database my_kinglionweb.
quando provo a postare un msg mi da un errore do query che ho individuato nella stringa
$sql_result = mysql_query($sql, $connection) or die("Couldnt exec Query");
qual'e il problema?
se volete dare un'occhiata al gbook l'indirizzo e
http://kinglionweb.altervista.org/1/gbook.html
Grazie.
-
Posta il contenuto della var $sql
Poi al posto di ("Couldnt exec Query") metti (mysql_error())
Ciaoooooo!!!!!
-
re
lo script si differenzia in tre file, uno html e due .php3
nell'html il comando base e giusto :
<form name="form1" method="post" action="http://kinglionweb.altervista.org/1/gbook.php3">
##################################################
Primo file gbook.php3
<?php
/*if((!$name) //|| (!$url) || (!$msg))
{
echo "<body bgcolor=\"black\" text=\"white\">";
echo "<font face=\"Verdana,Arial\" size=\"2\">" ;
echo "Please fill in all fields";
exit ;
}
*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>-=Guestbook=-</title></head>
<body bgcolor="#000000" text="#ffffff">
<font face="Verdana,Arial" size="2">
<?php
$sql = "INSERT INTO guests ( name, email, url, msg) VALUES
('$name', '$email', '$url', '$msg')";
// Creating Connection
$connection = mysql_connect("localhost", "kinglionweb", "mia_psw") or die("Could not Connect to DB");
// Selecting database
$db = mysql_select_db("my_kinglionweb", $connection) or die("Couldnt select DB");
// Execute Query
$sql_result = mysql_query($sql, $connection) or die("Couldnt exec Query");
if (!sql_result) {
echo "Couldnt Add Guestbook entry";
}
else {
echo "The following entry has been added to the guestbook<p>";
echo "Name : $name<p>";
echo "Email : $email<p>";
echo "Homepage : $url<p>";
echo "Message : $msg<p>";
}
?>
</body>
</html>
################################################## #
gbookv.php3
<html>
<head>
<title>-=Guestbook=-</title></head>
<body bgcolor="#000000" text="#ffffff">
<font face="Verdana,Arial" size="2">
<center><h4>Guestbook Entries</h4></center><p>
<?php
// Creating Connection usually to localhost and enter your database
//username & password in the blank quotes
$connection = mysql_connect("localhost", "kinglionweb", "mia_psw") or die("Could not Connect to DB");
// Query to be fired to the database
$sql = "SELECT id, name, email, url, msg FROM guests ORDER BY id DESC";
// Selecting database where "ultra" is the Database name
$db = mysql_select_db("my_kinglionweb", $connection) or die("Couldnt select DB");
// Execute Query to Display stuff
$sql_result = mysql_query($sql, $connection) or die("Couldnt exec Query");
while ($row = mysql_fetch_array($sql_result))
{
extract($row);
echo "$id. <b>Name</b> : $name<br>";
echo "<b>Email</b> : $email<br>";
echo "<b>HomePage url</b> : $url<br>";
echo "<b>Message</b> : $msg<br>";
echo "<hr>";
}
// Freeing result n closing connection
mysql_free_result($sql_result);
mysql_close($connection);
?>
</font>
</body></html>
##################################################
questo e tutto lo script ... dove devo cambiare le variabili?
help me please
-
Sembra ci sia un errore generale, non esegue nessuna query.
sostituisci ("Couldnt exec Query") con (mysql_error())
Ciaoooooooo!!!!!!!!!!!
-
hai creato le tabelle nel db?
-
.... ho fatto ma cambia solo il msg di errore.
se provo ad eliminare tutta la stringa
$sql_result = mysql_query($sql, $connection) or die("Couldnt exec Query");
il msg lo posta ma nn lo salva.
Avresti qualke altro script da passarmi?
la mia intenzione nn e proprio un guestbook ma diciamo un form di consigli x utenti, quindi mi serve uno script ke stampa i consigli degli user su di un file ke loro nn possono vedere ( magari solo nn mettendo il relink)
ho provato con frontpage e con cgi formmail ma nn sono supportati.
se provo col comando mailto: nn va sempre xke ki hh ha i msg muti configurati su outlook nn puo mandare mail...
come posso fare?
se hai quelke script mi faresti un big favore
-
Eh, appunto, devi dirmi che messaggio di errore ti da!
Ciaoooo!!!!!!
-
re
tabelle? no nn so ke siano
lo scripto e stato interamente postato ... nn c'e altro
-
nn so ke msg mi da... mi scrive solo ke c'e lerrore e l'errore sta nella stringa
$sql_result = mysql_query($sql, $connection) or die("Couldnt exec Query");
oppure
$sql_result = mysql_query($sql, $connection) or die("mysql_error()");
ho provato in entrambi i modi...
ora ho tolto questa stringa... il msg va ma nn posso accedere alla pagina gbookv.php3 x vederli e poi nn li salva...
nn so altro , se potete help me
-
Ti ho detto cosa sotituire, fallo in entrambe le pagine, e poi posta la frase di errore!
Ciaooo!!!