php,laravel,laravel-routingRelated issues-Collection of common programming errors


  • Josh
    php mysql
    I have a file /admin/php.php which has the following:<?php$ID=$_GET[‘ID’];require(“../admin/config.php”);$sql = “SELECT * FROM contacts WHERE contacttype IN (‘New’,’Buyer’,’Seller’,’Buyer / Seller’,’Investor’) AND leadstatus = ‘New’ ORDER BY date DESC”;$space = (!empty($row[‘firstname’]) && !empty($row[‘lastname’])) ? ‘ ‘ : ”; $name = $row[‘firstname’].$space.$row[‘lastname’]; $partner = $row[‘spousefirst’]; $cell = (!empty($row[‘phonecell’])) ? ” {$row[‘phonecell’

  • Orangepill
    php
    I was troubleshooting some code and I took it out of the execution path so that I could look in other places.PHP continued to call out the code as an error despite it not being executed. It is in a function that is not called.Is this expected behavior?// not in execution path$temp1 = $this->hash;$temp = array(‘1’, $temp1); // this is line 121$this->database_object->_pdoQuery(‘none’, ‘update_picture’, $temp );syntax error, unexpected T_LNUMBER, expecting ‘]’ in/home/foo/public_html/dev/

  • Stefan Vogt
    php url urldecode
    I have: http://www.example.com/index.php?amount=15%252E8In index.php:$test = $_GET[‘amount’];echo $test; // Output: 15%2E8But I don’t need 15%2E8, I need 15.8$test = $_GET[‘amount’];$test = urldecode($test);echo $test; //Output: 15.8But in http://us2.php.net/manual/en/function.urldecode.php they warn: Warning: The superglobals $_GET and $_REQUEST are already decoded.Using urldecode() on an element in $_GET or $_REQUEST could haveunexpected and dangerous results.Why $_GET[‘amount’] does not get

  • Florian
    php function namespaces use
    I’m trying to make the following work:function flosoftdedicated_api_init() { require_once ‘resources/vendor/autoload.php’; use \Ovh\Common\Ovh;….$ovh = new Ovh($config); return $ovh; }function flosoftdedicated_ClientArea($params) { global $ovh;$ovh = flosoftdedicated_api_init(); …. }but I get the error: Parse error: syntax error, unexpected T_USE in …./flosoftdedicated.php on line 35 Line 35 being the use statement.Is it not possible to use a namespace in a function? Do I need to assign t

  • Sebas
    php javascript jquery ajax boolean
    This question already has an answer here:How to convert string to boolean php6 answerslet’s say we have the following ajax:$.ajax({url:’myURL.php’,data:{ac:’do’,isDoable:false} });Now at the back end when reading the call data, the isDoable is a string, and trying to cast it as Boolean: $isDoable = (bool) $_REQUEST[‘isDoable’];results in $isDoable always being true, even when sent as false. When I encountered this issue I gave up and simply treated it as a string if($_REQUEST[‘isDoable’] == ‘tru

  • Andrew Lott
    php arrays sorting
    I want to apply different sorting on my array but I am getting unexpected results. This is my array result:Array ( [0] => Sony,HTC [1] => HTC [2] => AT&T [3] => Sony [4] => BlackBerry [5] => Nokia [6] => Toshiba [7] => Altori )When I print this array using sort($rows,SORT_ASC) it displays ‘1’.$rows as the array that contains elements. Can anybody find what the problem here is?I want to sort the array with different options like (SORT_REGULAR,SORT_NUMERIC).

  • richard
    php arrays parsing loops syntax
    I am trying to loop array from database in email.php but i am getting this error:Parse error: syntax error, unexpected ‘;’, expecting ‘)’ in /home/xxx/public_html /email.php on line 62 This is the code in email.php:$allowed_senders = Array($query = “SELECT email FROM members”; // Line 62$result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $loop_email = $row[’email’];echo “‘”.$loop_email.”‘,”; } ); I don’t understand what went wrong. Any help?

  • Yeshwanth Venkatesh
    php ajax codeigniter form-validation
    I am trying to validate a form and save it in my database. I am using codeigniter’s validation library and it fails. this is the ajax function inside the view function save_form(){ $.ajax({url: ‘/projects/cafe/index.php/welcome/save_form’,type: ‘post’,data: {‘fname’ : $(‘#fname’).val(),’lname’ : $(‘#lname’).val(),’story_name’ : $(‘#story_name’).val(),’email’ : $(‘#email’).val(),’address_street’ : $(‘#address_street’).val(),’city’ : $(‘#city’).val(),’state’ : $(‘#state’).val(),’zip’ : $(‘#zip’)

  • ConcurrentHashMap
    php constants
    I have a lot of pages, all of which require the file characters.php. This file contains constants which define many things in my website. They are defined like this, for example:const $humanHEALTH = 1.1;Everything works properly running it in my localhost using WAMP, but when I upload it to an online host I get this error:Parse error: syntax error, unexpected T_CONSTI used phpinfo() on one of the pages and the PHP version is 5.2.17.Any help would be greatly appreciated.

  • halfer
    php cakephp
    I have this line of code, unfortunately though it has a syntax error:Parse error: syntax error, unexpected T_DOUBLE_ARROW on line 1Here is the code:<?php echo $this->Html->link(‘View/Edit’, array(‘action’ => ‘view’, $client[‘Client’][‘id’]), “?” => array(‘nc’ => time(), array(‘class’ => ‘view’)); ?>Where is the mistake in here and how can I get this resolved?

  • Shnd
    laravel laravel-4
    I got Laravel 4 zip file from gitHub. (“laravel-master”). run composer and get all the dependencies. i can access it from: “127.0.0.1/laravel-master/public”but when i rename the “laravel-master” to other names, and then try to access it, i get:”HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.” I can not figure out what’s going wrong !

  • Roopendra
    php laravel
    I’m trying to use two params with a named route through a controller, but receive an error when loading the viewRouteRoute::get(‘agendarVehiculo/{idvehiculo}/{idcita}’, array(‘as’ => ‘agendarVehiculo’, ‘uses’ => ‘AgendamientosController@addAgendaCitaVehiculo’));View<td> <a href=”{{ route(‘agendarCitaPaciente’, [$paciente->id, $cita->id ] }}” class=”btn btn-xs btn-success”> <i class=”fa fa-calendar”> Agendar</i></a> </td>Errorsyntax error, unexpecte

  • Antonio Carlos Ribeiro
    laravel laravel-4
    When I run composer.phar installI get this error almost at the end of the installation, any ideas?Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating autoload filesWarning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in /home/belendez/public_html/laravel/artisan on line 46Parse error: syntax error, unexpected T_STRING in /home/belendez/public_html/laravel/artisan on line 46 Script

  • SLim
    php laravel laravel-4 laravel-artisan
    Would like to know how can i execute the PHP Artisan script inside my controller of Laravel? Tried the following code but it doesn’t work.php /Users/sl/Dropbox/Development/ABC/artisan currency:update;This is the error returned: syntax error, unexpected ‘currency’ (T_STRING)Thanks

  • Rubens Mariuzzo
    laravel twig sentry cartalyst-sentry
    I’m trying to check if Sentry user is logged in on twig template on a Laravel project, i’m using twigbridge.How do i?{% if Sentry::Check() == false %}This gives me:Unexpected token “punctuation” of value “:” (“end of statement block” expected) in “layouts.menu” at line 61Same for:{{ Sentry::getUser()->first_name }}

  • Bhadresh Arya
    html laravel
    While using HTML Placeholder with class in Laravel 4, shows me this error.Symfony \ Component \ Debug \ Exception \ FatalErrorException syntax error, unexpected ‘;’I’ve used{{ Form::text(‘name’, null, array(‘class’ => ‘form-control’, ‘placeholder’ => ‘Your Name’) }}

  • Mark Lewis
    php laravel
    I was referred to Juggling Larger Laravel Applications and I’m havihng trouble gettingView::addNamespace(‘Marketing’, __DIR__.’/../Views’)to work in one of my sub-app directories where the views are located at /var/www/myapp.com/app/MyApp/Marketing/Views Placing this code in my /var/www/myapp.com/app/MyApp/Marketing/Providers/MarketingServiceProvider.php<?php namespace MyApp\Marketing\Providers;use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\View;class MarketingServiceP

  • Alex Morrise
    php laravel
    I am trying to copy a project from localhost to live server done in Laravel 4 framework. On the local machine it is working, but I have this error in live server:Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in /**********/laravel/bootstrap/autoload.php on line 46Parse error: syntax error, unexpected T_STRING in /**********/laravel/bootstrap/autoload.php on line 46I didn’t modify those files.Thanks

  • Anand mohan sinha
    php laravel
    I am using laravel for my php project everything worked fine in devlopment but during hosting since i wasen’t given a shell access on server so i could not create a symlink . so i moved the contents of public folder to root and changed index.php accordingly . but i have been getting this errorWarning: chdir() [function.chdir]: No such file or directory (errno 2) in /home/saarorgi/public_html/paths.php on line 62Parse error: syntax error, unexpected T_STRING in /home/saarorgi/public_html/larav

  • edi9999
    php testing laravel phpunit laravel-4
    I’m trying to create some tests.Here’s my Test Class:class ExampleTest extends TestCase {public function setUp(){parent::setUp();Artisan::call(‘migrate’);$this->seed();Auth::loginUsingId(1);}public function testActionUpdateNew(){$action = new Action(Array());$action->save();var_dump($action->id);Action::with(‘reponses’,’contact’,’user’,’etudiant’,’entreprise’,’etude’)->findOrFail($action->id);}public function testEtudes(){$etudes=Etude::all()->toArray();$this->assertCount(10

  • core_m
    model controller laravel laravel-4 laravel-routing
    I can’t get rid of the errors. I’ve created an model, and have functions in controllers and a route, but I get errors.my model(newsticker.php):<?phpclass Newsticker extends Eloquent {protected $table = ‘aac_newsticker’;protected $fillable = array(‘label’, ‘content’);public $timestamps = true; }my controller (also used for other functions, but used also for newstickers):<?phpclass NewsController extends BaseController {/*** News Repository** @var News*/protected $news;public function __cons

  • teresko
    php laravel laravel-routing
    I’m trying to access the name of the current controller and the current method to pass it to my view as a variable. I’ve tried several ways from pointers I found online but they don’t work so I assume they were for Laravel 3.Here is what I’ve triedRequest::$route->controllergivesAccess to undeclared static property: Illuminate\Support\Facades\Request::$routeandRequest::route()->controllergivesCall to undefined method Illuminate\Http\Request::route()

Web site is in building