[英]New Line In Javascript Because Of PHP Include and Echo Of MySQL Query
I have a include statement that returns an echo to the browser of a single columns contents in a single found record. 我有一个include语句,它向单个找到的记录中的单列内容返回到浏览器的回显。
It is returning a newline at the beginning of the record. 它在记录的开头返回换行符。 This is breaking into two lines the javascript statement the echo is a part of.
这分为两行,是回显所包含的javascript语句。
This is the javascript statement: 这是javascript语句:
var listname = '<?php include("test.php");?>';
test.php version 1: test.php版本1:
mysql_query("SET character_set_results=utf8", $con);
$listref = $_GET["list"];
if(isset($listref)){
$result = mysql_query("SELECT `Description` FROM `lists_management_index` WHERE `LL_ID` = '$listref'");
$row = mysql_fetch_array($result);
echo "here we are";
}
Generates: 产生:
var listname = '
here we are';
test.php version 2: test.php版本2:
Generates: 产生:
var listname = 'here we are';
What is causing the line break and how do I get rid of it? 是什么导致换行符,我该如何解决?
Thanks. 谢谢。
PS: Full test.php version 1: PS:完整的test.php版本1:
<?php
session_start();
$_SESSION['views']=1;
?>
<?php
include('../cons.php');
$db='lists';
include('../condb.php');
mysql_query("SET character_set_results=utf8", $con);
$listref = $_GET["list"];
if(isset($listref)){
$result = mysql_query("SELECT `Description` FROM `lists_management_index` WHERE `LL_ID` = '$listref'");
$row = mysql_fetch_array($result);
echo $row['Description'];
}
include('../consc.php');
?>
Have a look at the beginning of your php script at <?php
. 看看
<?php
处的php脚本的开头。 Are these the very first characters of the file? 这些是文件的第一个字符吗? Or is there any newline before that?
还是在此之前有换行符?
Edit : Based on the info that your comment provided I assume that the contents of Description
for that row contain a newline at the start. 编辑 :根据您的评论提供的信息,我假设该行的
Description
内容在开始时包含换行符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.