Codeigniter - Parse error: syntax error, unexpected '-', expecting '{' -
i'm new in codeigniter programming , i'm having problems link controller.
i've got homepage (home.php) wich i've go page.
home.php
<?php defined('basepath') or exit('no direct script access allowed'); ?> <!-- default home page --> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>animania manager</title> <link rel="stylesheet" href="application/styles/foundation.css"> <link rel="stylesheet" href="application/styles/app.css"> <link rel="stylesheet" href="https://cdn.datatables.net/1.10.11/css/jquery.datatables.min.css" /> <link rel="stylesheet" href="application/styles/reset.css"> <!-- css reset --> <link rel="stylesheet" href="application/styles/style.css"> <!-- gem style --> <script src="application/js/modernizr.js"></script> <!-- modernizr --> <script src="http://code.jquery.com/jquery-1.12.0.min.js"></script> <!--script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script--> <script src="https://cdn.datatables.net/1.10.11/js/jquery.datatables.min.js"></script> <script> $(document).ready(function() { $('#offerte').datatable(); } ); $(document).ready(function() { $('#curriculum').datatable(); } ); </script> <script> $(document).ready(function() { // setup - add text input each footer cell $('#offerte tfoot th').each( function () { var title = $(this).text(); $(this).html( '<input type="text" placeholder="cerca '+title+'" /> '); } ); // datatable var table = $('#offerte').datatable(); // apply search table.columns().every( function () { var = this; $( 'input', this.footer() ).on( 'keyup change', function () { if ( that.search() !== this.value ) { .search( this.value ) .draw(); } } ); } ); } ); $(document).ready(function() { // setup - add text input each footer cell $('#curriculum tfoot th').each( function () { var title = $(this).text(); $(this).html( '<input type="text" placeholder="cerca '+title+'" /> '); } ); // datatable var table = $('#curriculum').datatable(); // apply search table.columns().every( function () { var = this; $( 'input', this.footer() ).on( 'keyup change', function () { if ( that.search() !== this.value ) { .search( this.value ) .draw(); } } ); } ); } ); </script> </head> <body> <div class="container row"> <header class="testata" role="banner"> <nav class="menu"> <ul> <li>inserimento offerta</li> <li>inserimento cv</li> <li></li> </ul> </nav> <nav class="main-nav"> <ul> <!-- inser more links here --> <li><a class="cd-signin" href="#0">login</a></li> <li><a class="cd-signup" href="#0">registrazione</a></li> </ul> </nav> </header> </div> <div class="cd-user-modal"> <!-- entire modal form, including background --> <div class="cd-user-modal-container"> <!-- container wrapper --> <ul class="cd-switcher"> <li><a href="#0">login</a></li> <li><a href="#0">nuovo account</a></li> </ul> <div id="cd-login" action="validation.php" method=get> <!-- log in form --> <form class="cd-form"> <p class="fieldset"> <label class="image-replace cd-email" for="signin-email">e-mail</label> <input class="full-width has-padding has-border" id="signin-email" type="email" placeholder="e-mail" name="email"> <span class="cd-error-message">errore</span> </p> <p class="fieldset"> <label class="image-replace cd-password" for="signin-password">password</label> <input class="full-width has-padding has-border" id="signin-password" type="text" placeholder="password" name="password"> <a href="#0" class="hide-password">nascondi</a> <span class="cd-error-message">errore!</span> </p> <p class="fieldset"> <input type="checkbox" id="remember-me" checked> <label for="remember-me">ricordami</label> </p> <p class="fieldset"> <input class="full-width" type="submit" value="login"> </p> </form> <p class="cd-form-bottom-message"><a href="#0">hai dimenticato la password?</a></p> <!-- <a href="#0" class="cd-close-form">close</a> --> </div> <!-- cd-login --> <div id="cd-signup"> <!-- sign form --> <form class="cd-form"> <p class="fieldset"> <label class="image-replace cd-username" for="signup-username">username</label> <input class="full-width has-padding has-border" id="signup-username" type="text" placeholder="username"> <span class="cd-error-message">errore!</span> </p> <p class="fieldset"> <label class="image-replace cd-email" for="signup-email">e-mail</label> <input class="full-width has-padding has-border" id="signup-email" type="email" placeholder="e-mail"> <span class="cd-error-message">errore!</span> </p> <p class="fieldset"> <label class="image-replace cd-password" for="signup-password">password</label> <input class="full-width has-padding has-border" id="signup-password" type="text" placeholder="password"> <a href="#0" class="hide-password">nascondi</a> <span class="cd-error-message">errore!</span> </p> <p class="fieldset"> <input type="checkbox" id="accept-terms"> <label for="accept-terms">accetto <a href="#0">termini</a></label> </p> <p class="fieldset"> <input class="full-width has-padding" type="submit" value="crea account"> </p> </form> <!-- <a href="#0" class="cd-close-form">close</a> --> </div> <!-- cd-signup --> <div id="cd-reset-password"> <!-- reset password form --> <p class="cd-form-message">hai perso la tua password? inserisci il tuo indirizzo email. riceverai un link per la creazione di una nuova password!</p> <form class="cd-form"> <p class="fieldset"> <label class="image-replace cd-email" for="reset-email">e-mail</label> <input class="full-width has-padding has-border" id="reset-email" type="email" placeholder="e-mail"> <span class="cd-error-message">errore!</span> </p> <p class="fieldset"> <input class="full-width has-padding" type="submit" value="reset password"> </p> </form> <p class="cd-form-bottom-message"><a href="#0">torna al log-in</a></p> </div> <!-- cd-reset-password --> <a href="#0" class="cd-close-form">chiudi</a> </div> <!-- cd-user-modal-container --> </div> <!-- cd-user-modal --> <?php if ($offers !== false) { print('<div> <table class="display" id="offerte" cellspacing="0" width="100%"> <thead> <tr> <th>titolo</th> <th>descrizione</th> <th>candidati</th> </tr> </thead> <tfoot> <tr> <th>titolo</th> <th>descrizione</th> <th>candidati</th> </tr> </tfoot><tbody>'); //for($i = 0; $i < count($offers); $i++){ foreach ($offers $offer){ //echo base_url(); //$url=base_url('single-offerta')."?idannunci=".$offer->getid(); print("<tr>"); print("<td>".$offer->gettitolo()."</td>"); print("<td>".$offer->getdescrizione()."</td>"); //print('<td><a href="'.site_url('singoff2').'">'.$offer->getpartecipanti().'</a></td>'); print('<td>'.anchor('singoff2', 'link text').'</td>'); print("</tr>"); } print("</tbody></table></div>"); } else { echo 'nessuna offerta'; } ?> <!--script src="js/vendor/jquery.js"></script--> <script src="application/js/vendor/what-input.js"></script> <script src="application/js/vendor/foundation.js"></script> <script src="application/js/app.js"></script> <script src="application/js/main.js"></script> <!-- gem jquery --> </div> </body> </html>
singoff2.php (controller other page)
<?php if ( ! defined('basepath')) exit('no direct script access allowed'); class single-offerta extends ci_controller { public function index() { $this->load->library("singofffactory"); //create data array can pass information view $data = array( "dettagli" => $this->singofffactory->getdettagli() ); //load view , pass data $this->load->view("singoff2", $data); } }
if try link have error below:
parse error: syntax error, unexpected '-', expecting '{' in d:\inetpub\webs\animaniait\manager\application\controllers\singoff2.php on line 4 php error encountered severity: parsing error message: syntax error, unexpected '-', expecting '{' filename: controllers/singoff2.php line number: 4 backtrace:
now if try change class name in singoff.php file have 404 error.
please me.....i'm going crazy!!
just read error. line 4 , invalid character -
- hyphen. dashes or hyphens not allowed in class names. class name should follow file name, meaning 2 need exact same. warm advice read full ci documentation. pay attention on file naming , class , method naming. also, helpful read php oop basics.
a valid class name starts letter or underscore, followed number of letters, numbers, or underscores. regular expression, expressed thus: ^[a-za-z_\x7f-\xff][a-za-z0-9_\x7f-\xff]*$.
in example file should single_offerta.php
, line 4 should accordingly
class single_offerta extends ci_controller {
if want access url example.com/single-offerta
efficient way translate uri dashes in apppath.'config/routes.php'
file setting true
:
$route['translate_uri_dashes'] = true;
Comments
Post a Comment