...

View Full Version : Why record is not inserted in the DB



qaiser_nazir
12-23-2010, 05:20 PM
Dears
I am new to OOP Php. for now i am entangled at very initial level i.e. data insertion into db. I simply passed the insert query to a variable in simple php file, which i further get in class function executeQuery(). Although, on echoing $query variable shows right output yet, i cannot find out why data is not going to database. The class code is as under:



<?php
class DBCon
{
var $con;
function getCon()
{
$hostname = 'localhost';
$dbuser = 'root';
$dbpassword = '';

$con=mysql_connect($hostname,$dbuser,$dbpassword);
if(!$con)
{
die('cannot connect db'.mysql_error());
}
mysql_select_db("studyco",$con);
return $con;
}

//Queries
function executeQuery($query)
{
if($query!= null)
{
mysql_query($query);
echo 'record added'.$query;
}
else
{
echo 'not added';
}
}
function destruct()
{
mysql_close();
}
}
?>


i would be extremely obliged for anyone's help in this regard.

Thanks
Qaiser

MattF
12-23-2010, 05:30 PM
if($query!= null)
{
mysql_query($query) or exit(mysql_error());
echo 'record added'.$query;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum