1

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 0 in C:\AppServ\www\phpdemo\newssave.php on line 7

<?php 
    include"setup.php";

    $anonym=$_Post["anonym"];
    $sub=$_Post["sub"];
    $content=$_Post["content"];

    $sql= "insert into $newstable values('id','$anonym','$sub','$content');";
    $connect= mysql_connect($DB_SERVER,$DB_USER,$DB_PASS)or die("CONNECT WORNG");
    $db=mysql_select_db($DB_Name,$connect)or die("WORNG");
    $query= mysql_query($sql,$connect)or die("CONNECT WORNG");

    if(!$query) {
        print "POST ERROR";
    }
    else {
      print "post *** ok!";
    }
?>
Pramod Kumar Sharma
  • 7,851
  • 5
  • 28
  • 53
  • 1
    You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are also **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that a modern API would make it easier to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Mar 22 '13 at 09:11
  • Your PHP code should work fine, the issue seems to be with MySQL server. – artahian Mar 22 '13 at 09:12
  • 1
    And please show us `setup.php`. Also use `$_POST` with capital letters. –  Mar 22 '13 at 09:12
  • What are the values of `$newstable` and `$DB_SERVER` ? – Fabien Mar 22 '13 at 09:13

0 Answers0