Jump to content

Where is the error in this?


Colourtheory

Recommended Posts

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 by Mudsaf
Link to comment
Share on other sites

$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 by xhtmlchamps1
Link to comment
Share on other sites

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 by dsonesuk
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...