php - MySQL Syntax Error Error -


when calling function mysql syntax error appears, ideas?

you have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 1

function getcomments1() {     $query = mysql_query("select * comments") or die(mysql_error());     while($post = mysql_fetch_assoc($query)) {         echo $post['author'];      } }  function addcomment($cname, $ccontent) {     $query = mysql_query("insert comments values(null,'$cname','$ccontent'") or die(mysql_error()); } 

<?php include('includes/functions.php'); mysql_set_charset ( "utf8" );  if(isset($_post['submit'])) {     if(isset($_post['commentname'])) {         if(isset($_post['commentcontent'])) {             addcomment($_post['commentname'],$_post['commentcontent']);             header("location: derger.php");         } else { "text missing";          }      } else {         echo "name missing";         include('herger.php');      }  } else {     header("location: werger.php"); } ?> 

("insert comments values(null,'$cname','$ccontent'")  

you didn't close values. should be:

("insert comments values(null,'$cname','$ccontent')")  

also, here remind you, mysql_ functions deprecated. should using pdo or mysqli. simple google search on either give plenty of resources transition into.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -