webmaster11 Posted April 25, 2014 Share Posted April 25, 2014 Hello everybody, I have a little code for you awesome expert PHP programmers out there. I have no idea what I'm doing...kind of. Basically, what's wrong is that the files I am using for the website are using a version of PHP different from that of the web host itself - I think. The problem is that Open Flash Chart does not display anything. I think what's going wrong is somewhat related to "open flash chart json parse error [syntax error] error at character 0, line 1: 0: <br>" But I'm not sure. I have some code here. This is only a small part of the code in the PHP file. I think the problem lies somewhere in here... public function getpilotsjson() { $page = $this->get->page; // get the requested page $limit = $this->get->rows; // get how many rows we want to have into the grid $sidx = $this->get->sidx; // get index row - i.e. user click to sort $sord = $this->get->sord; // get the direction if(!$sidx) $sidx =1; /* Do the search using jqGrid */ $where = array(); if($this->get->_search == 'true') { $searchstr = jqgrid::strip($this->get->filters); $where_string = jqgrid::constructWhere($searchstr); # Append to our search, add 1=1 since it comes with AND # from above $where[] = "1=1 {$where_string}"; } Config::Set('PILOT_ORDER_BY', "{$sidx} {$sord}"); # Do a search without the limits so we can find how many records $count = count(PilotData::findPilots($where)); if($count > 0) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; } $start = $limit * $page - $limit; // do not put $limit*($page - 1) if ($start < 0) { $start = 0; } # And finally do a search with the limits $allpilots = PilotData::findPilots($where, $limit, $start); if(!$allpilots) { $allpilots = array(); } # Form the json header $json = array( 'page' => $page, 'total' => $total_pages, 'records' => $count, 'rows' => array() ); # Add each row to the above array foreach($allpilots as $row) { $status = ($row->retired==0) ? 'Active' : 'Retired'; $location = '<img src="'.Countries::getCountryImage($row->location).'" alt="'.$row->location.'" />'; $edit = '<a href="'.adminurl('/pilotadmin/viewpilots?action=viewoptions&pilotid='.$row->pilotid).'">Edit</a>'; $tmp = array( 'id' => $row->id, 'cell' => array( # Each column, in order $row->id, $row->firstname, $row->lastname, $row->email, $location, $status, $row->rank, $row->totalflights, $row->totalhours, $row->lastip, $edit, ), ); $json['rows'][] = $tmp; } header("Content-type: text/x-json"); echo json_encode($json); } -------------------------- Thanks in advance for all help! Quote Link to comment https://forums.phpfreaks.com/topic/288021-phpjson-not-working/ Share on other sites More sharing options...
requinix Posted April 25, 2014 Share Posted April 25, 2014 Run your script in a browser. Do you see any error messages from PHP? Quote Link to comment https://forums.phpfreaks.com/topic/288021-phpjson-not-working/#findComment-1477295 Share on other sites More sharing options...
webmaster11 Posted April 25, 2014 Author Share Posted April 25, 2014 No errors pointing to the specific code snippet. It makes me think that this code isn't at fault. I have no PHP experience. May I ask, does this specific code snippet refer to any other files in my database? Quote Link to comment https://forums.phpfreaks.com/topic/288021-phpjson-not-working/#findComment-1477298 Share on other sites More sharing options...
requinix Posted April 26, 2014 Share Posted April 26, 2014 No errors pointing to the specific code snippet.Any errors at all? You can't just pick a bit of code, decide the problem is in there, and ignore problems that happen in the rest of the script. Quote Link to comment https://forums.phpfreaks.com/topic/288021-phpjson-not-working/#findComment-1477299 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.