473,322 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

difference between " quotes and '' quotes

please define me what is the main difference between double quotes and single quotes ?

Expand|Select|Wrap|Line Numbers
  1. $ans=20;
  2.  
  3. echo "$ans";
  4. output 20
  5.  
  6. echo '$ans';
  7. output $ans;
  8.  
  9. if we can type
  10.  
  11.  
  12. function update_query($filename,$data,$where)
  13.     {
  14.         $sql= "UPDATE ".$filename." SET ";        
  15.         foreach ($data as $key=>$value)
  16.         {
  17.             $sql.=$key."='$value'";             
  18.         }
  19.  
  20.         $sql = $sql." WHERE ".$where;
  21.         echo " ".$sql."<br>"; die;
  22.         return $res = $this->query($sql);  
  23.     }

please define me that line

Expand|Select|Wrap|Line Numbers
  1. $sql.=$key."='$value'";
why we put "''" value in quotes .

because "" is used for print the value

and single quotes print the variable

but why used here single quotes for print the value and how print the value

That function is running condition.
Feb 8 '12 #1
2 1555
Rabbit
12,516 Expert Mod 8TB
Single quotes don't print variables. Double quotes will expand variables. Hence the reason the string is surrounded by double quotes. The single quotes are for the benefit of the SQL engine. SQL requires strings to be surrounded by single quotes, which is why those single quotes surround the value.
Feb 8 '12 #2
Dormilich
8,658 Expert Mod 8TB
you'll find an in-depth explanation in the manual.
Feb 9 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jakanapes | last post by:
Hi all, I'm looking for a way to scan a block of text and replace all the double quotes (") with single quotes ('). I'm using PHP to pull text out of a mySQL table and then feed the text into...
21
by: b83503104 | last post by:
Hi, Can someone tell me the difference between single quote and double quote? Thanks
11
by: Ron | last post by:
Hello, I'm having an aggravating time getting the "html" spewed by Word 2003 to display correctly in a webpage. The situation here is that the people creating the documents only know Word, and...
3
by: Fei Li | last post by:
Hi, take string class as an example, who can explain the difference? Thanks
6
by: John Pass | last post by:
What is the difference between a While and Do While/Loop repetition structure. If they is no difference (as it seems) why do both exist?
3
by: red floyd | last post by:
I've got some code where somebody cut&pasted some comments from MS Word, and so these comments have "smart quotes" (in particular apostrophes) embedded. The apostrophe is character hex 0x92. ...
3
by: joboils | last post by:
I've inherited a huge, rambling site with numerous lines containing $_SERVER php.net says it should be single inverted commas, not double, yet everything seems to work. As it would be a...
3
by: Baron Samedi | last post by:
I am looking for a reliable cross-browser pull-quote solution in CSS. See for instance, http://www.sitepoint.com/examples/pullquotes/ The problem seems at first to be sure that it functions...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.