php,codeigniter,rest,codeigniter-2Related issues-Collection of common programming errors
waiwai933
php exception exception-handling throw
I’m trying to use exceptions in PHP as a way of avoiding multiple if-then-else blocks. However, when I try to catch the exception, I get the error Parse error: syntax error, unexpected T_CATCH in /directory/functions.php on line 66. Am I doing something wrong with my throwing and catching?function doThis($sSchool, $sDivision, $sClass, $sUsername, $sCode,$query1,$query2) {connectDb();global $dbConnection;$sDivisionIdArray = mysqli_query($dbConnection,$query1);if ($sDivisionIdArray==false){throw n
Galen
php mvc
i know that everything is going through the controller.but i often read articles that says something like this:user interacts with the view controller asks the model to change its state model notifies the view when its sate has changedi dont get the 3rd one. why saying that the model notifies the view, when it actually is notifying the controller and the controller is notifying the view?
Phil Jackson
php upload
Im using BluImp file uploader. Greate little script that I’ve used forever.Now I have scoured there forum and cant find anything but after debugging, I believe it is more of a permissions/restrictions/settings problem.Once the upload has appeared to have finished, an error is returned:Error: SyntaxError: Unexpected end of inputAfter debugging it is cause by any functions writing to the server, i.e. file_put_contents, move_upload_file….The file is 1.47 mbmy additional ini alterations are max_ex
maxgee
php html mysql table variables
I am trying to get this data to go into a table so I can view it better on my website and I dont really understand how to combing PHP and HTML and I was getting this error Parse error: syntax error, unexpected ‘;’ I dont know if I combine them wrong so here is my code and tell me if I need to supply more than this line of code. <h2>Featured Event’s</h2> <body> <table cellpadding=”10″> <tbody> <?php echo ?><td><?php $eventname ?></td><?php
Bojangles
php mysql jquery-ui
This seemed simply but i’m running into a problem. I’m building an autocomplete drop down box using jquery ui. It works fine with static information but when i try put dynamic data from mysql in the array it freaks out.Parse error: syntax error, unexpected T_DO, expecting ‘)’ on line 46Line 46 is the do in the array$items = array(do { $row_Recordset1[‘ARTIST’]; } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); );I’ve searched the net but I can’t find anything relating to problems w
ZyteX
php html compiler-errors echo
I have a long HTML code which I’m echoing out through the echo code. However I get an error and if I remove the code on all the lines where it says there’s an error I get an error on the body instead. When I try to connect to my page I get this error: ( ! ) Parse error: syntax error, unexpected $end inC:\wamp\www\Legendary\new\usersettings.php on line 670http://fiddle.jshell.net/n4a6W/** EDIT ** I just noticed one of the errors, but the errors with almost all of the is still there…
teresko
php yii optional-parameters yii-cmodel
I am trying to modify 1 controller to work with 2 models. This is what I have done with loadModel function in my controllerpublic function loadModel($id, $_model) {if (isset($_model)){$model=$_model::model()->findByPk($id); // syntax error, unexpected “::”if($model===null)throw new CHttpException(404,’The requested page does not exist.’);return $model;} else {$model=Foods::model()->findByPk($id);if($model===null)throw new CHttpException(404,’The requested page does not exist.’);return $mod
JDelage
php ajax json
All,I’m trying to pass a stringified json object as a GET parameter but the receiving URL seems unable to decode it, I am not sure why.Here is the relevant code:Client side Json object production (works fine): function createJson(){ // This works fine. It creates a json objects with three elements, the third being an array. //(omitted code for brevity)return jsonData; }Client side ajax call (works fine):function recordSetGet(jsonData){request = createRequest();var rawSet=JSON.stringify(jsonDat
Colin
php parsing
I’ve finally started to learn PHP and I quite have trouble with it. I am trying to make a website change its stylesheet according to the moment of the day (day, twilight, night) and I’ve taken this approach:<?php$lt = localtime();if ($lt[2]>=6 && $lt[2]<=16)echo(‘<link href=”style.css” rel=”stylesheet” type=”text/css” />’);elsif ($lt[2]>=17 && $lt[2]<=21)echo(‘<link href=”style_twilight.css” rel=”stylesheet” type=”text/css” />’);elseecho(‘<link href=
psniffer
php versions
i wrote a small program to help me study, it works fine on the localhost, but when i upload it i get an error message that has me stumped the line i get the error with is below<?php echo “Num # : ” . ($_SESSION[‘monster’]->getQuestionNumber()[$q]) .” of ”. $_SESSION[‘monster’] -> getTotalQuestions() . “<BR>”;?>on the local host i have PHP Version 5.4.4-14+deb7u5on the remote server i have PHP Version 5.2.6the error i get is Parse error: syntax error, unexpected
PeeHaa
php .htaccess codeigniter url url-rewriting
I tried to make my website’s URL cleaner(and SEO friendly) by removing the index.php from my URLs but unexpected results happend, this is my .htaccess file: <IfModule mod_rewrite.c> <IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /### Canonicalize codeigniter URLsRewriteRule ^(site(/index)?|index(\.php)?)/?$ / [L,R=301]RewriteRule ^(.*)/index/?$ $1 [L,R=301]# Removes trailing slashes (prevents SEO duplicate content issues)RewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.+)/$ $1
elavarasan lee
codeigniter switch-statement
I want to use switch statement in codeigniter form_dropdown. My code seems like:$schedule_options = array(); foreach($schedules as $schedule){ $schedule_options[$schedule->scheduleId] = .$schedule->scheduleDays.’ – ‘.$schedule->scheduleTime; } echo form_dropdown(‘classScheduleId’, $schedule_options, set_value(‘classScheduleId’, $class->classScheduleId));I want to switch $schedule_options before having it printed in form_dropdown.for example:switch($schedule_options) {case ‘even’: ec
user1423446
codeigniter
I have developed a small accounting application which running fine in xampp in windows machine and also it is working fine in my development server (linux based).But, when i migrate the total application to client linux server I got the following error:Parse error: syntax error, unexpected T_STRING in /home/orcilia/public_html/cfm/application/models/sm_main.php on line 1I have checked it several times but unable to found an error … But, I think in the client server there is some issue in case
Sumurai8
php apache .htaccess codeigniter error-handling
My website has been slowed down a little last couple of days. I’ve looked into my error log and found lots of these:[Mon Sep 30 00:09:53 2013] [error] [client 66.249.66.205] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace. [Mon Sep 30 00:09:53 2013] [debug] core.c(3120): [client 66.249.66.205] r->uri = /home/mysitecom/domains/mysite.com/public_html/
SideDishStudio
jquery ajax codeigniter jquery-ajax
So I’m using .load() to call a CI method to load some code into a div like normal. CI loads the correct content into the div UNLESS there is a trailing slash on the class, then it actually ignores the method I am loading and loads the default method in that class … ie:THIS WORKS FINE:I call .load(‘http://domain.com/class/ajaxmethod’)from domain.com/class/methodTHIS DOES NOT:I call .load(‘http://domain.com/class/ajaxmethod’)from domain.com/class/method/It will actually load http://domain.com/cl
JJD
json codeigniter codeigniter-datamapper
var data = xhr.responseText;When I output this console.log(xhr.responseText). Below is my output [“{id:1,name\”:\”JOHN\”,\”city\”:\”null\”}” ,”{\”id\”:2,\”name\”:\”MICHEAL\,\”city\”:\”null\”}”]How do I get id, name. I tried like this data.id but I get this error jquery JSON.parse: unexpected end of data.UpdateI am using code igniter with data mapper so my data mapper is giving that json response. Do you know, how I can resolve it.
Rocket Hazmat
codeigniter
I’m trying to get the id of last inserted record in the Db. But i’m getting the errorParse error: syntax error, unexpected T_RETURN in Z:\www\CI4\application\models \report_model.php on line 69my model:function getLastInserted() { $query =”SELECT $id as maxID from info where $id = LAST_INSERT_ID()”return $query; //line 69}my controller:function index(){ $id=$this->report_model->getLastInserted();$this->load->view(‘u_type1’,$id);}
hakre
php codeigniter codeigniter-2
I am new to codeigniter and trying to access data from mysql databasehere is my model class codefunction model_data($a){ $this->load->database(); $query = $this->db->query(“SELECT* FROM mytable3”); return $query->result(); }function model_data_cat(){ $this->load->database(); $query = $this->db->query(“SELECT* FROM mytable1”); return $query->result(); } Actually i am calling two functions in my controller. one is model_data and the other is model_data_cat. bu
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’)
teresko
php codeigniter error-handling relative-path
I am using code igniter, and I need to be able to read and/or include some html files, so I created an includes directory in the application folder. Using CI what is the best way to access this directory?In my controller I have tried:private $cms_temp_folder = APPPATH . ‘includes/’;But that gives me the error:Parse error: syntax error, unexpected ‘.’, expecting ‘,’ or ‘;Am I approaching this right, or should I be doing it another way?
Buddy
ruby-on-rails rest
Wondering if I should ALWAYS use the respond_to/format.xxx block in ALL of my actions in ALL of my controllers. This came up because I realized that, for apps using only HTML response format (no respond_to block), I could send some other type of request (say XML) and get a valid response. Is this considered insecure? Feels to me like it is, and it seems that the solution would be to ALWAYS add the respond_to/format.xxx block to EVERY action on EVERY controller even if you are just using HTML
Matt M.
rest dns
We are are going to be creating some RESTful services which are essentially going to be a passthrough to some ye-olde-fashioned SOAP-based webservices. The SOAP services are more generalized and will used across our entire organization (at least that’s the plan). The RESTful services are tailored to specific clients. This decision was already made and is unfortunately out of my control to change…We’re struggling with how to structure our RESTful resources in a way that makes sense, follows
Ashish Patha
windows json wcf rest curl
when i post a raw string as an input to JSON REST Service call it is executing ex:curl -d “{\”input1\”: \”as\”, \”input2\”: \”ad\”}” -i -X POST -H “Content-Type:application/json” http://localhost/rtygies/Service1.svc/rest/receivedata1 But when i am posting as an xml as input it is giveng error as below:curl -d “{\”input1\”: \”<xml></xml>\”, \”input2\”: \”<xml></xml>\”}” -i -X POST -H “Content-Type:application/json” http://localhost/rtygies/Service1.svc/rest/receivedat
noircc
rest jersey jackson enunciate
I have a rest-project which is using jersey+enunciate and now i wanna test the endpoints with malicious strings. The output of the programm seems to me like a JacksonParseException but with no details or stacktrace:Unexpected character (‘6’ (code 54)): was expecting comma to separate ARRAY entriesat [Source: org.apache.catalina.connector.CoyoteInputStream@28fe53cf; line: 1, column: 35]I wanna catch the exception but even declaring an default error-page won’t do the work, also the ExceptionMapper
LU RD
wcf asp.net-mvc-3 rest
I have created a ReST WCF Service in .NET 4.0. It’s hosted in IIS (.svc). The .svc file is mapped correctly in IIS 7.5. When I try to consume the WCF Service in MVC 3, I get an error :”The remote server returned an unexpected response: (405) Method Not Allowed.” I created a proxy by adding a service reference to my MVC project. Let me know if you have encountered this issue and have the solution. Please help! I already spent 2 days on it.
conny
web-services rest http-status-codes
Is it to be considered good practice to reuse RFC HTTP Status codes like this, or should we be making up new ones that map exactly to our specific error reasons?We’re designing a web service API around a couple of legacy applications. In addition to JSON/XML data structures in the Response Body, we aim to return HTTP Status Codes that make sense to web caches and developers.But how do you go about mapping different classes of errors onto appropriate HTTP Status codes? Everyone on the team agrees
Cory Kendall
http rest
I’m implementing the logic for a RESTful web server which supports searching with a SolR like syntax. Here are some common valid requests:”https://www.somewhere.com/fooResource/123″ “https://www.somewhere.com/fooResource/456” “https://www.somewhere.com/fooResource?q=title:hi” “https://www.somewhere.com/fooResource?q=title:hello&sort=foo”My question is very generic; what should I do if I receive a request like this?”https://www.somewhere.com/fooResource?q=title:hi&something=foo”I receive
Bruce
rest soap communication
We are building a proprietary system involving a client and a server linked over TCP/IP. Occasionally, the server will have some new expected or unexpected information that would be of interest to the client. My understanding is that SOAP and REST are query/response systems that require the client to request something and the server responds back. We need the client to register and the server to respond back if and when the new information is available. Are these protocols capable of such be
mdtsandman
java android rest restlet
I’ve been playing around a bit with restlet, and so far I like it :)I am having some trouble getting a restlet client to work on an android emulator, though.Right now a have a very simple restlet server running under JSE. All it does is expose a root resource (which for the moment is just a line of text) via the GET method. I can get consume the resource with a browser, and also with a simple restlet client running in the console. I have modified the code for the JSE client to try to connect
Marek Grzenkowicz
web-services rest soap soapui sugarcrm
I saw somewhere in net (like SugarCRM SOAP test call fails), that some people use SoapUI to access SugarCRM SOAP or REST web services, with urls like http://ip/sugarcrm/service/v2/soap.php and http://ip/sugarcrm/service/v2/rest.php, respectively. I tried it, with ‘New SoapUI Project’ wizard, and putting that urls in ‘Initial WSDL/WADL:”. But I only get error messages:”Error loading [http://ip/sugarcrm/service/v2/soap.php] org.apache.xmlbeans.XmlException: error: Unexpected character encountered:
hakre
php codeigniter codeigniter-2
I am new to codeigniter and trying to access data from mysql databasehere is my model class codefunction model_data($a){ $this->load->database(); $query = $this->db->query(“SELECT* FROM mytable3”); return $query->result(); }function model_data_cat(){ $this->load->database(); $query = $this->db->query(“SELECT* FROM mytable1”); return $query->result(); } Actually i am calling two functions in my controller. one is model_data and the other is model_data_cat. bu
fl3x7
php codeigniter smarty codeigniter-2 smarty3
Im currently using codeigniter 2 with ci-Smarty. Just been trying to add a smarty output filter but not having much luck. Its as if the function cannot be found or something?I am using a plugin as the output filter function and have the following code:LOCATION: /libraries/Smarty.php// Set email output filter $this->loadFilter(‘output’, ‘protect_email’);LOCATION: /third_party/Smarty/plugins/function.protect_email.phpfunction smarty_function_protect_email($tpl_output, Smarty_Internal_Template $
Sasha
php codeigniter codeigniter-2
This question already has an answer here:PHP ini file_get_contents external url6 answersI am using function (snippet from CSS Trics) to get country of the user based on IP. On localhost (on my computer) it is working without the problem, but once I transferred and tried website this is the error I am getting:Fatal error: Uncaught exception ‘InvalidArgumentException’ with message ‘Error contacting Geo-IP-Server’ in/home/elsaorgr/public_html/application/core/MY_Controller.php:72 Stack trace: #0 /
Murat Ünal
php doctrine2 codeigniter-2
I developed a ecommere system which works fine on localhost, however, at remote server it gives the fatal error;Fatal error: Uncaught exception ‘Doctrine\ORM\Mapping\MappingException’ with message ‘Class models\category\ProductCategory is not a valid entity or mapped super class.’ in /home/munal/public_html/cikurulum/application/libraries/Doctrine/ORM/Mapping/MappingException.php:137 Stack trace: #0 /home/munal/public_html/cikurulum/application/libraries/Doctrine/ORM/Mapping/Driver/AnnotationDri
Herdi Yudha Yusuf
php jquery facebook-graph-api jquery-ajax codeigniter-2
i want to show friends list with FQL in facebook application with Jquery ajax Load. I have succes to load user friends list but sometimes had some error like this : Fatal Error : Uncaught OAuthException: An Active access token must be used to query information about the current user. How can I handle this Error?here’s my javascrpit code and I use CodeIgniter :$(‘#boyslist’).load(‘friendslist/boyslist’, function(){ //some callback script });$(‘#girlslist’).load(‘friendslist/girlslist’,functio
j0k
mysql codeigniter doctrine doctrine2 codeigniter-2
Please help me get to the bottom of this error: Fatal error: Uncaught exception ‘Doctrine_Connection_Exception’ with message ‘PDO Connection Error: SQLSTATE[28000] [1045] Access denied for user ‘root’@’localhost’ (using password: NO)’Checked my Database config file and it reads correctly, Below is my config file: $db[‘default’][‘hostname’] = ‘localhost’; $db[‘default’][‘username’] = ‘root’; $db[‘default’][‘password’] = ‘mypassword’; $db[‘default’][‘database’] = ‘mydb’; $db[‘default’][‘dbdriver’]
Abdullah Nasir
javascript codeigniter twitter-bootstrap codeigniter-2
I am using Codeigniter + TwitterBootstrap +jqueryWhenever i add any javascript plugin be it Uploadify(flash version), ratty, Tagit, tagsManagerThe initialize function always throw this kind of error:Uncaught TypeError: Object [object Object] has no method ‘tagsManager’ (anonymous function) c p.fireWith b.extend.ready H Kindly advise as to what i am doing wrong!
Drudge
php doctrine2 codeigniter-2
I am making entities using doctrine in codeigniter by reversenginerring (i.e. i had my database and i had made the entities by running the command orm:convert-mapping –form-database annotation models/Entity) my doctrine.php goes like this …<?phpuse Doctrine\Common\ClassLoader,Doctrine\ORM\Tools\Setup,Doctrine\ORM\EntityManager;class Doctrine {public $em;public function __construct(){require_once __DIR__ . ‘/Doctrine/ORM/Tools/Setup.php’;Setup::registerAutoloadDirectory(__DIR__);// Load the
AlvinArulselvan
soap codeigniter-2 soap-client
I am getting the following error. What is wrong? How I can catch or solve this exception.Fatal error: Uncaught SoapFault exception: [a:InternalServiceFault] The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on traci
Ram
forms codeigniter-2
I am new to codeigniter trying out some simple pages. I have successfully connected to the database for inserting and updating. But now I want to populate the fields from the database for updating. That is when the user selects the name from the dropdown the corresponding values should appear in the other fields so that the user can update easily.I have worked on this to do without ajax or jquery. It worked for me but with some warning message – Use of undefined constant.I am giving by mvc. Help
Web site is in building