webdevdea Posted February 24, 2016 Share Posted February 24, 2016 at my link http://dandewebwonders.com/BBProject%204/index.php when you click on players you see the error.. this is what i need to do .. change data type from html to json, fix the controller error, and change it to parse the data.data object. case "listPlayers_Data" : $response = null; $results = array(); $players = new PlayersClass(); foreach ($players -> RetrieveAll() as $row) { $results[] = new PlayerListModel($row -> Id); } $response -> data = $results; echo json_encode($response); break; and a link to the project on github https://github.com/deannariddlespur/bb_Project/blob/master/Controllers/Controller.php Quote Link to comment https://forums.phpfreaks.com/topic/300871-json-help/ Share on other sites More sharing options...
requinix Posted February 24, 2016 Share Posted February 24, 2016 Warning: Creating default object from empty value in /home3/aundie/public_html/dandewebwonders.com/BBProject 4/Controllers/Controller.php on line 41 {"data":[{"Id":"1","FirstName":"Chico","LastName":"Escuela","HomeTown":"San Juan, PR","Bats":"L","Throws":"R","Team":null},{"Id":"2","FirstName":"Christopher","LastName":"Henry","HomeTown":"Pittsburgh, PA","Bats":"","Throws":"","Team":null},{"Id":"3","FirstName":"Travis","LastName":"Hubbard","HomeTown":"Boise, ID","Bats":"","Throws":"","Team":null},{"Id":"4","FirstName":"Richard","LastName":"McCoy","HomeTown":"Austin, TX","Bats":"","Throws":"","Team":null},{"Id":"5","FirstName":"Al","LastName":"Torres","HomeTown":"Baltimore, MD","Bats":"","Throws":"","Team":null},{"Id":"6","FirstName":"Everett","LastName":"Greer","HomeTown":"Wilmington, DE","Bats":"","Throws":"","Team":null},{"Id":"7","FirstName":"Johnnie","LastName":"Joseph","HomeTown":"St. Paul, MN","Bats":"","Throws":"","Team":null},{"Id":"8","FirstName":"Milton","LastName":"Osborne","HomeTown":"Davidson, TN","Bats":"","Throws":"","Team":null},{"Id":"9","FirstName":"Dewey","LastName":"McDonald","HomeTown":"St. Louis, MO","Bats":"","Throws":"","Team":null},{"Id":"10","FirstName":"Ervin","LastName":"Lawrence","HomeTown":"Anaheim, CA","Bats":"","Throws":"","Team":null},{"Id":"11","FirstName":"Thomas","LastName":"Copeland","HomeTown":"St. Petersburg, FL","Bats":"","Throws":"","Team":null},{"Id":"12","FirstName":"Christian","LastName":"Shelton","HomeTown":"Akron, OH","Bats":"","Throws":"","Team":null},{"Id":"13","FirstName":"Jackie","LastName":"Harris","HomeTown":"Rochester, NY","Bats":"","Throws":"","Team":null},{"Id":"14","FirstName":"Bob","LastName":"Barnes","HomeTown":"Newark, NJ","Bats":"","Throws":"","Team":null},{"Id":"15","FirstName":"Woodrow","LastName":"Zimmerman","HomeTown":"Baltimore, MD","Bats":"","Throws":"","Team":null},{"Id":"16","FirstName":"Willard","LastName":"Harrington","HomeTown":"Glendale, AZ","Bats":"","Throws":"","Team":null},{"Id":"17","FirstName":"Orville","LastName":"Gregory","HomeTown":"Reno, NV","Bats":"","Throws":"","Team":null},{"Id":"18","FirstName":"Tony","LastName":"Jennings","HomeTown":"Denver, CO","Bats":"","Throws":"","Team":null},{"Id":"19","FirstName":"Benjamin","LastName":"Hawkins","HomeTown":"Philadelphia, PA","Bats":"","Throws":"","Team":null},{"Id":"20","FirstName":"Andre","LastName":"Wells","HomeTown":"Kansas City, MO","Bats":"","Throws":"","Team":null},{"Id":"21","FirstName":"Rafael","LastName":"McDaniel","HomeTown":"Norfolk, VA","Bats":"","Throws":"","Team":null}]} 1 Quote Link to comment https://forums.phpfreaks.com/topic/300871-json-help/#findComment-1531406 Share on other sites More sharing options...
webdevdea Posted February 24, 2016 Author Share Posted February 24, 2016 yes I think it is not formatting correctly.. Quote Link to comment https://forums.phpfreaks.com/topic/300871-json-help/#findComment-1531407 Share on other sites More sharing options...
webdevdea Posted February 24, 2016 Author Share Posted February 24, 2016 <br /> <b>Warning</b>: Creating default object from empty value in <b>/home3/aundie/public_html/dandewebwonders.com/BBProject 4/Controllers/Controller.php</b> on line <b>41</b><br /> {"data":[{"Id":"1","FirstName":"Chico","LastName":"Escuela","HomeTown":"San Juan, PR","Bats":"L","Throws":"R","Team":null},{"Id":"2","FirstName":"Christopher","LastName":"Henry","HomeTown":"Pittsburgh, PA","Bats":"","Throws":"","Team":null},{"Id":"3","FirstName":"Travis","LastName":"Hubbard","HomeTown":"Boise, ID","Bats":"","Throws":"","Team":null},{"Id":"4","FirstName":"Richard","LastName":"McCoy","HomeTown":"Austin, TX","Bats":"","Throws":"","Team":null},{"Id":"5","FirstName":"Al","LastName":"Torres","HomeTown":"Baltimore, MD","Bats":"","Throws":"","Team":null},{"Id":"6","FirstName":"Everett","LastName":"Greer","HomeTown":"Wilmington, DE","Bats":"","Throws":"","Team":null},{"Id":"7","FirstName":"Johnnie","LastName":"Joseph","HomeTown":"St. Paul, MN","Bats":"","Throws":"","Team":null},{"Id":"8","FirstName":"Milton","LastName":"Osborne","HomeTown":"Davidson, TN","Bats":"","Throws":"","Team":null},{"Id":"9","FirstName":"Dewey","LastName":"McDonald","HomeTown":"St. Louis, MO","Bats":"","Throws":"","Team":null},{"Id":"10","FirstName":"Ervin","LastName":"Lawrence","HomeTown":"Anaheim, CA","Bats":"","Throws":"","Team":null},{"Id":"11","FirstName":"Thomas","LastName":"Copeland","HomeTown":"St. Petersburg, FL","Bats":"","Throws":"","Team":null},{"Id":"12","FirstName":"Christian","LastName":"Shelton","HomeTown":"Akron, OH","Bats":"","Throws":"","Team":null},{"Id":"13","FirstName":"Jackie","LastName":"Harris","HomeTown":"Rochester, NY","Bats":"","Throws":"","Team":null},{"Id":"14","FirstName":"Bob","LastName":"Barnes","HomeTown":"Newark, NJ","Bats":"","Throws":"","Team":null},{"Id":"15","FirstName":"Woodrow","LastName":"Zimmerman","HomeTown":"Baltimore, MD","Bats":"","Throws":"","Team":null},{"Id":"16","FirstName":"Willard","LastName":"Harrington","HomeTown":"Glendale, AZ","Bats":"","Throws":"","Team":null},{"Id":"17","FirstName":"Orville","LastName":"Gregory","HomeTown":"Reno, NV","Bats":"","Throws":"","Team":null},{"Id":"18","FirstName":"Tony","LastName":"Jennings","HomeTown":"Denver, CO","Bats":"","Throws":"","Team":null},{"Id":"19","FirstName":"Benjamin","LastName":"Hawkins","HomeTown":"Philadelphia, PA","Bats":"","Throws":"","Team":null},{"Id":"20","FirstName":"Andre","LastName":"Wells","HomeTown":"Kansas City, MO","Bats":"","Throws":"","Team":null},{"Id":"21","FirstName":"Rafael","LastName":"McDaniel","HomeTown":"Norfolk, VA","Bats":"","Throws":"","Team":null}]} how would i change data type from html to json, Quote Link to comment https://forums.phpfreaks.com/topic/300871-json-help/#findComment-1531408 Share on other sites More sharing options...
requinix Posted February 24, 2016 Share Posted February 24, 2016 Forget that for a moment and focus on the error message. And on fixing whatever caused it. 1 Quote Link to comment https://forums.phpfreaks.com/topic/300871-json-help/#findComment-1531411 Share on other sites More sharing options...
Jacques1 Posted February 24, 2016 Share Posted February 24, 2016 You assign null to $response in line 35, but then you try to assign an array to $response->data in line 41 as if null was an object. This is of course nonsensical. Either make $response an array and use the $response['data'] syntax, or make it an actual object. 1 Quote Link to comment https://forums.phpfreaks.com/topic/300871-json-help/#findComment-1531422 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.