Internal Server Error 500 Codeigniter on upload to webhosting - php

I am facing server 500 error on following website, fabcoders.com/ghostwriter
Login in as username: chelsea Password:Chelsea123
once logged in you'll be directed to http://fabcoders.com/ghostwriter/dashboard page.
There you'll find a listing as topic,submission,view click the view link.
You'll be directed to http://fabcoders.com/ghostwriter/project/view_submission/230 page click the view. and that that is were i get the 500 error. It show blank but once you inspect element and go to console there you can see the error.
The code is in codeigniter
Here is the controller section
public function view_submission_detail ($submission_id)
{
$user_id = $this->session->userdata("id");
$this->load->model("submission_m");
$this->load->model("ratings_m");
$star = $this->input->post("rating");
$review=$this->input->post("reviews");
$tip=$this->input->post("tip");
$record = $this->submission_m->get($submission_id);
$rat_to=$record->fk_user_id;
//dump($record);
$select = $this->ratings_m->get($rat_to);
//$tip=$select->tip;
$this->load->model("addproject_m");
$temp = $this->user_m->get($rat_to);
$emailid = $temp->email;
$user_id = $temp->id;
$prjct = $this->addproject_m->get($record->fk_project_id);
//dump($record->fk_project_id);
//dump($prjct);
$pname = $prjct->p_title;
$buyername = $prjct->p_buyname;
$this->data['tip'] = $tip;
$this->data['numele'] = count($this->submission_m->viewusersub($user_id));
$this->data['numacc'] = count($this->submission_m->viewuseracc($user_id));
$this->data['numrej'] = count($this->submission_m->viewuserreject($user_id));
$this->data['numrew'] = count($this->submission_m->viewuserrewrite($user_id));
//$this->data['usersubs'] = $this->submission_m->viewusersub($user_id);
$get_rating_count=$this->submission_m->get_rating_count($rat_to);//rating_m
$this->data['get_rating_count']=$get_rating_count;
$get_rating_details=$this->submission_m->get_rating_details($rat_to);//rating_m
$this->data['get_rating_details']=$get_rating_details;
$sum=0;
foreach($get_rating_details as $rows)
{
$sum=$sum+$rows->rating;
}
$average_rating=0;
if($get_rating_count != 0)
$average_rating=(int)($sum/$get_rating_count);
if($this->input->post("accept") && $this->input->post("pk_submission_id")){
redirect('dashboard');
}else if($this->input->post("reject") && $this->input->post("pk_submission_id")){
$this->submission_m->reject_submission($submission_id);
$this->submission_m->rejectMail($emailid,$pname,$buyername);
redirect('dashboard');
}else if($this->input->post("rewrite") && $this->input->post("pk_submission_id")){
$this->submission_m->rewrite_submission($submission_id);
$this->submission_m->rewriteMail($emailid,$pname,$buyername);
redirect('dashboard');
}
$this->data['average_rating']=$average_rating;
$this->data['submission'] = $this->submission_m->get($submission_id);
$this->data['username'] = $this->user_m->get($this->data['submission']->fk_user_id);
$this->data['project'] = $this->addproject_m->get($this->data['submission']->fk_project_id);
$this->load->view('project/view_submission_details', $this->data);
}
Here is the view part
p_title ?>
img/close.png">
Writer's Name:
firstname ?>
Submitted Date:
created))); ?>
Rating:
</li><?php if($tip!= ""){?>
<li class="label-list">Tip for Writer:</li>
<li><?php echo $tip; } ?></li>
<br>
<?php if($numele>=1)
echo "Previous submissions";?>
<br>
<?php if($numele>=1)
echo "Number of submissions ".$numele;?>
<br>
<?php if($numacc>=1)
echo "Number of Projects Accepted ".$numacc;?>
<br>
<?php if($numrej>=1)
echo "Number of Projects Rejected ".$numrej;?>
<br>
<?php if($numrew>=1)
echo "Number of Projects Rewritten ".$numrew;?>
<br>
<? } ?>
<?php //echo "Tip".$get_rating_details->tip ?>
</ul>
<div class="content1 div-center2 colorwhite">
<p class="text-content"><?php echo nl2br( htmlentities($submission->content)) ?></p>
</div>
<div class="buttons">
<ul class="button-row">
<?php if(!($project->p_complete==1) && ($submission->status=='NOT REVIEWED')) { ?>
<?php
echo form_open('','id="contentForm"');
echo form_hidden("pk_submission_id",$submission->pk_submission_id);
echo " ".form_submit("accept","Accept",'class="btn-green .btn-small" id="acceptBtn"');
echo " ".form_submit("reject","Reject",'class="btn-red .btn-small"');
echo " ".form_submit("rewrite","Rewrite",'class="btn-blue .btn-small"');
echo form_close();
?>
<?php } ?>
</ul>
</body>
</html>
<script>
$(function() {
$("#acceptBtn").click(function(e){
var sdata = $('#contentForm').serialize();
$.ajax({
url: "<?php echo site_url('project/accept_submission'); ?>",
type: "POST",
data:sdata +'&accept=1',
success: function(data){
$('.buttons').remove();
$('#baseModal-xs .modal-content').html(data);
$('#baseModal-xs').modal("show");
}
});
return false;
});
});
</script>
It works locally but it does not run when live the project is still in development stage.
I don't know much about servers cause i only do coding, but in my company i was told to fix the issue and i have no clue my week end is going to be ruined :(
I had previously posted regarding the same issue but it was for different section even that was not fixed.
I don't know if the model part also can cause issue but i cant put the code cause i have passed to limit of the question size

In the view part i had added a extra closing brace which had no opening brace i removed that brace and Wa-lah it worked :).

Related

Value showing empty in browser , but its available in Database

Once we click on Download button, we are trying to download complete order details in pdf.... here 100452121 is orderid, xpress is shipping name & 14104918100111 is tracking id....
we set conditions that if tracking_id is empty, than it should echo 0 but we are getting zero [0] even when tracking_id available for the order....
Shippinglabel.php Full code in pastebin
<td><?php echo $orderrecords[$k]["order_id"]; ?><br/>
<?php
if ($st == 1) {
if ($orderrecords[$k]["tracking_id"] == '') {
?>
<input type="button" name="shipment" id="xpress" value="xpress"
onclick="createshipment('<?php echo $orderrecords[$k]["order_id"];?>')" />
<?php
}
}
?>
<?php
if ($orderrecords[$k]["tracking_id"] != '' && $orderrecords[$k]["shipping_name"] == 'xpress')
{
?>
<a target="_blank"
href="http://sbdev1.kidsdial.com/ecom1/xpress/xpressdownload.php?orderId=<?php
echo $orderrecords[$k]["order_id"];?>"
id="pdfdownload" >
<input type="button" name="shipment" value="DOWNLOAD" /></a>
<?php
}
?>
</td>
createshipment
function createshipment(orderid)
{
var assignee='<?php echo $_SESSION['login_user']?>';
alert(orderid);
$.ajax({
url: "xpressshipment.php",
type: "POST",
data:'orderid='+orderid+'&assignee='+assignee,
success: function(data){
if(data==1)
{
$("#pdfdownload").show();
}
if(data==0){alert("First Enter Tracking Id.");}
window.location ="http://sbdev1.kidsdial.com/ecom1/xpress/xpressdownload.php?orderId="+orderid;
}
});
}
xpressshipment.php Full code in pastebin
<?php
$data =
array (
'AirWayBillNO' => $resultc[0]['awb'],
);
if($res->AddManifestDetails[0]->ReturnMessage=='successful')
{
$sqli="update do_order set tracking_id='".$resultc[0]['awb']."',shipping_name='xpress' where order_id='".$order_id."'";
$resulti=$db_handle->executeUpdate($sqli);
}
?>
xpressdownload.php Full code in pastebin
<?php
if(isset($_GET['orderId']) && $_GET['orderId']!='')
{
$orderid=$_GET['orderId'];
}
else
{
echo 2;
}
$orderid='';
$sqlorder = "SELECT tracking_id,order_id from do_order where order_id='".$orderid."' limit 1";
$resultdoorder = $db_handle->runSelectQuerys($sqlorder);
if($resultdoorder['tracking_id']=='')
{
echo 0;
//var_dump("tracking_id");
}
var_dump("tracking_id"); gave string(11) "tracking_id" as result....
please let me know if you need more details....
please help me to find solution....
Thanks in Advance....
In file xpressdownload.php you defined variable $orderid incorrectly.
if(isset($_GET['orderId']) && $_GET['orderId']!='')
{
$orderid=$_GET['orderId'];
}
else
{
echo 2;
}
$orderid='';
First, you are checking whether $_GET['orderId'] exists and if yes, you give the value of $_GET['orderId'] to $orderid. This is correct.
But after the if... else block you give the $orderid the '' value. So in every case the $orderid has the null value and you sql query is not returning the record. You have to remove the line $orderid=''; or move it before the if statement.

Retrieving data from database and displaying it by using ajax

Okay people, what I am trying actually trying to achieve is, to create a chat box something similar to fb without refreshing the page. I have two tables in my database(phpmyadmin) where the first table, i store 2 users chat id(unique) and later save their message in another table so that i will be able to retrieve their chat history just by their unique id.
So I was able to send their Id(unique) by using get method to send the unique ID to the second div and then run through the database using php and display their conversation.
So how can i do it in ajax so that the page does not refreshes guys ? Some guide on that please ? I have been trying to google for it but i cant find a way simply because i do not know ajax much.
The purpose of me wanting it to not refresh the page is because i am using Jquery to hide and show the chat conversation. When the page refreshes, the conversation disappears. Im sorry if my explanation is not on point, hopefully somebody understands my problem and guide me in this :D
So here are my codes ...
This code is in my first div. It basically displays all the users who I have chatted with before...
<div>
<ul style="list-style-type: none;">
<?php
include 'connectDB.php';
//retrieve all the message history of yours from the PrivateMessage table
$query = "SELECT * FROM `messagecheck` WHERE `sender_a` = '$userId'
OR `sender_b` = '$userId';";
$result = mysqli_query($dbconnect,$query);
if(mysqli_num_rows($result) > 0)
{
//if exist, display the history
while($row = mysqli_fetch_assoc($result))
{
?>
<a href="Item_v1.php?msgId=<?php echo $row['exist']?>">
<li style="color:black; width:100%; padding-top:5px" >
<input id="IDValue" name="IDValue" value="<?php echo $row['exist']?>" >
<?php
//if the sender_a id is not my id, display the name
//if sender_a is my id, then display sender_b
//Because we dont want to see our name in the chat History
if($row['sender_a'] != $userId)
{
$senderName = $row['sender_a'];
include 'connectDB.php';
$nameSearch = "SELECT `fName`, `lName` FROM `register` WHERE `id`='$senderName';";
$Searchresult = mysqli_query($dbconnect,$nameSearch);
$Searchrow = mysqli_fetch_assoc($Searchresult);
echo $Searchrow['fName'] ." ". $Searchrow['lName'];
}
else
{
$senderName = $row['sender_b'];
include 'connectDB.php';
$nameSearch = "SELECT `fName`, `lName` FROM `register` WHERE `id`='$senderName';";
$Searchresult = mysqli_query($dbconnect,$nameSearch);
$Searchrow = mysqli_fetch_assoc($Searchresult);
echo $Searchrow['fName'] ." ". $Searchrow['lName'];
}
?>
</li>
</a>
<?php
}
}
?>
</ul>
</div>
So basically when i click the names which will be in the < li > tag, it should be posting the messages in another div(Which is the div below)...
<!-- //Message Content! -->
<div style="width:100%;max-height: 300;border: 2px solid #1F1F1F;overflow: auto;">
<?php
if($_GET)
{
$msgId = $_GET['msgId'];
}
if(!empty($msgId))
{
include 'connectDB.php';
$collectMsgQuery = "SELECT * FROM `privatemessage` WHERE `existing_id` = $msgId";
$MsgResult = mysqli_query($dbconnect, $collectMsgQuery);
if(mysqli_num_rows($MsgResult) > 0)
{
while($Msgrow = mysqli_fetch_assoc($MsgResult))
{
if($userId == $Msgrow['from_who']){
?>
<h4 class="ifMe"><span class="ifMeDesign"><?php echo $Msgrow['message'] ?></span></h4>
<?php
}else if ($userId == $Msgrow['to_who']) {
?>
<h4 class="notMe"><span class="notMeDesign"><?php echo $Msgrow['message'] ?></span></h4>
<?php
}
}
}
}
?>
</div>
P.S : I'm not really sure how to work with ajax so that is why i am posting it here. Any help would be great! Thanks in advance ! :D
Working with ajax, at the beginning, can be very frustrating. You should start with more simple task, simply to understand what you're working with.
Start with something like this, a simple request that send two numbers to the server and then alert the sum
ajax_request.php
<?php
$num1 = isset( $_GET[ "num1" ] ) ? $_GET[ "num1" ]: 0;
$num2 = isset( $_GET[ "num2" ] ) ? $_GET[ "num2" ]: 0;
echo $num1 + $num2;
index.html
<html>
<head>
<script src="jquery-1.11.3.min.js"></script>
<script>
$(document).ready(function () {
$( "#calculate" ).click(function(e) {
e.preventDefault();
$.ajax({
url: 'ajax_request.php',
data: $( "#form" ).serialize(),
success: function( data ) {
alert( data );
},
error: function() {
alert( "Something went wrong" );
}
});
});
});
</script>
</head>
<body>
<form id="form">
Num1: <input type="text" name="num1" /><br />
Num2: <input type="text" name="num2" /><br />
<input type="submit" id="calculate" />
</form>
</body>
</html>
Open index.html (download the jQuery library), fill the two numbers and click the button.
You can test the "Something went wrong", simply put a wrong url (ajax_requestx.php instead of ajax_request.php).
From here, you can study "ajax" and "jQuery" to understand better how this work.
The concept is this: you stop the form to be sent (e.preventDefault()) and instead send the form in "asyncronous" way, making javascript send the request to the server without changing the page; in the "success" function you can analyze the string sent back from the server and do something with it. All done by javascript

Which page is which acording to model-view-controller?

EDIT: My below example is more of a post-redirect-get than a MVC
I am reading a lot about correct structure for my page, MVC pattern, frameworks etc. and yet I am confused which parts of my page best fit under the description of model, of view and which of controller. Now before you downvote I did a lot of research already to separate my logic and make my simple page, I just need a confirmation that I am doing it right, what to fix/separate, which page is what according to MVC and where would I link or include index.php? I am not asking much I hope just for a quick glance at my code.
I will provide 3 different pages I built in order they are initialized as an example:
html form, also displays processed data user starts here:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Vaški gozd</title>
<link href="../html/css/base.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php if(!$_POST and $poskodbe != '0') { ?>
<p>Presenetil<?php text($spol); ?> te je <?php text($monster); ?> !</p>
<form action='../php/gozd.php' method='post'>
<input type='submit' name='action' value='Napadi' /> ali
<input type='submit' name='action' value='Pobegni' />
<input type='hidden' name='monster' value= '<?php text($monster); ?>' />
</form>
<?php }
else if ($poskodbe == '0'){text($moznost); ?>
<p><a href='../php/start.php'>Odpravi se proti domu</a></p>
<?php }
else { ?>
<ul><?php foreach ($combat as $turns => $i) { ?>
<li> <p><strong><?php text($i['napadalec']); ?></strong>
<?php text(' napade '); ?><strong><?php text($i['branilec']); ?></strong>
<?php text(' in mu napravi poškodbe za ') ?><strong><?php text($i['damage']); ?></strong>
<?php text(' točk zdravja '); } ?> </p></li>
</ul>
<?php if(isset ($zmaga)) { ?>
<p>Pregnal si <strong><?php text($monster_ime); ?></strong>!
V naglici je za seboj pustil <strong><?php text($cekini); ?></strong> cekinov, ki jih seveda pobereš.</p>
<p><a href='../php/gozd.php'>Raziskuj dalje</a></p>
<?php } ?>
<?php if(isset ($zguba)) { ?>
<p>Podlegel si poškodbam <strong><?php text($monster_ime); ?></strong>.</p>
<?php } ?>
<p><a href='../php/start.php'>Odpravi se proti domu</a></p>
<?php } ?>
</body>
</html>
php that processes data and returns results:
<?php
session_start();
include 'config.php';
include 'stats.php';
$igralec_ime = $_SESSION['username'];
$_SESSION['poskodbe'] = ($poskodbe = prikazi_stat('curhp', $igralec_ime));
if ($poskodbe == '0') {$_SESSION['moznost'] = ($moznost = 'Tvoje zdravje je resno ogroženo, vrni se domov!');}
else {
if ($_POST) {
if($_POST['action'] == 'Napadi') {
$igralec = array (
'ime' => $igralec_ime,
'napad' => prikazi_stat('ofe',$igralec_ime),
'obramba' => prikazi_stat('def',$igralec_ime),
'curhp' => prikazi_stat('curhp',$igralec_ime)
);
$monster_ime = $_POST['monster'];
$monster = array (
'ime' => $monster_ime,
'napad' => prikazi_monster_stat('ofe',$monster_ime),
'obramba' => prikazi_monster_stat('def',$monster_ime),
'curhp' => prikazi_monster_stat('maxhp',$monster_ime)
);
$combat = array();
$turns = 0;
while($igralec['curhp'] > 0 && $monster['curhp'] > 0) {
if($turns % 2 != 0) {
$napadalec = &$monster;
$branilec = &$igralec; }
else {
$napadalec = &$igralec;
$branilec = &$monster; }
$damage = 0;
if($napadalec['napad'] > $branilec['obramba']) {
$damage = $napadalec['napad'] - $branilec['obramba']; }
$branilec['curhp'] -= $damage;
$combat[$turns] = array(
'napadalec' => $napadalec['ime'],
'branilec' => $branilec['ime'],
'damage' => $damage
);
$turns++; }
update_stat('curhp',$igralec_ime,$igralec['curhp']);
if($igralec['curhp'] > 0) {
update_stat('cek',$igralec_ime,prikazi_stat('cek',$igralec_ime)+ prikazi_monster_stat('cek',$monster_ime));
$zmaga = 1;
$cekini = prikazi_monster_stat('cek',$monster_ime); }
else {
if ($igralec['curhp'] <0) {update_stat('curhp', $igralec_ime, '0'); }
$zguba = 1; } }
else {
header('Location:../php/start.php');
exit;
}
}
else {
$query = sprintf("SELECT ime, spol FROM monsters ORDER BY RAND() LIMIT 1");
$result = mysql_query($query);
list($monster, $spol) = mysql_fetch_row($result);
}
}
$_SESSION['moznost'] = $moznost;
$_SESSION['monster'] = $monster;
$_SESSION['spol'] = $spol;
$_SESSION['poskodbe'] = $poskodbe;
$_SESSION['combat'] = $combat;
$_SESSION['turns'] = $turns;
$_SESSION['zmaga'] = $zmaga;
$_SESSION['zguba'] = $zguba;
$_SESSION['monster_ime'] = $monster_ime;
$_SESSION['cekini'] = $cekini;
$_SESSION['post'] = $_POST;
header('Location:../php/gozd_kontroler.php',true,303);
exit;
?>
php page that has included html page from earlier and to which my data manipulating php script redirects to display results:
<?php
session_start();
include 'razno.php';
$monster = $_SESSION['monster'];
$spol = $_SESSION['spol'];
$poskodbe = $_SESSION['poskodbe'];
$moznost = $_SESSION['moznost'];
$combat = $_SESSION['combat'];
$turns = $_SESSION['turns'];
$zmaga = $_SESSION['zmaga'];
$zguba = $_SESSION['zguba'];
$monster_ime = $_SESSION['monster_ime'];
$cekini = $_SESSION['cekini'];
$_POST = $_SESSION['post'];
include '../html/gozd.html';
?>
Which page is which acording to model-view-controller? Am I doing it right at all? Where would I link or include index.php?
Which page is which according to model-view-controller?
A page is a page. It isn't part of MVC, it is built using MVC.
The view is the class that (given some data) generates whatever is sent to the client (usually HTML).
The model is the class that operates on the data. It talks to your database or other data store.
The controller is the class that looks at the URL, decides which models and views are right for it and exchanges data between the submitted data, the models and the view.
Am I doing it right at all?
No
Where would I link or include index.php?
Your index page should just bootstrap your controller class.

Displaying menu names from CMS

I have been trying to display a menu name from my CMS database that I created myself, I got it displayed perfectly but there is a really weird error, I spent many hours to discover the solution but I couldn't.
The problem is that I want to display the menu name as page H1 in line 50 exactly so whenever you click on the menu name its also displaying as H1 title.
The menu name is displaying correctly, but the sub menu(pages) displaying N instead of the page name, I don't know where is that N is coming from.
NOTE: There is no problem with the database connection or retrieving data.
This is my content page code:
<?php include("includes/header.php"); ?>
<?php require_once 'includes/db_connection.php'; ?>
<?php require_once 'includes/b_functions.php'; ?>
<?php require_once 'includes/cms_constants.php'; ?>
<?php db_connect();?>
<?php
if (isset ( $_GET ['subj'] )) {
$sel_subject = get_subject_by_id ( $_GET ['subj'] );
$sel_page = "NULL";
} elseif (isset ( $_GET ['pages'] )) {
$sel_subject = false;
$sel_page = get_page_by_id ( $_GET ['pages'] );
} else {
$sel_subject = "NULL";
$sel_page = "NULL";
}
?>
<table id="structure">
<tr>
<td id="navigation">
<ul class="subjects">
<?php
$subject_set = get_all_subjects();
while ($subject = mysql_fetch_array($subject_set)) {
echo "<li";
if ($subject["id"] == $sel_subject["id"]) { echo " class=\"selected\""; }
echo "><a href=\"contents.php?subj=" . urlencode($subject["id"]) .
"\">{$subject["menu_name"]}</a></li>";
$page_set = get_pages_for_subject($subject["id"]);
echo "<ul class=\"pages\">";
while ($page = mysql_fetch_array($page_set)) {
echo "<li";
if ($page["id"] == $sel_page["id"]) { echo " class=\"selected\""; }
echo "><a href=\"contents.php?pages=" . urlencode($page["id"]) .
"\">{$page["menu_name"]}</a></li>";
}
echo "</ul>";
}
?>
</ul>
</td>
<td id="page">
<?php if (!is_null($sel_subject)) { // subject selected ?>
<h2><?php echo $sel_subject['menu_name']; ?></h2>
<?php } elseif (!is_null($sel_page)) { // page selected ?>
<h2><?php echo $sel_page['menu_name']; ?></h2>
<div class="page-content">
<?php echo $sel_page['content']; ?>
</div>
<?php } else { // nothing selected ?>
<h2>Select a subject or page to edit</h2>
<?php } ?> </td>
</tr>
</table>
<?php require_once 'includes/footer.php';?>
Your 'N' is coming from the "NULL" string. I believe you meant to set your variables with actual NULL and not a string. Like:
$var = NULL;
As opposed to:
$var = "NULL";
When you access a variable that is set to "NULL" as an array, you will get the 'N' (as the string is treated as an array). For instance;
$var = "NULL";
echo $var[0]; // 'N'
Furthermore, if you test for NULL on a string it will return false (the variable is non-null);
$var = "NULL";
if($var) {
echo "var is: " . $var;
}
else {
echo "var is NULL!";
}
The above should output "var is: NULL".
I say this from experience (I did this when I started coding PHP). However, the root of your problem likely doesn't stop there as your variables should be set in subsequent conditionals. I would go through your while statements, and if statements and ensure your variables are being set appropriately. (var_dump($var) or print_r($var) through suspect blocks).

SlickGrid error: Slick.Editors.Text is not a constructor

I'm trying to implement SlickGrid on the edit page of a CakePHP project, and when the page loads I get this error in the javascript console:
slick.grid.js:2173TypeError:'Slick.Editors.Text is not a constructor' (evaluating 'new (editor || getEditor(activeRow, activeCell))')
The data renders correctly in the grid on my page, but when I click on a cell to edit it, it just turns white and I can't type anything. If I click on another cell, that cell will turn white and the first one will stay white.
Here is my php/jQuery code:
<?php echo $this->Html->script("/js/slickgrid/lib/jquery-1.7.min.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/lib/jquery.event.drag-2.0.min.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/lib/jquery-ui-1.8.16.custom.min.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.core.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.grid.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.editors.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.formatters.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.dataview.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/plugins/slick.cellselectionmodel.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/plugins/slick.cellrangedecorator.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/plugins/slick.cellrangeselector.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/plugins/slick.rowselectionmodel.js"); ?>
<?php // Setup rows and cols array for grid
$columns = array();
foreach($route['Stop'] as $stop) {
$columns[] = array( "name" => $stop['name'],
"field" => $stop['id'],
"id" => $stop['id'],
"editor" => "Slick.Editors.Text");
}
$tripId = 1;
$thisTrip['id'] = $tripId;
foreach($route['RouteTrip'] as $routeTrip) {
if($routeTrip['trip_id'] != $tripId) {
$rows[] = $thisTrip;
$tripId = $routeTrip['trip_id'];
$thisTrip['id'] = $tripId;
}
else {
$thisTrip[$routeTrip['stop_id']] = $routeTrip['time'];
}
}
?>
<?php
echo $this->Html->scriptBlock('
var rows = '.json_encode($rows).';
var columns = '.json_encode($columns).';
var options = { rowHeight:21,
defaultColumnWidth:100,
editable:true,
enableAddRow:true,
enableCellNavigation:true,
asyncEditorLoading:false,
autoHeight:true,
autoEdit:true
};
slickgrid = new Slick.Grid($("#scheduleTable"), rows, columns, options);
slickgrid.setSelectionModel(new Slick.CellSelectionModel());
slickgrid.updateRowCount();
slickgrid.render();
');
?>
The $rows and $columns are correctly formatted, and each column has an "editor" attribute with "Slick.Editors.Text" as its value.
Help?
I have also got this error initially when i started working with slickgrid.
The error is because you have specified the editor as string and not as a class.
So, remove the double quotes in "editor" => "Slick.Editors.Text" and give as "editor" => Slick.Editors.Text
This solved the error for me. Hope this solution will solve yours too.
Include the slick.editors.js file.
Also, make sure that the editor is being specified as a class, not as a string (I'm not familiar with PHP, so it's not obvious to me from the source code, but I suspect that's the case).

Categories