简体   繁体   中英

Error viewing the same page on localhost

My ctp file code :

<?php echo $this->Form->create('Users',array('action'=>'port_settings_edit')); ?>

<tr><td><center><?php echo $this->Form->input('process',array('type'=>'hidden','value'=>$pid,'id'=>'pid')); ?>
<?php echo $pname; ?></center></td><td><center>
<?php echo $characteristic; ?></center></td><td><center>
<select id="deviceid"></select></center></td><td><center><select id="instid">
<option value="">Select Any</option>
<option value="xyzz">xyzz</option>
<option value="fgh">fgh</option>
<option value="abc">abc</option>
</select></center></tr></table>
<BR><BR> &nbsp; &nbsp; &nbsp;
<button type="submit" id="submit_btn" class="bott1"><font size=3 ><b>SUBMIT</b></font></button>
  • function defined in my controller :

     function port_settings_edit($id=null) { $this->loadModel('Process'); $op=$this->Process->find('first',array('conditions'=>array('Process.id'=>$id))); $this->set('pname',$op['Process']['name']);//ERROR $this->set('pid',$op['Process']['id']);//ERROR $this->set('characteristic',$op['Process']['characteristic']);//ERROR if(!empty($this->data)) { //$this->layout = false; //print_r($this->data); $this->Session->setFlash('PORTS SETTINGS ARE DONE SUCCESSFULLY.'); $this->redirect(array('action'=>'viewport')); } } 

I am encountering the same error on these 3 lines. ie

undefined syntax: process

I have already defined the variables.

I can see some issue in your CakePHP code.

  1. in method you have passed $id , and form action url is also wrong it should be <?php echo $this->Form->create('Users',array('url'=>['action'=>'port_settings_edit',$pid]));?>
  2. Also no need to pass $pid in hidden field because you are fetching from url.

Also please mention which error exactly you are facing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM