Since this morning i'm working on a applcation that send sms through the net.I'm using ajax with php for the validation.
If the data is submitted and there is no error it should direct to a page.that page script inserts the data in the database. for that i've set a class that provide all the functions for that.Now the problem is any time i run it i see this:
i'ved change things and up to now nothing and i bet you it's king of frustrating.I'm using XAMPP 1.5.5 and pdo extensions are enabledUnexpected error occuredSQLSTATE[28000] [1045] Access denied for user 'ODBC'@'localhost' (using password: NO)
Fatal error: Call to a member function prepare() on a non-object in C:\Program Files\xampp\htdocs\servDTxtBuddy\handler.class.php on line 31
here is the page
Code: Select all
[
<?php
session_start();
include_once('config.php');
include_once("handler.class.php");
$handler = new handler();
$handler->insertData();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Wlecome to Authentication page</title>
</head>
<body>
<h1>Authentication</h1>
</body>
</html>
Code: Select all
<?php
//include_once("config.php");
class handler
{
private $txtID = 0;
function dbconnect()
{
echo $db_user;
$dsn = "mysql:dbname=$db_database;host=$db_hostname";
try
{
$pdo = new PDO($dsn, $db_user, $db_password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $pdo;
}
catch(Exception $e)
{
echo "Unexpected error occured" . $e->getMessage();
}
}
//insert data when the iwalletsettings page is called
function insertData()
{
$txtID++;
$db = $this->dbconnect();
$sql = "insert txtbuddydetails textId ,senderId, recipientNumber, txtMessage values(:txtID, :sendID, :reNumber, :txtSMS)";
try
{
$_SESSION['ID'] = $txtID;
$stmt = $db->prepare($sql);
$stmt->binParam(':txtID', $txtID );
$stmt->binParam(':sendID', $_SESSION['text']['txtMessage'] = $_POST['txtMessage']);
$stmt->binParam(':reNumber', $_SESSION['text']['txtNumber'] = $_POST['txtNumber']);
$stmt->binParam(':txtSMS', $_SESSION['text']['txtMessage'] = $_POST['txtMessage']);
$stmt->execute();
}
catch(Excetion $e)
{
echo ("Unexpected error Occured" . $e.getMessage());
}
}
function updateStatus($sendStatus)
{
$dbUpdate = $this->dbconnect();
//$sendStatus is the response from the SMS Gateway API
if($sendStatus == 1)
{
try
{
$sqlstatus = "update txtbuddydetails set status = 1 where textId= :uID ";
$stmtupdate = $dbUpdate->prepare($sqlstatus);
$stmtupdate->bindParam(":tID", $_SESSION['ID']);
$stmtupdate->execute();
}
catch(Exception $e)
{
echo ("Unexpected error Occured" . $e.getMessage());
}
}
else
{
try
{
$sqlstatus = "update txtbuddydetails set status = 2 where textId= :uID ";
$stmtupdate = $dbUpdate->prepare($sqlstatus);
$stmtupdate->bindParam(":uID", $_SESSION['ID']);
$stmtupdate->execute();
}
catch(Exception $e)
{
echo ("Unexpected error Occured" . $e.getMessage());
}
}
}
function removeInvalidTransaction()
{
try{
$dbRemove = $this->dbconnect();
$sqlstatus = "update txtbuddydetails set status = 2 where textId= :reID ";
$stmtremove = $dbRemove->prepare($sqlstatus);
$stmtremove->bindParam(":reID", $_SESSION['ID']);
$stmtremove->execute();
$_SESSION['ID'] = " ";
$txtID--;
}
catch(Exception $e)
{
echo ("Unexpected error Occured" . $e.getMessage());
}
}
function retrieveData()
{
try
{
$dbretrieve = $this->dbconnect();
$sqlretrieve = "select senderId, recipientNumber, txtmessage from txtbuddydetails where textId = :rID";
$stmtretrieve = $dbretrieve->prepare($sqlretrieve);
$stmtretrieve->bindParam(":rID",$_SESSION['ID']);
$stmtretrieve->execute();
$data = $stmtretrieve->fetch(PDO::FETCH_ASSOC);
}
catch(Exception $e)
{
echo ("Unexpected error Occured" . $e.getMessage());
}
}
}
?>