MYSQL自动打印值打印[关闭]

I am having problem regarding this code. How can I print the value I am fetching? It's not showing anything.

<?php

$comm = mysql_connect("localhost","root","");

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("abhijit", $comm);
$new=$_POST['comment'];
$insert=mysql_query("INSERT INTO comment(post) VALUES('$new')");
$str="SELECT * FROM comment";
$rom=mysql_fetch_array($str);
echo $rom['post'];

mysql_close($comm);
?>

$str is not a query result. For example:

$str = "SELECT * FROM comment";
$result = mysql_query($str);
$rom = mysql_fetch_array($result);

However, I advise against using mysql_* functions. Learn MySQLi or PDO instead.

With "SELECT * FROM comment" you get the hole content of the "comment"-Table and not just the value you are fetching. If you want to get only the value you are fetching, you have to add a WHERE-clause.

Something like this:

SELECT * FROM comment WHERE post_name = ?

I hope I answered your question right.

ok :) I write you this code and i hope it works, because i didn't tested it. I just want to notice, that this code don't make any sense and it is just for learning.

$connect = mysql_connect("localhost","root","");

if (!$con) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("abhijit", $comm);
// Inserting
$new = $_POST['comment'];
$insert = mysql_query("INSERT INTO comment(post) VALUES('$new')");
// Reading
$str = mysql_query("SELECT * FROM comment WHERE post = '$new'");
$row = mysql_fetch_array($str);
echo $row['post'];

mysql_close($connect);