I am working in PHP, I have to define variables in sequence to save in Mysql. Both field name and variable name must be same in my case.
Can I declare a variable like this
$1 OR $2 etc
If not why not and if yes why yes?
I tried:
$id = 0;
$6 = $_REQUEST['6'];
$7 = $_REQUEST['7'];
$8 = $_REQUEST['8'];
$xary = array('6','7','8','9')
$oAppl->save_record("tablename", $id, "id");
which give me error.
Also can I create and use fields in Mysql with the same name?
This is how PHP was designed. You can't start a variable name with a number.
What you can do is use underscore:
$_6 = $_REQUEST['6'];
EDIT: since variables start with $ in PHP, is would be possible to have variables starting with numbers, but that would be a bit confusing to most people since there is no other language that allows variables starting with numbers (or at least I don't know any).
But let's imagine variables starting with numbers are allowed.
Can you imagine a coworker saying to you: 23 equals 74? That is a bit confusing. Hearing n23 equals 74 makes more sense. You know n23 is a variable without having to explicitly say that.