I have a include statement that returns an echo to the browser of a single columns contents in a single found record.
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.
This is the javascript statement:
var listname = '<?php include("test.php");?>';
test.php version 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:
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:
<?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. 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
Descriptionfor that row contain a newline at the start.