为什么不保存?

时间:2014-05-25 06:30:24

标签: php mysql

我成功连接,为什么不保存?如果可以,有人可以在此代码中指出错误,谢谢!

<?php $actual_quote = (isset($_GET['actual_quote']) ? $_GET['actual_quote'] : ''); ?>
<div class="top-submit"><?php echo '&#8220;' . $actual_quote . '&#8221;'; ?>
</div>
<?php $poster = (isset($_GET['poster']) ? $_GET['poster'] : ''); ?>
<div class="poster"><?php echo '-' . $poster; ?>
<div class = "like">
<a href = "javascript:countClicksLike();" class = "btn btn-large" style = "color:green;">Like</a>
<p id = "like" style = "color:green;">0</p>
</div>
<div class = "dislike">
<a href = "javascript:countClicks();" class = "btn btn-large" style = "float:right; color:red;">Dislike</a>
<p id = "dis" style = "color:red;">0</p>
</div>
</div>
<!-- if there's an issue it may be this aswell-->
<?php
define('DB_NAME', 'submissions');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');

$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);

if(!$db_selected) {
die('Cannot use' . DB_NAME . ': ' . mysql_error());
}
$sql = "INSERT INTO submissions (poster, actual_quote) VALUES ('$poster', '$actual_quote')";
if(!mysql_query($sql)) {
die('Error:' . mysql_error());
}
mysql_close();
?>

对不起,如果开始有点突然,我只是非常迷失。我应该在包含$ _GET和isset的php中包含insert函数吗? 任何帮助是极大的赞赏。 谢谢! -Connor

0 个答案:

没有答案