Reputation: 61
I catch html from two files with javascript. In one of the files I include info to connect to my DB.
But when I do, php adds two " to my html. All files are saved with the encoding UTF8.
Index.php html
<div class="f-l" id="right-column"></div>
Javascript.js
$('#lead, #prospects').change(function() {
var kund_id = 'kund_id=' + $('#lead option:selected, #prospects option:selected').attr('value');
$.post(
'get_kund.php',
kund_id,
function(data){
$('#center-column').html(data)
});
$.post(
'get_kontaktperson.php',
kund_id,
function(data){
$('#right-column').html(data)
}); return false;
});
get_kontaktperson.php
include("db_connect.php");
$kund_id = $_POST['kund_id'];
$qry = "SELECT * FROM kontaktperson WHERE kund_id='$kund_id' ORDER BY id DESC";
$result=mysql_query($qry);
while($row=mysql_fetch_array($result)) {
echo 'some html'; }
db_connect.php
require_once('db_info_login.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: '
. mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die('Unable to select database');
}
mysql_query('SET NAMES utf8')
This adds "" above the html code from get_kontaktperson.php:
Why this seems to be a problem for me, the <div class="kontaktperson">
is missplaced by something. If I take away the include it will show the html content correct. But when I put in some data, this will occur. Margin on the right column...
Upvotes: 3
Views: 148
Reputation: 6265
Those two quotation marks are used by Chrome's web inspector to denote content inside the element. As there is no content, two quotation marks are shown without anything inside them.
Upvotes: 9