我正在尝试做一件事,而且只做一件事。
$embedCode = mysql_real_escape_string('<object width="270" height="227"><param name="movie" value="http://www.youtube.com/v/pz-VWi5-tGA?fs=1&hl=en_US&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/pz-VWi5-tGA?fs=1&hl=en_US&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="270" height="227"></embed></object>');
现在如果我写...
echo 'CODE = ' . $embedCode;
我得到...
CODE =
没什么...
想法?
编辑:
好的,所以我的意图不仅仅是打印 $embedCode,而是将它插入数据库,但我得到一个空值。我想我会是个聪明人,但在这里我的简单化方法适得其反。无论如何,重点是,它没有通过我的 mysql 查询。
编辑 2:我正在使用 wordpress 的 $wpdb 对象
function insert_video(){
global $wpdb;
$wpdb->show_errors();
$table_name = $wpdb->prefix . "video_manager";
$embedCode = mysql_real_escape_string('<object width="270" height="227"><param name="movie" value="http://www.youtube.com/v/pz-VWi5-tGA?fs=1&hl=en_US&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/pz-VWi5-tGA?fs=1&hl=en_US&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="270" height="227"></embed></object>');
$title = 'this is my title';
$description = 'this is my description';
$wpdb->insert( $table_name, array( 'title' => mysql_real_escape_string($title), 'embed_code' => $embedCode, 'description' => mysql_real_escape_string($description) ) );
}
function get_video_block($id){
insert_video();
global $wpdb;
$wpdb->show_errors();
$table_name = $wpdb->prefix . "video_manager";
$query = "SELECT * FROM " . $table_name . " WHERE `index` = '$id'";
$results = $wpdb->get_results($query, ARRAY_A);
$results = $results[0];
$returnString = $results['title'] . '<br>';
$returnString .= $results['embed_code'] . '<br>';
$returnString .= $results['description'] . '<br>';
return $returnString;
}
并得到结果:
this is my title<br><br>this is my description<br>