I’m learning SQL using Wampserver, Crimson editor, and the New Boston tutorials. Nothing worked until I change quotation marks:
With SQL commands, regular ‘single quotes’ don’t work, but weird slanty quotes do.
When using forms and $_GET["name"]; only double quotes will work.
Any idea what is going on here? I use a British keyboard, but so does the video tutor, and he uses $_GET['name']; with single quotes.
EDIT: sample code:
if(isset($_GET["sortBy"])&&!empty($_GET["sortBy"]) ) // only works with "full" quotes
{ $sortBy = $_GET["sortBy"];
echo "sortBy works <br><br>";
}
$topTenResult = "SELECT `name`,`intuition`,`bravery`,`romance` FROM `scores` ORDER BY $sortBy DESC";
// does not work with default keyboard single quotes
In SQL, single quotes mark strings.
In MySQL, back quotes mark ‘delimited identifiers’. These are names that are case-sensitive or collide with keywords. The back quotes are unique to MySQL; MS SQL Server uses square brackets for the same job. Both are non-standard extensions.
In Standard SQL, double quotes are used to mark delimited identifiers. Some DBMS treat double quotes as marking strings unless put into a standard-compliant mode; some treat them as delimited identifiers automatically.