Guys this is a code i have written. I have two files.
File one.
$regname=$_POST['name']; -----> here the variable passed is john suppose..
$sponserid=$_POST['sname'];
$regemail=$_POST['email'];
$regmobile=$_POST['mobile'];
include 'dbcon.php';
$obj = new dbcon;
$obj->createUser($regname,$sponserid,$regemail,$regmobile);
echo $obj;
in the above code i am getting variables from a form a and storing them. Then I instantiate an object and pass all those to a method.
My class code id like this.
class dbcon
{
public function __construct() //This is the connection construct.
{
$server = "localhost";
$user = "eplu";
$pass = "123456"; //Change on hosting server
$db = "epl";
mysql_connect($server, $user, $pass) or die("Error connecting to sql server: ".mysql_error());
mysql_select_db($db);
}
public function createUser($regname,$sponserid,$regemail,$regmobile){
$sql = "INSERT INTO onlinereg (names,sid,emails,mobiles) VALUES (`$regname`,`$sponserid`,`$regemail`,`$regmobile`)";
mysql_query($sql) or die(mysql_error());
return "Registration Success";
}
}
I get an error like Unknown column 'john' in 'field list'. New to OOPS pls help...Thnx in advance.....