Mudsaf 17 Posted February 1, 2013 Report Share Posted February 1, 2013 (edited) Try this <?phpsession_start();include('themesys.php')?> <br><br><div class="bbox"> <center> <?php if (isset($_SESSION['user_id'])) { $con = mysql_connect("mystuff","mystuff","mypw") or die("Could not connect to hostserver: " . mysql_error());mysql_select_db("mydb") or die("Could not select database: " . mysql_error()); $id = $_SESSION['user_id'];$sql="INSERT INTO discussions (name, desc, maker) VALUES('{$_POST['namevalue']}', '{$_POST['descvalue']}','$id')";mysql_query($sql) or die("MySQL error: " . error());echo "Discussion started!"; mysql_close($con);} else {header('Location: login.php');}?> </div></body> Edited February 1, 2013 by Mudsaf Quote Link to post Share on other sites
xhtmlchamps1 2 Posted February 4, 2013 Report Share Posted February 4, 2013 (edited) $sql="INSERT INTO discussions (name, desc, maker)VALUES('".$_POST[name]."', '".$_POST[desc]."', '$id')"; This is the right way to write you can also write in this manner $sql="INSERT INTO discussions (name, desc, maker)VALUES('".$_POST['name']."', '".$_POST['desc']."', '$id')"; ('".$_POST['name']."' this particular key word can accepts the values perfectly. Edited February 4, 2013 by xhtmlchamps1 Quote Link to post Share on other sites
dsonesuk 914 Posted February 4, 2013 Report Share Posted February 4, 2013 (edited) $sql="INSERT INTO discussions (name, desc, maker)VALUES('$_POST[name]', '$_POST[desc]', '$id')"; Theres no need to use concatenation operator '.' to add quotes, it looks really messy doing so. Edited February 4, 2013 by dsonesuk Quote Link to post Share on other sites
dsonesuk 914 Posted February 4, 2013 Report Share Posted February 4, 2013 (edited) The error is due to a reserved word being used desc, it is reserved for describing which order you require as in descending or ascending. if you can't change field name try using backticks `desc`. OOPS! i see this has already been pointed out, guys the problem has been found, give it up. Edited February 4, 2013 by dsonesuk Quote Link to post Share on other sites
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.