Hey, when you are doing a mysql_query() and such which of the following examples is better:
їcode]mysql_query("select name from names");ї/code]
їcode]mysql_query("select name from 'names'");ї/code]
db queries & single quotes?
Moderator: General Moderators
- devork
- Forum Contributor
- Posts: 213
- Joined: Fri Aug 08, 2003 6:44 am
- Location: p(h) developer's network
Code: Select all
mysql_query("select name from 'names'");-
jollyjumper
- Forum Contributor
- Posts: 107
- Joined: Sat Jan 25, 2003 11:03 am
Code: Select all
select * from 'tablename'Code: Select all
select * from tablenameGreetz Jolly.
-
DaMastaBugz
- Forum Newbie
- Posts: 2
- Joined: Tue Aug 19, 2003 9:21 am
- Location: Sao Paulo
I think this is kind of a personal issue.
I know people who prefer to use single quotes and people who just hate that. I fall into the second group.
In cases where you name your tables "my table" (not the space in the name) the single quotes are a must, but if you are a reasonable bloke, you'd never name your tables with special characters and spaces to start off.
Hope this helps
I know people who prefer to use single quotes and people who just hate that. I fall into the second group.
In cases where you name your tables "my table" (not the space in the name) the single quotes are a must, but if you are a reasonable bloke, you'd never name your tables with special characters and spaces to start off.
Hope this helps
I am not aware of that using single or double quotes make a difference in MySQL.
However they make a huge, but very subtle difference in PHP. Everything between double-quotes will be get parsed, i.e. searched for variables which will get replaced with their value.
Everything between single-quotes is taken as text.
Example:
Depending on how much text there is between the double-quotes, this parsing slows the output down. Hence, most people use single quotes.
However they make a huge, but very subtle difference in PHP. Everything between double-quotes will be get parsed, i.e. searched for variables which will get replaced with their value.
Everything between single-quotes is taken as text.
Example:
Code: Select all
$var='cookie';
echo "my $var is different";
echo 'my $var is different';