DB_HOST Connection problem?
Posted: Tue Sep 25, 2007 5:30 am
I keep getting this error from my code when im trying to execute my script.
Thanks
CONFIG.PHP
TOOLS.CLASS.PHP
REGISTER.PHP
I'm unsure what the problem is? Any advice or hints?ERRNO:, 8 TEXT : Use of undefined constant DB_HOST - assumed 'DB_HOST' LOCATION: /home/sites/waphoo.net/public_html/classes/tools.class.php, line 14
Thanks
CONFIG.PHP
Code: Select all
<?
//define database connection values
define("DB_HOST", 'localhost');
define("DB_USER", '*****');
define("DB_PASSWORD", '******');
define("DB_DATABASE", '******');
?>Code: Select all
<?php
require_once('config.php');
class Tools
{
private $mMysqli;
//constructor opens database connection
function __construct() {
$this->mMysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
}
//destructor closes database connection
function __destruct() {
$this->mMysqli->close();
}
/*
* Function registers users values into database and sends off
* an email to both the user and Core Telecom
*/
public function register($name, $house_number, $street, $town, $city, $postcode, $country, $telephone, $mobile, $email)
{
$query = $this->mMysqli->query("INSERT into requests VALUES (NULL,'$telephone', '$mobile' , '$email' , 'NULL', '$name','$house_number' , '$street', '$town', '$city', '$postcode', '$country')");
$this->sendCoreEmail($email, $name);
$this->sendUserEmail($email, $name);
//return 'www.waphoo.net';
}
private function sendCoreEmail($email, $name)
{
$sender = 'Waphoo';
$time_of_enquiry = date('r');
$recipient = 'martinsandhu@gmail.com';
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Mailer: php\n";
$headers .= 'From: Waphoo <'.$sender.'>';
$subject = "Waphoo - New Number Request";
$mail = '
A new user has requested for a number to be mapped at waphoo.
Name: '.$name.'
Email: '.$email.'
To view information and send this user a number. Login to the Waphoo Control Panel.
http://www.waphoo.net/admin/
Regards,
Waphoo
';
$result = mail($recipient, $subject, $mail, $headers);
}
private function sendUserEmail($email, $name)
{
$sender = 'Waphoo';
$time_of_enquiry = date('r');
$recipient = $email;
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Mailer: php\n";
$headers .= 'From: Waphoo <'.$sender.'>';
$subject = "Waphoo - Your New Number Request";
$mail = '
Hello '.$name.'
Thanks for requesting your own personal international follow me telephone number.
A member of our team will be in touch within the next 24 hours to guide you through the setup and your number.
Regards,
Waphoo
';
$result = mail($recipient, $subject, $mail, $headers);
}
}
?>Code: Select all
<?php
require_once('classes/tools.class.php');
require_once('classes/error_handler.php');
$name = $_POST['name'];
$house_number = $_POST['house_number'];
$street = $_POST['street'];
$town = $_POST['town'];
$mobile = $_POST['mobile'];
$city = $_POST['city'];
$country = $_POST['country'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
$postcode = $_POST['postcode'];
$tools = new Tools();
$tools->register($name, $house_number, $street, $town, $city, $postcode, $country, $telephone, $mobile, $email);
?>