Jump to content

XML Parsing Error: junk after document element


candice

Recommended Posts

Hi all, I am about to do a live search, and in the midst of testing out my script that generates the xml, i found this error:

 

XML Parsing Error: junk after document element

Location: http://localhost/equipdb/genUserSearch.php

Line Number 2, Column 1:<b>Notice</b>:  Undefined index:  search in <b>C:\wamp\www\equipdb\genUserSearch.php</b> on line <b>41</b><br />

^

 

Does any of you know where the error lies? Thanks.

 

Attached is my code:

<?php header ('Content-type:text/xml') ?>
<?php echo ('<?xml version="1.0" encoding="iso-8859-1"?>') ?>
<?php require_once('connection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

function highlightkeyword($text) {
$keyword = $_GET['search'];
$highlighttext = str_ireplace($keyword, "<span class='highlight'>".$keyword."</span>", $text);
return $highlighttext;
}

mysql_select_db($db_name);
$search = $_GET['search'];
$query_rsAccount = "SELECT * FROM student WHERE
				studentID LIKE '%".$search."%' OR
				studentname LIKE '%".$search."%'";

$rsAccount = mysql_query($query_rsAccount, $db_name) or die(mysql_error());
$row_rsAccount = mysql_fetch_assoc($rsAccount);
$totalRows_rsAccount = mysql_num_rows($rsAccount);
?>
<Account>
  <?php do { ?>
    <result total ="<?php echo $totalRows_rsAccount ?>">
      <id><![CDATA[<?php echo $row_rsAccount['id']; ?>]]></id>
      <studentID><![CDATA[<?php echo highlightkeyword($row_rsAccount['studentID']); ?>]]></studentID>
      <studentname><![CDATA[<?php echo highlightkeyword($row_rsAccount['studentname']); ?>]]></studentname>
    <?php } while ($row_rsAccount = mysql_fetch_assoc($rsAccount)); ?>
</Account>

<?php
mysql_free_result($rsAccount);
?>

 

Thanks for the reply. I tried replacing the code, but im still getting the same error.

 

XML Parsing Error: junk after document element

Location: http://localhost/equipdb/genUserSearch.php

Line Number 2, Column 1:<b>Notice</b>:  Undefined index:  search in <b>C:\wamp\www\equipdb\genUserSearch.php</b> on line <b>41</b><br />

^

 

could be something to search variable?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.