I'm a VB.NET programmer, but trying to get into PHP to broaden my knowledge. I'm doing a simple registration / login site just to get my hands on it.
The issue I am having is the registration is not completing. I have a feeling it is the way I am connecting to the database but can't seem to figure out where my error is.
Here is what I have.
register.php
$sql = "INSERT INTO users (Username, Password, Email, FullName) VALUES ($username, $password, $email, $name)";
$this->dbConnect('login') or die("Could not connect to server.");
$this->dbQuery($sql) or die("Could not query the database.");
$this->dbClose();
functions.php:
<?php
include('constants.php');
class database
{
// Each time this class is called, it will connect to the database
function __construct()
{
$this->dbConnect();
}
// Creates a connection to the database
function dbConnect($dbname)
{
$this->$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("Could not connect to server.");
$this->$dbselect = mysql_select_db($dbname, $conn) or die("Could not connect to the database.");
}
// Closes database connection if a connection is currently set
function dbClose()
{
if(isset($this->$conn))
{
mysql_close($this->$conn);
}
}
// Query's the databases
function dbQuery($sql)
{
$result = mysql_query($sql);
return $result;
}
function dbNumRows($result)
{
$rows = mysql_num_rows($result);
return $rows;
}
}
?>
^^ $dbhost, $dbuser, $dbpass all come out of the constants.php file
constants.php:
<?php
define($dbhost, 'localhost');
define($dbuser, 'root');
define($dbpass, '');
?>
Anyone able to point me in the direction of my error?