Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8491529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:27:07+00:00 2026-06-10T22:27:07+00:00

In my php file I have the following code //create SQL to select schedule

  • 0

In my php file I have the following code

//create SQL to select schedule
 $sql = "SELECT * FROM `Schedule`";

 //create result set
 $result = mysql_query($sql);

 $result_array[] = "";
 while($row = mysql_fetch_assoc($result))
 {
    $result_array[$row['ID']] = $row;
 }

 echo json_encode($result_array);

In my HTML file I have the following code

xmlhttp.onreadystatechange=function()
  {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
   {
    var schedArray = JSON.parse(xmlhttp.ResponseText);

    alert(schedArray[0]["ID"]);
   }
  }
  xmlhttp.open("GET","getSchedule.php?q="+year,true);
  xmlhttp.send();

When I run my HTML code I get this error: Uncaught SyntaxError: Unexpected token u

I belive my data is encoded correctly because running

document.getElementById("txtHint").innerHTML=xmlhttp.responseText;

in my ready state check nets me an array with the correct data:

{"0":"","1":{"ID":"1","Team":"Louisiana-Monroe","playDate":"2011-09-03","Conference":"Sun Belt","Rank":null,"Bowl":"0","Site":"H"},"3":{"ID":"3","Team":"Oklahoma","playDate":"2011-09-17","Conference":"Big 10","Rank":"1","Bowl":"0","Site":"H"},"4":{"ID":"4","Team":"Clemson","playDate":"2011-09-24","Conference":"ACC","Rank":"21","Bowl":"0","Site":"A"},"5":{"ID":"5","Team":"Wake Forest","playDate":"2011-10-08","Conference":"ACC","Rank":null,"Bowl":"0","Site":"A"},"6":{"ID":"6","Team":"Duke","playDate":"2011-10-15","Conference":"ACC","Rank":null,"Bowl":"0","Site":"A"},"7":{"ID":"7","Team":"Maryland","playDate":"2011-10-22","Conference":"ACC","Rank":null,"Bowl":"0","Site":"H"},"8":{"ID":"8","Team":"North Carolina State","playDate":"2011-10-29","Conference":"ACC","Rank":null,"Bowl":"0","Site":"H"},"9":{"ID":"9","Team":"Boston College","playDate":"2011-11-03","Conference":"ACC","Rank":null,"Bowl":"0","Site":"A"},"10":{"ID":"10","Team":"Miami (FL)","playDate":"2011-11-12","Conference":"ACC","Rank":null,"Bowl":"0","Site":"H"},"11":{"ID":"11","Team":"Virginia","playDate":"2011-11-19","Conference":"ACC","Rank":null,"Bowl":"0","Site":"H"},"12":{"ID":"12","Team":"Florida","playDate":"2011-11-26","Conference":"SEC","Rank":null,"Bowl":"0","Site":"A"},"13":{"ID":"13","Team":"Notre Dame","playDate":"2011-12-29","Conference":"IND","Rank":null,"Bowl":"1","Site":"N"},"14":{"ID":"14","Team":"Murray State","playDate":"2012-09-01","Conference":"Ohio Valley","Rank":null,"Bowl":"0","Site":"H"},"15":{"ID":"15","Team":"Savannah State","playDate":"2012-09-08","Conference":"MEAC","Rank":null,"Bowl":"0","Site":"H"}}

I cannot figure out why I am receiving this error. I am not using JQuery and I have included json2.js in my JavaScript. Any help somebody could provide would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:27:09+00:00Added an answer on June 10, 2026 at 10:27 pm

    Your problem is, I think, here:

    var schedArray = JSON.parse(xmlhttp.ResponseText);
    

    It should be responseText, lower-case “r”. What’s happening is that the string "undefined" is what the parser is actually trying to interpret, and a string starting with “u” cannot be valid JSON.

    You got it right in the code that populates the debugging element to show the response.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the Create ZIP File PHP class I have the following line of code
I have the following code to upload a file: <?php //set the image size
I have the following code: if (include_once(dirname(__FILE__).'/file.php') || include_once(dirname(__FILE__).'/local/file.php') ) { This causes an
In PHP I have the following code that gets a file submitted through CGI:
I have the following lines of php code which should rename a file which
I have the following code: <? $serverurl = $_SERVER[DOCUMENT_ROOT]; $file = $serverurl.'/demo/sample_php.php'; $newfile =
I am learning file handling in php. I have written the following code to
I have the following PHP code: $testMessage = TESTMESSAGE; $db = new SQLite3('messages.sq3'); $db->exec('CREATE
I have the following PHP code that checks which choice from a radio button
I have the following class in a php file: function calcTotal(){ var productID =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.