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);
?>

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.