Search Results

Search found 1121 results on 45 pages for 'quotes'.

Page 12/45 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Is there a standard way to encode a .NET string into javascript string for use in MS AJAX?

    - by Rich Andrews
    I'm trying to pass the output of a SQL Server exception to the client using the RegisterStartUpScript method of the MS ScriptManager. This works fine for some errors but when the exception contains single quotes the alert fails. I dont want to only escape single quotes though - Is there a standard function i can call to escape any special chars for use in Javascript? string scriptstring = "alert('" + ex.Message + "');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", scriptstring , true); Thanks tpeczek, the code almost worked for me :) but with a slight amendment (the escaping of single quotes) it works a treat. I've included my amended version here... public class JSEncode { /// <summary> /// Encodes a string to be represented as a string literal. The format /// is essentially a JSON string. /// /// The string returned includes outer quotes /// Example Output: "Hello \"Rick\"!\r\nRock on" /// </summary> /// <param name="s"></param> /// <returns></returns> public static string EncodeJsString(string s) { StringBuilder sb = new StringBuilder(); sb.Append("\""); foreach (char c in s) { switch (c) { case '\'': sb.Append("\\\'"); break; case '\"': sb.Append("\\\""); break; case '\\': sb.Append("\\\\"); break; case '\b': sb.Append("\\b"); break; case '\f': sb.Append("\\f"); break; case '\n': sb.Append("\\n"); break; case '\r': sb.Append("\\r"); break; case '\t': sb.Append("\\t"); break; default: int i = (int)c; if (i < 32 || i > 127) { sb.AppendFormat("\\u{0:X04}", i); } else { sb.Append(c); } break; } } sb.Append("\""); return sb.ToString(); } } As mentioned below - original source: here

    Read the article

  • How can I query Google Spreadsheets API with a string value?

    - by ColinM
    I am using Zend_Gdata_SpreadsheetsListQuery. In PHP my query is: "confirmation=$confirmation" The problem is that $confirmation = 'AB-CD-EFG-012345'; Apparently the hyphens are causing problems with the query and the exception thrown is: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 Parse error: Invalid token encountered' How can I quote or escape the value to not cause parse errors? Single quotes cause the same error, double quotes don't throw errors but there are no results to match.

    Read the article

  • html-encode output && incorrect string error

    - by fusion
    my data includes arabic characters which looks like garbage in mysql but displays correctly when run on browser. my questions: how do i html-encode the output? if i add this to all my files: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> i get this error: Error: Incorrect string value: '\xE4\xEE\xC3\xD8\xEF\xE6...' for column 'cQuotes' at row 1 i'm working on php/mysql platform. insertion form in html: <!doctype html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Your Favorite Quotes</title> <link rel="stylesheet" type="text/css" href="style.css" /> <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" charset="utf-8" /> <script type="text/javascript" src="scripts/jquery-1.4.2.js"></script> <script src="scripts/jquery.validationEngine-en.js" type="text/javascript"></script> <script src="scripts/jquery.validationEngine.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("#submitForm").validationEngine() }) </script> </head> <body> <div class="container"> <div class="center_div"> <h2>Submit Your Quote</h2> <fieldset> <form id="submitForm" action="qinsert.php" method="post"> <div class="field"> <label>Author: </label> <input id="author" name="author" type="text" class="validate[required,custom[onlyLetter],length[0,100]]"> </div><br /> <div class="field"> <label>Quote: </label> <textarea id="quote" name="quote" class="validate[required, length[0,1000]]"></textarea> <br /> </div> <input id="button1" type="submit" value="Submit" class="submit" /><br /> <input id="button2" type="reset" value="Reset" /> </form> </fieldset> </div> </div> </body> </html> ////////////////////// query in php: //<?php //header('Content-Type: text/html; charset=UTF-8'); //?> <!doctype html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="style2.css" /> <title>Your Quote Databank</title> </head> <body> <?php include 'config.php'; echo "Connected <br />"; //check for quotes and apostrophes $author = ''; $quote = ''; $author = $_POST['author']; $quote = $_POST['quote']; $author = mysql_real_escape_string(trim($author)); $quote = mysql_real_escape_string(trim($quote)); //************************** //validating data $query = "SELECT * FROM Quotes where cQuotes = '$quote' limit 1;"; $result = mysql_query($query, $conn); //now check that the number of rows is 0 if (mysql_num_rows($result) > 0 ) { header("Location: /error.html"); exit; } //inserting data //mysql_query("SET NAMES 'utf8'"); //mysql_query("SET CHARACTER SET utf8"); $sql="INSERT INTO Quotes (vauthor, cquotes) VALUES ('$author', '$quote')"; if (!mysql_query($sql,$conn)) { die('Error: ' . mysql_error()); } echo "<div class='container'><p><label class='lbl_record'> Record Added Successfully!</label>"; echo "<a href='qform.html'> Submit a New Quote!</a></p>"; //************************** //selecting data $result = mysql_query("SELECT * FROM Quotes ORDER BY idQuotes DESC"); echo "<div class='center_div'>"; echo "<table> <thead> <tr> <th>Author</th> <th>Quotes</th> </tr> </thead>"; while($row = mysql_fetch_array($result)) { echo "<tbody><tr>"; echo "<td width='150px'>" . $row['vAuthor'] . "</td>"; echo "<td>" . $row['cQuotes'] . "</td>"; echo "</tr>"; } echo "</tbody></table>"; echo "</div></div>"; //************************** include 'close_config.php'; ?> </body> </html>

    Read the article

  • Generating JSON request manually, returned HTML causing issues.

    - by mrblah
    Hi, I am generating my JSON manually, and I even escaped for quotes with a preceding backslash. It is causing me problems. My HTML returned looks something like: <div class="blah"><div class="a2">This is just a test! I hope this work's man!</div></div> string json = "MY HTML HERE"; json = json.Replace(@"""", @"\"""); Is there more to replace than just the double quotes?

    Read the article

  • Sanitizing MySQL user parameters.

    - by Tom
    What are the dangerous characters that should be replaced in user input when the users' input will be inserted in a MySQL query? I know about quotes, double quotes, \r and \n. Are there others?(I don't have the option of using a smart connector that accepts parameters so I have to build the query myself and this will be implemented in multiple programming languages, including some obscure ones so solutions such as mysql_real_escape_string in PHP are not valid)

    Read the article

  • Creating directory?

    - by Vineet
    When iam creating directory using sytem as user create directory emp_dir1 AS "'C:\Documents and Settings\Administrator\Desktop\vin.txt"; vin.txt is my file it creates it. same when i do using user Scott it gives an error for path of file that "Identifier is too long" but when i put this file path in single quotes instead of double quotes for scott, it creates it. What is the reason behind?

    Read the article

  • How can I correctly quote query parameters using DBI?

    - by imerez
    I am dumping the a number of things including the following into a db INSERT statement \"$rec->{reqHdrs}\" However when for example my value for reqHdrs contains quotes it causes the statement to end and thus cause invalid sql. e.g. bla;bla="http://www.yahoo.com/xhtml",bla bla How do I escape the double quotes inside this statement ?

    Read the article

  • Assembly GDB Print String

    - by Ken
    So in assembly I declare the following String: Sample db "This is a sample string",0 In GDB I type "p Sample" (without quotes) and it spits out 0x73696854. I want the actual String to print out. So I tried "printf "%s", Sample" (again, without quotes) and it spits out "Cannot access memory at address 0x73696854." Short version: How do I print a string in GDB?

    Read the article

  • Help with SQL query in C#

    - by DanSogaard
    I'm trying to rename the columns. The syntax should be the column name between double quotes incase of two words, like this: SELECT p_Name "Product Name" from items So I'm trying to do it in C# code like this: string sqlqry1 = "SELECT p_Name \"Prodcut Name\" from items"; But I get an error: Syntax error (missing operator) in query expression 'p_Name "Prodcut Name"'. It seems am having somthing wrong with the quotes, but I can't figure out.

    Read the article

  • String literals C++?

    - by Bad Man
    I need to do the following C# code in C++ (if possible). I have to const a long string with lots of freaking quotes and other stuff in it. const String _literal = @"I can use "quotes" inside here";

    Read the article

  • Django admin default filter

    - by h3
    I know I already managed to do this but can't remember how nor I can't find any documentation about this.. How can apply a filter by default on a object list view in the admin ? I have an app which list quotes and those quotes have a status (ex: accepted, rejected, on hold ..). I want the filter set on status='accepted' by default that is..

    Read the article

  • How to search and replace an unprintable character

    - by krzyk
    I've a file that was exported from Word and it replaced all quotes with strange unicode characters which aren't correctly displayed in vim. So now I want those characters to be replaced with quotes, but I don't know how to enter this character in :%s/???/'/g The characters look like this: ~U ~R. But of course I can't just mark them with mouse and paste in the command.

    Read the article

  • IIS 6.0 Server and Unicode Characters

    - by Srikanth
    We are performing a pen test on a simple asp application that uses MS SQL Database. It seems for the authentication they are using dynamic constructed queries but escaping single qoutes. When we use Unicode quotes like %uFFO7,%u02b9 etc we are able to successfully inject SQL injections. Want to understand is it more a kind of configuration issue of IIS server to cannonicalize Unicode characters or the way the validation function to escape single quotes is written is the cause of the problem?

    Read the article

  • Ruby on Rails: create records for multiple models with one form and one submit

    - by notblakeshelton
    I have a 3 models: quote, customer, and item. Each quote has one customer and one item. I would like to create a new quote, a new customer, and a new item in their respective tables when I press the submit button. I have looked at other questions and railscasts and either they don't work for my situation or I don't know how to implement them. I also want my index page to be the page where I can create everything. quote.rb class Quote < ActiveRecord::Base attr_accessible :quote_number has_one :customer has_one :item end customer.rb class Customer < ActiveRecord::Base #unsure of what to put here #a customer can have multiple quotes, so would i use: has_many :quotes #<----? end item.rb class Item < ActiveRecord::Base #also unsure about this #each item can also be in multiple quotes quotes_controller.rb class QuotesController < ApplicationController def index @quote = Quote.new @customer = Customer.new @item = item.new end def create @quote = Quote.new(params[:quote]) @quote.save @customer = Customer.new(params[:customer]) @customer.save @item = Item.new(params[:item]) @item.save end end items_controller.rb class ItemsController < ApplicationController def index end def new @item = Item.new end def create @item = Item.new(params[:item]) @item.save end end customers_controller.rb class CustomersController < ApplicationController def index end def new @customer = Customer.new end def create @customer = Customer.new(params[:customer]) @customer.save end end quotes/index.html.erb <%= form_for @quote do |f| %> <%= f.fields_for @customer do |builder| %> <%= label_tag :firstname %> <%= builder.text_field :firstname %> <%= label_tag :lastname %> <%= builder.text_field :lastname %> <% end %> <%= f.fields_for @item do |builder| %> <%= label_tag :name %> <%= builder.text_field :name %> <%= label_tag :description %> <%= builder.text_field :description %> <% end %> <%= label_tag :quote_number %> <%= f.text_field :quote_number %> <%= f.submit %> <% end %> When I try submitting that I get an error: Can't mass-assign protected attributes: item, customer So to try and fix it I updated the attr_accessible in quote.rb to include :item, :customer but then I get this error: Item(#) expected, got ActiveSupport::HashWithIndifferentAccess(#) Any help would be greatly appreciated.

    Read the article

  • standard c library for escaping a string.

    - by rampion
    Is there a standard C library function to escape C-strings? For example, if I had the C string: char example[] = "first line\nsecond line: \"inner quotes\""; And I wanted to print "first line\nsecond line: \"inner quotes\"" Is there a library function that will do that transformation for me? Rolling my own just seems a little silly. Bonus points if I can give it a length to escape (so it stops before or beyond the \0).

    Read the article

  • How do I find everything between two characters after a word using grep, without outputting the entire line?

    - by Nick Sweeting
    I am downlading the info.0.json file from xkcd and trying to parse just the alt text. I don't care if there are quotes around it or not. The problem it that the info.0.json file is all one line, and the alt text is in quotes after the word "alt=". Trying cat info.0.json | grep alt just returns the whole file (because it's all one line). What is the grep or sed code that will get me the alt text?

    Read the article

  • Guest blog: A Closer Look at Oracle Price Analytics by Will Hutchinson

    - by Takin Babaei
    Overview:  Price Analytics helps companies understand how much of each sale goes into discounts, special terms, and allowances. This visibility lets sales management see the panoply of discounts and start seeing whether each discount drives desired behavior. In Price Analytics monitors parts of the quote-to-order process, tracking quotes, including the whole price waterfall and seeing which result in orders. The “price waterfall” shows all discounts between list price and “pocket price”. Pocket price is the final price the vendor puts in its pocket after all discounts are taken. The value proposition: Based on benchmarks from leading consultancies and companies I have talked to, where they have studied the effects of discounting and started enforcing what many of them call “discount discipline”, they find they can increase the pocket price by 0.8-3%. Yes, in today’s zero or negative inflation environment, one can, through better monitoring of discounts, collect what amounts to a price rise of a few percent. We are not talking about selling more product, merely about collecting a higher pocket price without decreasing quantities sold. Higher prices fall straight to the bottom line. The best reference I have ever found for understanding this phenomenon comes from an article from the September-October 1992 issue of Harvard Business Review called “Managing Price, Gaining Profit” by Michael Marn and Robert Rosiello of McKinsey & Co. They describe the outsized impact price management has on bottom line performance compared to selling more product or cutting variable or fixed costs. Price Analytics manages what Marn and Rosiello call “transaction pricing”, namely the prices of a given transaction, as opposed to what is on the price list or pricing according to the value received. They make the point that if the vendor does not manage the price waterfall, customers will, to the vendor’s detriment. It also discusses its findings that in companies it studied, there was no correlation between discount levels and any indication of customer value. I urge you to read this article. What Price Analytics does: Price analytics looks at quotes the company issues and tracks them until either the quote is accepted or rejected or it expires. There are prebuilt adapters for EBS and Siebel as well as a universal adapter. The target audience includes pricing analysts, product managers, sales managers, and VP’s of sales, marketing, finance, and sales operations. It tracks how effective discounts have been, the win rate on quotes, how well pricing policies have been followed, customer and product profitability, and customer performance against commitments. It has the concept of price waterfall, the deal lifecycle, and price segmentation built into the product. These help product and sales managers understand their pricing and its effectiveness on driving revenue and profit. They also help understand how terms are adhered to during negotiations. They also help people understand what segments exist and how well they are adhered to. To help your company increase its profits and revenues, I urge you to look at this product. If you have questions, please contact me. Will HutchinsonMaster Principal Sales Consultant – Analytics, Oracle Corp. Will Hutchinson has worked in the business intelligence and data warehousing for over 25 years. He started building data warehouses in 1986 at Metaphor, advancing to running Metaphor UK’s sales consulting area. He also worked in A.T. Kearney’s business intelligence practice for over four years, running projects and providing training to new consultants in the IT practice. He also worked at Informatica and then Siebel, before coming to Oracle with the Siebel acquisition. He became Master Principal Sales Consultant in 2009. He has worked on developing ROI and TCO models for business intelligence for over ten years. Mr. Hutchinson has a BS degree in Chemical Engineering from Princeton University and an MBA in Finance from the University of Chicago.

    Read the article

  • Common coding style for Python?

    - by Oscar Carballal
    Hi, I'm pretty new to Python, and I want to develop my first serious open source project. I want to ask what is the common coding style for python projects. I'll put also what I'm doing right now. 1.- What is the most widely used column width? (the eternal question) I'm currently sticking to 80 columns (and it's a pain!) 2.- What quotes to use? (I've seen everything and PEP 8 does not mention anything clear) I'm using single quotes for everything but docstrings, which use triple double quotes. 3.- Where do I put my imports? I'm putting them at file header in this order. import sys import -rest of python modules needed- import whatever import -rest of application modules- <code here> 4.- Can I use "import whatever.function as blah"? I saw some documents that disregard doing this. 5.- Tabs or spaces for indenting? Currently using 4 spaces tabs. 6.- Variable naming style? I'm using lowercase for everything but classes, which I put in camelCase. Anything you would recommend?

    Read the article

  • Administrator's shortcut to batch file with double quoted parameters

    - by XXB
    Take an excruciatingly simple batch file: echo hi pause Save that as test.bat. Now, make a shortcut to test.bat. The shortcut runs the batch file, which prints "hi" and then waits for a keypress as expected. Now, add some argument to the target of the shortcut. Now you have a shortcut to: %path%\test.bat some args The shortcut runs the batch file as before. Now, run the shortcut as administrator. (This is on Windows 7 by the way.) You can use either right-click - Run as Administrator, or go to the shortcut's properties and check the box in the advanced section. Tell UAC that it's okay and once again the shortcut runs the batch file as expected. Now, change the arguments in the target of the shortcut to add double quotes: %path%\test.bat "some args" Now try the shortcut as administrator. It doesn't work this time! A command window pops up and and disappears too fast to see any error. I tried adding test.log 2&1 to the shortcut, but no log is created in this case. Try running the same shortcut (with the double quotes) but not as Administrator. It runs the batch file fine. So, it seems the behavior is not because of the double quoted parameters, and it's not because it's run as Administrator. It's some weird combination of the two. I also tried running the same command from an administrator's command window. This ran the batch file as expected without error. Running the shortcut from the command window spawned a new command window which flashed and went away. So apparently the issue is caused by a combination of administrator, the shortcut, and the double quotes. I'm totally stumped, does anyone have any idea what's going on?

    Read the article

  • How can I return json from my WCF rest service (.NET 4), using Json.Net, without it being a string,

    - by Samuel Meacham
    The DataContractJsonSerializer is unable to handle many scenarios that Json.Net handles just fine when properly configured (specifically, cycles). A service method can either return a specific object type (in this case a DTO), in which case the DataContractJsonSerializer will be used, or I can have the method return a string, and do the serialization myself with Json.Net. The problem is that when I return a json string as opposed to an object, the json that is sent to the client is wrapped in quotes. Using DataContractJsonSerializer, returning a specific object type, the response is: {"Message":"Hello World"} Using Json.Net to return a json string, the response is: "{\"Message\":\"Hello World\"}" I do not want to have to eval() or JSON.parse() the result on the client, which is what I would have to do if the json comes back as a string, wrapped in quotes. I realize that the behavior is correct; it's just not what I want/need. I need the raw json; the behavior when the service method's return type is an object, not a string. So, how can I have my method return an object type, but not use the DataContractJsonSerializer? How can I tell it to use the Json.Net serializer instead? Or, is there someway to directly write to the response stream? So I can just return the raw json myself? Without the wrapping quotes? Here is my contrived example, for reference: [DataContract] public class SimpleMessage { [DataMember] public string Message { get; set; } } [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] public class PersonService { // uses DataContractJsonSerializer // returns {"Message":"Hello World"} [WebGet(UriTemplate = "helloObject")] public SimpleMessage SayHelloObject() { return new SimpleMessage("Hello World"); } // uses Json.Net serialization, to return a json string // returns "{\"Message\":\"Hello World\"}" [WebGet(UriTemplate = "helloString")] public string SayHelloString() { SimpleMessage message = new SimpleMessage() { Message = "Hello World" }; string json = JsonConvert.Serialize(message); return json; } // I need a mix of the two. Return an object type, but use the Json.Net serializer. }

    Read the article

  • Escape Quote in C# for javascript consumption

    - by Jason
    I have a ASP.Net web handler that returns results of a query in JSON format public static String dt2JSON(DataTable dt) { String s = "{\"rows\":["; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { s += "{"; for (int i = 0; i < dr.Table.Columns.Count; i++) { s += "\"" + dr.Table.Columns[i].ToString() + "\":\"" + dr[i].ToString() + "\","; } s = s.Remove(s.Length - 1, 1); s += "},"; } s = s.Remove(s.Length - 1, 1); } s += "]}"; return s; } The problem is that sometimes the data returned has quotes in it and I would need to javascript-escape these so that it can be properly created into a js object. I need a way to find quotes in my data (quotes aren't there every time) and place a "/" character in front of them. Example response text (wrong): {"rows":[{"id":"ABC123","length":"5""}, {"id":"DEF456","length":"1.35""}, {"id":"HIJ789","length":"36.25""}]} I would need to escape the " so my response should be: {"rows":[{"id":"ABC123","length":"5\""}, {"id":"DEF456","length":"1.35\""}, {"id":"HIJ789","length":"36.25\""}]} Also, I'm pretty new to C# (coding in general really) so if something else in my code looks silly let me know.

    Read the article

  • Textmate, open file at Caret

    - by amjags
    I bet this is really obvious but I can't find how to open the linked file that the Caret is currently on in Textmate. For example in the likes of Dreamweaver you can click in the index.html portion of <a href"index.html" hit cmd-D and it opens this file in a new tab. Is this possible? Would also be good to do this with <img src="image.jpg" to open the file directly into Photoshop. Solved! Solution for Patrick below. I used a modified version of Daustin777's example above to create a Command called OpenatCaret. The command is: open "$TM_PROJECT_DIRECTORY"/"$TM_SELECTED_TEXT" I then extended this by installing a macro which allowed you to select a path between double quotes but not including the quotes. I got this from the macromates board here. http://lists.macromates.com/textmate/2009-June/028965.html To wrap them both together I put my cursor in a path and recorded a new macro where I run the "Select within double quotes" macro and then the OpenatCaret command. I then named this OpenProjectFileAtCaret and bound this macro to cmd-D. Works a treat and is used all the time. Just make sure you have the correct default apps setup for each file type you are opening eg. Textmate for php, asp, html and it will open them in a new tab.

    Read the article

  • Replacing text with apostrophe text via sed in applescript

    - by bob stinton
    I have an applescript to find and replace a number of strings. I ran in the problem of having a replacement string which contained & some time ago, but could get around it by putting \& in the replacement property list. However an apostrophe seems to be far more annoying. Using a single apostrophe just gets ignored (replacement doesn't contain it), using \' gives a syntax error (Expected “"” but found unknown token.) and using \' gets ignored again. (You can keep doing that btw, even number gets ignored uneven gets syntax error) I tried replacing the apostrophe in the actual sed command with double quotes (sed "s…" instead of sed 's…'), which works in the command line, but gives a syntax error in the script (Expected end of line, etc. but found identifier.) The single quotes mess with the shell, the double quotes with applescript. I also tried '\'' as was suggested here and '"'"' from here. Basic script to get the type of errors: set findList to "Thats.nice" set replaceList to "That's nice" set fileName to "Thats.nice.whatever" set resultFile to do shell script "echo " & fileName & " | sed 's/" & findList & "/" & replaceList & " /'"

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >