I have been creating registration form using php.
And my database and table look like this:
This is the database connection query:
<?PHP
require_once("./include/fg_membersite.php");
$fgmembersite = new FGMembersite();
//Provide your site name here
//Provide the email address where you want to get notifications
$fgmembersite->SetAdminEmail('rajaselva.csc@gmail.com');
//Provide your database login details here:
//hostname, user name, password, database name and table name
//note that the script will create the table (for example, fgusers in this case)
//by itself on submitting register.php for the first time
$fgmembersite->InitDB(/*hostname*/'localhost',
/*username*/'root',
/*password*/'',
/*database name*/'employee',
/*table name*/'employee-reg');
//For better security. Get a random string from this link: http://tinyurl.com/randstr
// and put it here
$fgmembersite->SetRandomKey('qSRcVS6DrTzrPvr');
?>
After entering the input details, it shows like this,
May I know, what is my mistake, how can I fix this.
Can anybody help me? thanks in advance.
Add back tick (``) on the employee-reg table name. Hope that will work
$fgmembersite->InitDB(/*hostname*/'localhost',
/*username*/'root',
/*password*/'',
/*database name*/'employee',
/*table name*/'`employee-reg`');
Problem is with your table name you should not user minus(-) sign in your table name. If you really need to use it then enclose it with back-ticks (`). See the Example Below:
CREATE TABLE `employee-reg` (id int, name varchar( 255 )); //Works Well
CREATE TABLE employee-reg (id int, name varchar( 255 )); //Will Not Work and gives error
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-reg (id int, name varchar( 255 ))' at line 1
Quite Similar to your error. So either remove minus(-) sign or use back-ticks(`).