Mudsaf Posted February 1, 2013 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 Link to comment Share on other sites More sharing options...
xhtmlchamps1 Posted February 4, 2013 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 Link to comment Share on other sites More sharing options...
dsonesuk Posted February 4, 2013 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 Link to comment Share on other sites More sharing options...
dsonesuk Posted February 4, 2013 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now