Why are ` needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Why are ` needed

Post by Addos »

I’m unsure why the `250_champ` and `date` below uses ` instead of a quote. What is the reason for these? I appreciate that Dreamweaver is not everybody’s choice but I’m studying the code that this programme produces and although I generally see a lot of unnecessary extra written code been written not to say unsafe stuff too but I’m puzzled about why these little ` are used.
Many thanks
B
Sample

Code: Select all

$insertSQL = sprintf("INSERT INTO paypal (`date`, first_name, last_name, address, champ_no, support_no, `250_champ`, phone, mobile, email, ip) VALUES (CURDATE(), %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       //GetSQLValueString($_POST['date'], "text"),
                       GetSQLValueString("$f_name_message", "text"),
                       GetSQLValueString("$l_name_message", "text"),
                       GetSQLValueString("$address_message", "text"),
                       GetSQLValueString(isset($_POST['champ_no']) ? "true" : "", "defined","'Yes'","'No'"),
                       GetSQLValueString(isset($_POST['support_no']) ? "true" : "", "defined","'Yes'","'No'"),
                       GetSQLValueString(isset($_POST['0_champ']) ? "true" : "", "defined","'Yes'","'No'"),
                       GetSQLValueString($_POST['phone'], "text"),
                       GetSQLValueString($_POST['mobile'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['ip'], "text"));
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

The back ticks allow you to use words as column names that MySQL has reserved such as "Date" in this instance. I can't see why "250_champ" needs backticks though. Maybe it's because it starts with an integer.
Post Reply