php,javascript,forms,emailRelated issues-Collection of common programming errors
Gordon
php
Pretty straightforward question: In PHP, when do you use define(‘FOO’, 1);and when do you useconst FOO = 1;What are the main differences between those two?
Matt Ball
php computer-algebra-systems
I’m creating a CAS (Computer Algebra System) in PHP, but I’m stuck right now. I am using this website.Now I wrote a tokenizer. It will convert an equation like this:1+2x-3*(4-5*(3x))to this:NUMBER PLUS_OPERATOR NUMBER VAR[X] MINUS_OPERATOR NUMBER MULTIPLY_OPERATOR GROUP(where group is another set of tokens). How can I simplify this equation? Yeah, I know what you can do: adding X-vars, but they are in the sub-group. What is the best method I can use for handling those tokens?
iainjames88
php ubuntu-12.04 error-reporting internal-server-error
I’ve set up a fresh install of Ubuntu Server 12.04 LTS on Amazon AWS with *Apache2/MySQL/PHP5. When I run a PHP script and it encounters an error I don’t see any error reporting from PHP, all I see isHTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.I have checked my /etc/php5/apache2/php.ini file and as far as I can tell error reporting should be set up. The contents of the file (regarding errors) are:; displ
Charles
php oop
Using PHP 5.3 I’m experiencing weird / non-intuitive behavior when applying empty() to dynamic object properties fetched via the __get() overload function. Consider the following code snippet:<?phpclass Test {protected $_data= array(‘id’=> 23,’name’=> ‘my string’);function __get($k) {return $this->_data[$k];}}$test= new Test(); var_dump(“Accessing directly:”); var_dump($test->name); var_dump($test->id); var_dump(empty($test->name)); var_dump(empty($test->id));var_dump(“Ac
codaddict
php operators ternary-operator
This is what I wrote :$Myprovince = ( ($province == 6) ? “city-1” : ($province == 7) ? “city-2” : ($province == 8) ? “city-3” : ($province == 30) ? “city-4” : “out of borders” );But for every field I got the value city-4. I want to use ternary operators instead of switch/if because I want to experiment and see how it would be done.What’s the problem with this code?
Jess Telford
php unit-testing phpunit
When running a PHPUnit test, I would like to be able to dump output so I can debug one or two things.I have tried the following (similar to the PHPUnit Manual example);class theTest extends PHPUnit_Framework_TestCase {/*** @outputBuffering disabled*/public function testOutput() {print_r(“Hello World”);print “Ping”;echo “Pong”;$out = “Foo”;var_dump($out);} }With the following result:PHPUnit @package_version@ by Sebastian Bergmann..Time: 0 seconds, Memory: 3.00MbOK (1 test, 0 assertions)Notice
user456885
php multibyte
Given certain multibyte character sets, am I correct in assuming that the following doesn’t do what it was intended to do?$string = str_replace(‘”‘, ‘\\”‘, $string);In particular, if the input was in a character set that might have a valid character like 0xbf5c, so an attacker can inject 0xbf22 to get 0xbf5c22, leaving a valid character followed by an unquoted double quote (“).Is there an easy way to mitigate this problem, or am I misunderstanding the issue in the first place?(In my case, the st
testwork
php facebook facebook-graph-api facebook-php-sdk
I have a problem with posting image in more than one facebook pages. I am creating an image using GD Library.I am using facebook api to post in the pages with pageid and page access token. When a submit button is clicked for the first time the image is not uploaded and gives the error – **OAuthException: An unexpected error has occurred. Please retry your request later.Fatal error: Uncaught OAuthException: An unexpected error has occurred. Please retry your request later thrown in /sdk/base_fac
apaul34208
php class codeigniter
Basically I have a helper file with several function. I auto load the helper in the config file so theoretically reloading it is not required.However when I try to use the function that I created(from this helper) within a new library that I am working on it will through this error:”Parse error: syntax error, unexpected ‘(‘, expecting ‘,’ or ‘;’ in /home/techwork/public_html/giverhub/application/libraries/Udetails.php on line 7″Whenever I use that function anywhere else(module,controller,views)
khellang
php javascript jquery ajax
Basically I am trying to post a comment via AJAX and then load the new comment into the HTML. I am having a problem with what I think is my AJAX success function. The data gets added to the database fine, but I still get an error “Sorry, unexpected error. Please try again later.” as set inside the success function itself.JS:function newComment(event) { event.preventDefault();//Get the data from all the fieldsvar comment = $(‘textarea’);var product_id = $(‘input[name=product_id]’);var form
John Snow
javascript google-maps animation google-maps-api-3 google-maps-markers
I have a simple javascript maps application that I’m working on that requires me to animate the movement of multiple markers between different coords. Each marker is free to move on its own and all markers are stored in an array list. However, I have been having trouble getting them to smoothly transition locations.I’ve done a ton of research and trial/error but no luck, anyone have any luck with this?
pvorb
javascript node.js foreach v8
I wanted to use for each … in with Node.js (v0.4.11).I use it like this:var conf = {index: {path: {first: “index.html”,pattern: “index/{num}.html”},template: “index.tpl”,limit: 8},feed: {path: “feed.xml”,template: “atom.tpl”,limit: 8} }for each (var index in conf) {console.log(index.path); }I get the following error:for each (var index in conf) {^^^^node.js:134throw e; // process.nextTick error, or ‘error’ event on first tick^ SyntaxError: Unexpected identifierat Module._compile (module.js:397
Peter Mortensen
javascript programming-languages crockford
This question already has an answer here:Calling member function of number literal3 answersI’m reading through Douglas Crockford’s JavaScript: The Good Parts, and I’m at the point where he defines a fade function. Part of this code boils down to this:var level = 1; var hex = level.toString(16);So I run this in my browser’s console to see what I get….var level = 1; level.toString(16);Hey, it returns “1”… Fabuloso! Wunderbar!Then to be cheeky, I try this to see what I get…1.toString(16);and
LukeS
javascript jquery html scrolling mobile-browser
I am trying to scroll to a specific location in a scrolling DIV. Right now I am using a pixel offset with the jQuery scrollTop() function which works great on desktop browsers but it does not work on android mobiles browsers with the exception of Google’s Chrome Android browser (do not have an iOS device to test if that works). All the solutions I have found are for page (window) scrolling and not for scrolling in a DIV, anyone have any suggestions on what else I can use to accomplish the same
muntoo
javascript dhtml
I want to create a simple bit of JS code that creates an image element in the background and doesn’t display anything. The image element will call a tracking URL (such as Omniture) and needs to be simple and robust and work in IE 6 =< only. Here is the code I have:var oImg=document.createElement(“img”); oImg.setAttribute(‘src’, ‘http://www.testtrackinglink.com’); oImg.setAttribute(‘alt’, ‘na’); oImg.setAttribute(‘height’, ‘1px’); oImg.setAttribute(‘width’, ‘1px’); document.body.appendChild(
Tim
javascript jquery asp.net ajax
I have a modal dialog on my page using jQuery that a user enters a password into.It’s a standard jQuery dialog and it works fine. I have linkbuttons in a datagrid that open the dialog using this code:$(‘.needsVal’).click(function () {$(“#login1”).dialog(‘open’);id = $(this).attr(‘id’);return false;});The problem is later on in the page I make an Ajax call, and based on the value returned, I want to selectively fire a postback for the page. The problem is the postback never fires. My postback cod
Marek Lipka
javascript ruby-on-rails heroku
So I’m a newbie and I am having issues deploying my code onto Heroku. I keep getting this error response. It looks like a JS Parse Error, which I have no idea what it could be. ANY help would be amazing. Thanks!I was successfully able to upload my previous application. I worry that it was because I tried to install some JQUERY plugins and it deleted the info inside my JS folderRunning: rake assets:precompileI, [2013-12-10T02:45:51.431542 #852] INFO — : Writing /tmp/build_63a972cd-66ca-44
khellang
php javascript jquery ajax
Basically I am trying to post a comment via AJAX and then load the new comment into the HTML. I am having a problem with what I think is my AJAX success function. The data gets added to the database fine, but I still get an error “Sorry, unexpected error. Please try again later.” as set inside the success function itself.JS:function newComment(event) { event.preventDefault();//Get the data from all the fieldsvar comment = $(‘textarea’);var product_id = $(‘input[name=product_id]’);var form
JrnDel
javascript multidimensional-array
I’m trying to construct a multidimentional array in javascript, so far without succes. I’ve read some other posts here on Stackoverflow, and read/watched tutorials on the subject, all have helped me but but I can’t get it to work.Most of the time I get the following error:Uncaught SyntaxError: Unexpected tokenBasically, I’ve got a form where the visitor of my website can input their age, bloodpressure, cholesterol and if they’re a smoker of not.riscTable = { ’68’: { // AGE’170′: { //
Connor Leech
javascript angularjs gruntjs angularjs-ng-include
When I deploy my unminified code everything works great. Then I run grunt build and deploy from the dist folder, as you do. When I check out one of the pages though it breaks and I get an error in the console: Error: [$parse:lexerr] Lexer Error: Unexpected next character at columns 0-0 [\] in expression [\]. http://errors.angularjs.org/1.2.6/$parse/lexerr?p0=Unexpected%20nextharacter%20&p1=s%200-0%20%5B%5C%5D&p2=%5Cat https://353a23c500dde3b2ad58-c49fe7e7355d384845270f4a7a0a7aa1.ssl.cf2
cpjolicoeur
ruby-on-rails forms serialization
I have a data model in my Rails project that has a serialized field:class Widget < ActiveRecord::Baseserialize :options endThe options field can have variable data info. For example, here is the options field for one record from the fixtures file:options:query_id: 2 axis_y: ‘percent’axis_x: ‘text’units: ‘%’css_class: ‘occupancy’dom_hook: ‘#average-occupancy-by-day’table_scale: 1My question is what is the proper way to let a user edit this info in a standard form view?If you just use a simple
user2147744
jquery html forms
Whenever I try to run this script it say “Unexpected token ILLEGAL” <form name=”abc” id=”fform” class=”contactform”><p><label for=”name”>Name:</label><br /><input type=”text” name=”name” id=”name” value=”” class=”input” /> <br/><label for=”email”>Email:</label><br /><input type=”text” name=”email” id=”email” value=”” class=”input” /> </p><input name=”send” id=”submit_btn” class=”submit_btn” type=”submit” value=”Join” /
johnnyfittizio
html forms twitter-bootstrap laravel laravel-4
I have to define a checkbox within a Laravel 4 app. But at the same time it is a Bootstrap 2.3.1 site, and i need to pass also Input::old How can i do it?This is how it was in html:<label class=”checkbox”><input type=”checkbox” name=”extraBed” value=”extra” /><span class=”blue”><strong class=”blue”><span><i class=”icon-plus”></i></span> Extra bed</span></label>This is how i have tried to write in Laravel4:<label class=”checkbox”>
F21
php ajax forms symfony2
I am building a web application that involves forms. The framework being used is symfony2. I would like to have everything working for users without javascript, and then progressively enhance the experience for people with javascript enabled. I am planning to use JQuery as my javascript library.I would like to have forms where it submits and displays a message using the FlashMessage component if the user does not have javascript and the request is not an ajax request.For users with javascript su
jkkennedytv
php forms explode delimiter nl2br
I have created a form which utilizes a .txt file to pull the names of the EMPLOYEES from and breaks them up in the SELECT form option using the PHP explode function.<select name=”FakeName” id=”Fake-ID” aria-required=”true” required><option value=””></option><?php$options=nl2br(file_get_contents(“employees.txt”));$options=explode(“<br />”,$options);for($i=0;$i<count($options);$i++){echo “<option value='”.$options[$i].”‘>”.$options[$i].”</option>”;}?> &
Sumurai8
php forms .htaccess mod-rewrite url-rewriting
i have problem with mod rewritei made htaccess to convert url from php to htmland every thing finebut problem is some file i dont need to convert like form.phpthis is my htaccessRewriteCond %{REQUEST_URI} !^(.*)form.php(.*)$ RewriteCond %{REQUEST_URI} !^(.*)sitemap\.xml(.*)$ RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^/]+)\.php\s RewriteRule .* %1.html [R=301,L] RewriteRule ^([^/]*)\.html$ $1.php RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule ^.*$ – [L] RewriteRule ^index.php$ http://%{http_host}
Ren Hoek
forms sharepoint-2010
I cant find a glue for that. Trying to edit a Listitem in the Browser , I get an Error the Log says:File Not Found: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Layouts\EditingMenu\SiteAction.xml System.ArgumentNullException: Der Wert darf nicht NULL sein. Parametername: s bei System.IO.StringReader..ctor(String s) bei System.Xml.XmlDocument.LoadXml(String xml) bei Microsoft.SharePoint.Publishing.Internal.WorkflowUtilities.FlattenXmlToHashtable(Str
ksu
forms checkbox ruby-on-rails-4 syntax-error erb
Rails 4, ruby 2.0. I want to make a public file serving page with a download link for each file and the possibility to check multiple files for download with checkboxes and a “Download checked files” button. My code in index.html.erb<% form_tag(controller: “files”, action: “download_many”, method: “get”)%> <h1>St.Catherines</h1><ul> <% @stcatherines.each do |file|%><li><%= link_to file, :action => “download”, :name =>file %></li><%check_b
s28400
php forms login submit action
I have a bit of a problem with my website. I have phpbb integrated into my website and a login form on the homepage. This form needs to execute two different actions. It first needs to run the ucp.php (to log into phpbb) and also the login.php (to hide the form and add control panel on home screen). They both work by themselves, I just need a way to have them together when a user logs in. i have researched this for a while and can’t find a solution. Thanks in advances, JoshI need to combine this
Dustin
javascript jquery forms
I have a rate calculator on my site with a simple set of selects that looks like this:<select name=”room”><option value=”Green”>Green Room</option><option value=”Red”>Red Room</option><option value=”Blue”>Blue Room</option><option value=”Orange”>Orange Room</option><option value=”Yellow”>Yellow Room</option></select></td><td>and I rehearse </td><td><select name=”rehearsals”><option value=”1″&
Greg Steiner
xcode cocoa email scripting-bridge
Here’s what I’m attempting to do: Let’s assume that you are in mail and create a New blank mail message, then enter some data into it, such as body copy, etc. (in my case, the message was created through scripting bridge using the “Mail Contents of this Page” from safari… the main purpose of this process for my application.)From my application, I want to select that message and assign it to:MailOutgoingMessage *myMessage;so that I can programmatically add recipients. I’ve tried several ways
Benjamin
php email
Fairly new to PHP, and I’m working on a simple form,Users enter in their information and then once it’s checked to see if the information is there and not empty, then use the mail function to send it outhere is the codeI get the error Parse error: syntax error, unexpected ‘,’ in C:\xampp\htdocs\registration.php on line 20line 20 is where the mail function isif (isset ($_POST[‘attendee’]) && isset ($_POST[‘attending’]) && isset ($_POST[‘message’]) && isset ($_POST[‘contact
Nick
email cakephp cakephp-2.1
I’m building a CakePHP website that sends an e-mail like this:$email = new CakeEmail(‘default’); $email->template(‘test’); $email->emailFormat(‘html’); $email->to(array(‘[email protected]’ => ‘John Doe’)); $email->subject(‘Test E-mail’); $email->helpers(array(‘Html’, ‘Text’)); $email->viewVars(array(…) );if ($email->send()) {$this->Session->setFlash(‘The e-mail was sent!’, ‘default’, array(‘class’ => ‘alert alert-success’)); } else {$this->Session->set
haiqus
ruby email sinatra contact-form
I’m trying to place a simple contact form on my site. In the application file, I have,post ‘/contact’ doname = params[:name]mail = params[:mail]inquirykind = params [:inquirykind]body = params[:body]Mail.defaults.dodelivery_method :smtp, { :address => “smtp.gmail.com”,:port => 587, :user_name => “[email protected]”,:password => “password”,:authentication => ‘plain’,:enable_starttls_auto => true }endmail = Mail.new dofrom ‘#{mail}’to ‘[email protected]’subject ‘#{inq
Nishchal Gautam
php html email formatting email-client
Once I tried to display the mails in my logged in panel for me(as I am the webmaster), when I send email from gmail where i bolded some texts, and when i viewed the body, it gave me unexpected results, for example i had bolded the text like this then it would give me *bolded* or something like this and same in case of links if i would give link, then it would not give me html links but it will format in something other way. its just like that how we type here in questioning but how would i chang
centic
java email apache-commons-email
Currently I am using Commons Email to send email messages, but I have not been able to find a way to share smtp connections between emails sent. I have code like the following:Email email = new SimpleEmail();email.setFrom(“[email protected]”);email.addTo(“[email protected]”);email.setSubject(“Hello Example”);email.setMsg(“Hello Example”);email.setSmtpPort(25);email.setHostName(“localhost”);email.send();Which is very readable, but is slow when I do a large amount of messages, which I believe
user852974
php email mailer
I have this form<form method=”POST” action=”mailer.php”><div id=”email”><input type=”email” name=”email” class=”email” placeholder=”[email protected]”></div></form>And this PHP<?php $email = $_POST[’email’]; $to = “[email protected]”; $subject = “ADD THIS EMAIL ADDRESS TO THE MAILING LIST”; $body = “\n\n”; $url = ‘http://10.0.1.1/~ewiuf’; if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo ‘<script> alert(“PLEASE ENTER A VALID EMAIL ADDRESS”) </script>
dTDesign
css email html-email newsletter
I am trying to put together an html email newsletter (similar to stackexchange newsletter) and trying to figure out the best practice for layout given no ability to include external css. If there any better solution than simply shoving a whole set of style css inline into divs, tables, etc? Also want to make sure its visible / renderable on as many email clients as possible.
prapin
email for-loop lua
Basically, I have several devices I need to pull data from. I get multiple emails when the temperature measures are under or over the set limits. I would like to have a for loop to include all current devices states that are under or over limits into one email.body = for device_name, 1 do device_name++ — I get error here because unexpected symbol near ‘for'”Device Name: ” ..device_name.. “\nDevice Location: ” ..device_location.. “\n————————————————————–“
ikegami
perl email pipe
2 examples with issues: What is wrong with the following statement syntax (perl newbie):$mailCmd = sprintf(“echo $message | /usr/ucb/mail -s ‘X Detected an Invalid Thing’ %s”, $people_list);When I do system($mailCmd) or `$mailCmd`, it results in:sh: syntax error at line 2: `|’ unexpectedAnother one:$message = “Invalid STUFF setup for ID $r. Please correct this ASAP.\n” .”Number of thingies = $uno \n” .”Another thingy = $id \n” ;This produces:sh: Number: not found sh: Another: not foun
Web site is in building