473,785 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MySQL table names in PHP code

I'm learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:

$sql_command = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I'm not using
the right search terms.

While I'm asking, I think I've figured out how double quotes (")
differ from single quotes ('), but if there is a discussion that
someone can point me to, that would be very nice.

Thanks.
Jun 2 '08 #1
23 1599
MikeB wrote:
I'm learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:

$sql_command = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I'm not using
the right search terms.

While I'm asking, I think I've figured out how double quotes (")
differ from single quotes ('), but if there is a discussion that
someone can point me to, that would be very nice.

Thanks.
That's because it's a MySQL convention and has nothing to do with PHP.
Try the MySQL documentation.

SQL commands are just strings PHP passes to the database. From there
on, it's the databases responsibility.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 2 '08 #2
Jerry Stuckle wrote:
MikeB wrote:
>I'm learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:

$sql_command = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I'm not using
the right search terms.

While I'm asking, I think I've figured out how double quotes (")
differ from single quotes ('), but if there is a discussion that
someone can point me to, that would be very nice.

Thanks.

That's because it's a MySQL convention and has nothing to do with PHP.
Try the MySQL documentation.

SQL commands are just strings PHP passes to the database. From there
on, it's the databases responsibility.
They don't have to be escaped. They work fine without them.

$sql_command = "SELECT * from foo";

works.
Jun 2 '08 #3
MikeB wrote:
I'm learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:

$sql_command = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I'm not using
the right search terms.

While I'm asking, I think I've figured out how double quotes (")
differ from single quotes ('), but if there is a discussion that
someone can point me to, that would be very nice.

Thanks.
You might want to try following up in comp.databases. mysql.

--
Curtis
Jun 2 '08 #4
MikeB <MP*****@gmail. comwrote:
: I'm learning PHP and MySQL. In the samples I work with, the SQL table
: names are "escaped" in accent grave (`) marks, not in single or double
: quotes.

: Can anyone explain that?

: For instance, I have the following:

: $sql_command = "SELECT * from `7-1_List`";

I discovered backquotes when I inherited a MYSQL database that
had a table with a column named 'interval'. MYSQL refused to let
me reference that column: I couldn't select it, update it, remove
it. The good people here and at the MYSQL newsgroup told me that
I would need to add those backquotes because 'interval' is
otherwise recognized as a MYSQL datatype.

I would guess that the backquotes are hiding that '-' [minus?]
from MYSQL--I prefer to rename things that need such extra handling.
--thelma
Jun 2 '08 #5
MikeB wrote:
I'm learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:

$sql_command = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I'm not using
the right search terms.

While I'm asking, I think I've figured out how double quotes (")
differ from single quotes ('), but if there is a discussion that
someone can point me to, that would be very nice.
Re: quotes - http://us.php.net/types.string

--
*************** **************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Nothing he's got he really needs
Twenty first century schizoid man.
*************** *************** *****

Jun 2 '08 #6
sheldonlg <sheldonlgwrote :
>Jerry Stuckle wrote:
>MikeB wrote:
>>I'm learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:

$sql_comman d = "SELECT * from `7-1_List`";
...
That's because it's a MySQL convention and has nothing to do with PHP.
Try the MySQL documentation.

SQL commands are just strings PHP passes to the database. From there
on, it's the databases responsibility.

They don't have to be escaped. They work fine without them.

$sql_command = "SELECT * from foo";

works.
Of course it does, but "foo" is a very different name from "7-1_List". His
table name contains special characters that DO need to be escaped.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 2 '08 #7
sheldonlg a écrit :
They don't have to be escaped. They work fine without them.

$sql_command = "SELECT * from foo";

works.
Yeah but this escaping is here to use named fields/tables with a name
matching a MySQL reserved name.

I encountered it a lot with int and (previously) date, those indeed
being MySQL reserved types, but also a nice name for a date field and a
(RPG game based site) intelligence status (just like str, hp, vit...).

SELECT `int` FROM mytable
works whereas
SELECT int FROM mytable
tries to access the int type and fails.

Long ago (and as far as I remember), the same applied to date, referring
to the date() function.

Btw this is nowhere close to a PHP related issue ^^

Regards,
--
Guillaume
Jun 2 '08 #8
sheldonlg wrote:
Jerry Stuckle wrote:
>MikeB wrote:
>>I'm learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:

$sql_comman d = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I'm not using
the right search terms.

While I'm asking, I think I've figured out how double quotes (")
differ from single quotes ('), but if there is a discussion that
someone can point me to, that would be very nice.

Thanks.

That's because it's a MySQL convention and has nothing to do with PHP.
Try the MySQL documentation.

SQL commands are just strings PHP passes to the database. From there
on, it's the databases responsibility.

They don't have to be escaped. They work fine without them.

$sql_command = "SELECT * from foo";

works.
It depends - sometimes you do. But that's a question for
comp.databases. mysql, not comp.lang.php.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 2 '08 #9
Chuck Anderson wrote:
MikeB wrote:
>I'm learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:

$sql_command = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I'm not using
the right search terms.

While I'm asking, I think I've figured out how double quotes (")
differ from single quotes ('), but if there is a discussion that
someone can point me to, that would be very nice.

Re: quotes - http://us.php.net/types.string
Good try, but it has nothing to do with the user's question.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 2 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3556
by: jacob nikom | last post by:
I would like to create data model for a group of stores. All stores in this group are very similar to each other, so it is natural to allocate one MySQL database per store. Each database is going to have very similar set of tables with content related to a particular store. Let's suppose each store has multiple departments which are also very similar to each other. In this case I would like to model the departments
0
3948
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
1
538
by: David | last post by:
Hi, I currently administer our MySQL db version 3.23.56 on a Linux Cobalt Qube server via an external fron-end piece of software. My Table Names have capital letters at the beginning, i.e. StockMovements, OrderLines..... We are now implementing a cross-over to a Windows Server 2003 machine. I have installed MySQL version 4.0.20a and initially it was stated as 4.0.20a-debug. I managed to find another piece of software to take it
1
1595
by: Neil Zanella | last post by:
Hello, Consider the following PostgreSQL or Oracle SQL DDL code: CREATE TABLE fooTable ( foo INTEGER, PRIMARY KEY (foo) ); CREATE TABLE barTable (
39
8432
by: Mairhtin O'Feannag | last post by:
Hello, I have a client (customer) who asked the question : "Why would I buy and use UDB, when MySql is free?" I had to say I was stunned. I have no experience with MySql, so I was left sort of stammering and sputtering, and managed to pull out something I heard a couple of years back - that there was no real transaction safety in MySql. In flight transactions could be lost.
39
3234
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
6
38523
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get through this without much trouble. Programming knowledge is not required. Index What is SQL? Why MySQL? Installing MySQL. Using the MySQL command line interface
39
5870
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f ISO-8859-1 -t UTF-8 mydb.sql mydb_utf8.sql mysqlCREATE DATABASE mydb_utf8 CHARACTER SET utf8 COLLATE utf8_general_ci;
1
9586
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of things (stored procedures, functions).. we have to manually edit. That time, we face some interesting challenges.. I failed to document all of them, but whatever I can share with u.. I will try.. :) ...
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.