XeroXer Posted January 5, 2007 Share Posted January 5, 2007 Start with the problem stuff:[b]database[/b][code]CREATE TABLE `support_questions` (`id` tinyint(9) NOT NULL auto_increment,`username` varchar(99) NOT NULL default '',`email` varchar(99) NOT NULL default '',`question` longtext NOT NULL,`qdate` varchar(99) NOT NULL default '',`answer` longtext NOT NULL,`adate` varchar(99) NOT NULL default '',`ausername` varchar(99) NOT NULL default '',`show` varchar(99) NOT NULL default '',PRIMARY KEY (`id`)) TYPE=MyISAM ;[/code][b]form[/b][code]<?phpecho "<table width='50%' aling='left' valign='top'><tr><td>";echo "<form id='login' name='login' method='post' action='index.php?p=ask'>";echo "<input type='text' name='user' value='username' onFocus='formrule(this);'><br>";echo "<input type='text' name='email' value='e-mail' onFocus='formrule(this);'><br>";echo "<textarea name='quest' onFocus='formrule(this);'>question</textarea><br>";echo "<input type='submit' name='ask' value='ask'>";echo "</form>";echo "</td></tr></table>";?>[/code][b]code[/b][code]<?phpinclude("database.php");$con = mysql_connect("$mysqlhost","$mysqlusr","$mysqlpass") or die('Could not connect: ' . mysql_error());mysql_select_db($db_name, $con) or die(mysql_error());mysql_query("INSERT INTO support_questions (username, email, question, show) VALUES ('$name', '$email', '$message', '$thetime', '0')");echo "<table width='50%' aling='left' valign='top'><tr><td>";echo "Question has been asked. Answer will be updated by an admin.";echo "<br><br><u>Save this information to get your answer later.</u>";echo "<br><b>Name:</b> ";echo $name;echo "<br><b>E-mail:</b> ";echo $email;echo "<br><b>Question:</b> <table><tr><td>";echo $message;echo "</td></tr></table></td></tr></table>";mysql_close($con);?>[/code][hr]I have been sitting with this code on the side all day.Checking it a few times and it just won't work.Probebly I have just missed a variable like the last time.Please help...[i]The part I find strange is that i copied the code from my other site where it works.So I can't find the problem...[/i] Quote Link to comment Share on other sites More sharing options...
paul2463 Posted January 5, 2007 Share Posted January 5, 2007 Hi If you had a warning script at the end of your mysql_query statement such as[code]<?phpmysql_query("INSERT INTO support_questions (username, email, question, show) VALUES ('$name', '$email', '$message', '$thetime', '0')") or die ('Error in query: ' . mysql_error());?>[/code]it would probably have said something like there was an error in your query.INSERT INTO (username, email, question, show) // 4 field namesVALUES ('$name', '$email', '$message', '$thetime', '0') // 5 variablestoo many entries for the number of fieldshope that helps Quote Link to comment Share on other sites More sharing options...
XeroXer Posted January 5, 2007 Author Share Posted January 5, 2007 changed that row to:[code]<?phpmysql_query("INSERT INTO support_questions (username, email, question, qdate, show) VALUES ('$name', '$email', '$message', '$thetime', '0')") or die ('Error in query: ' . mysql_error());?>[/code]but then I get the error:[code]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 'show) VALUES ('XeroXer', 'test@test.com', 'hello', '2007-01-0[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 5, 2007 Share Posted January 5, 2007 The word "show" is most likely a reserved word in MySQL so you need to enclose it in backticks:[code]<?phpmysql_query("INSERT INTO support_questions (username, email, question, qdate, `show`) VALUES ('$name', '$email', '$message', '$thetime', '0')") or die ('Error in query: ' . mysql_error());?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
XeroXer Posted January 5, 2007 Author Share Posted January 5, 2007 thank you... thank you... thank you... thank you... thank you... thank you... :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.