在我的MySQL数据库中插入特定的代码行时遇到问题。它可以插入三行,但是由于某种原因,"html_href“行不能插入。下面是我的代码:
function html_path() {
$title = strtolower($_POST['title']); // convert title to lower case
$filename = str_replace(" ", "-", $title); // replace spaces with dashes
$html_href = $filename . ".html"; // add the extension
}
和我的MySQL查询代码:
$query = "INSERT INTO work (title, logline, html_href, synopsis) VALUES";
$query .= "('".mysql_real_escape_string($_POST['title'])."',";
$query .= "'".mysql_real_escape_string($_POST['logline'])."',";
$query .= "'".html_path()."',";
$query .= "'".mysql_real_escape_string($_POST['synopsis'])."')";
$result = mysql_query($query);
标题、logline和概要的值可以很好地插入,但是html_href()
函数会插入一个空行。
发布于 2011-07-31 23:20:08
看起来你的html_path()
函数没有返回任何东西。
尝试:
function html_path() {
$title = strtolower($_POST['title']); // convert title to lower case
$filename = str_replace(" ", "-", $title); // replace spaces with dashes
$html_href = $filename . ".html"; // add the extension
return $html_href;
}
发布于 2011-07-31 23:21:29
您的html_path()不返回$html_href变量。添加
return $html_href;
在你关闭它之前,它应该能完美地工作。
https://stackoverflow.com/questions/6892968
复制