im getting this error when trying to add data to an MS Access db
Fatal error: Cannot instantiate non-existent class: com in /home/reallygo/public_html/test_interfaces/insert.php on line 8
website
http://www.reallygoodco.com/test_interfaces/default.htm
works fine on my Win2K box
http://yrag.kicks-ass.org/senior_project/default.htm (not always on)
dont no why im getting this error
ive looked in some forums possibilities is that wrong permissions on server to write to database? the server is running Appache
php settings http://www.reallygoodco.com/test_interfaces/test.php
dont blast me about dupilcating soo much code and not using functions, it works OK (on my windows box anyway)
am i doing anything wrong i am much more used to ASP and the windows world but want to learn more. this is an important project for my Dad, thought i was going to write in ASP then found i could only use php, only started learning sunday (steep learning curve)
any help most appreciated!!
code
<?php
ob_start();
$nextpage = $POST['nextpage'];
$page = $POST['page'];
$vote = $_POST['vote'];
if (!$conn = new COM("ADODB.Connection"))
{
print "Unable to create an ADODB connection<br>";
exit;
}
$strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("snp_db/snp_db.mdb");
$conn->open($strConn);
$strSQL = "SELECT * FROM vote WHERE page = '".$page."'";
$rs = $conn->execute($strSQL);
if ($rs->BOF AND $rs->EOF)
{
if ($vote == "1")
{
$strSQL = "INSERT INTO vote(page, one) VALUES ('".$page."' ,1)";
$conn->execute($strSQL);
$conn->Close();
$conn = null;
}
else if ($vote == "2")
{
$strSQL = "INSERT INTO vote(page, two) VALUES ('".$page."' ,1)";
$conn->execute($strSQL);
$conn->Close();
$conn = null;
}
else if ($vote == "3")
{
$strSQL = "INSERT INTO vote(page, three) VALUES ('".$page."' ,1)";
$conn->execute($strSQL);
$conn->Close();
$conn = null;
}
else if ($vote == "4")
{
$strSQL = "INSERT INTO vote(page, four) VALUES ('".$page."' ,1)";
$conn->execute($strSQL);
$conn->Close();
$conn = null;
}
else if ($vote == "5")
{
$strSQL = "INSERT INTO vote(page, five) VALUES ('".$page."' ,1)";
$conn->execute($strSQL);
$conn->Close();
$conn = null;
}
}
else
{
if ($vote == "1")
{
$strSQL = "SELECT vote.one FROM vote WHERE page = '".$page."'";
$rs1 = $conn->execute($strSQL);
$one = $rs1->Fields(one);
$newvalue = $one->value + 1;
$strSQL = "UPDATE vote SET [one] = ".$newvalue." WHERE vote.page = '".$page."'";
$conn->execute($strSQL);
$rs1->Close();
$rs1 = null;
$conn->Close();
$conn = null;
}
elseif ($vote == "2")
{
$strSQL = "SELECT vote.two FROM vote WHERE page = '".$page."'";
$rs1 = $conn->execute($strSQL);
$two = $rs1->Fields(two);
$newvalue = $two->value + 1;
$strSQL = "UPDATE vote SET [two] = ".$newvalue." WHERE vote.page = '".$page."'";
$conn->execute($strSQL);
$rs1->Close();
$rs1 = null;
$conn->Close();
$conn = null;
}
elseif ($vote == "3")
{
$strSQL = "SELECT vote.three FROM vote WHERE page = '".$page."'";
$rs1 = $conn->execute($strSQL);
$three = $rs1->Fields(three);
$newvalue = $three->value + 1;
$strSQL = "UPDATE vote SET [three] = ".$newvalue." WHERE vote.page = '".$page."'";
$conn->execute($strSQL);
$rs1->Close();
$rs1 = null;
$conn->Close();
$conn = null;
}
elseif ($vote == "4")
{
$strSQL = "SELECT vote.four FROM vote WHERE page = '".$page."'";
$rs1 = $conn->execute($strSQL);
$four = $rs1->Fields(four);
$newvalue = $four->value + 1;
$strSQL = "UPDATE vote SET [four] = ".$newvalue." WHERE vote.page = '".$page."'";
$conn->execute($strSQL);
$rs1->Close();
$rs1 = null;
$conn->Close();
$conn = null;
}
elseif ($vote == "5")
{
$strSQL = "SELECT vote.five FROM vote WHERE page = '".$page."'";
$rs1 = $conn->execute($strSQL);
$five = $rs1->Fields(five);
$newvalue = $five->value + 1;
$strSQL = "UPDATE vote SET [five] = ".$newvalue." WHERE vote.page = '".$page."'";
$conn->execute($strSQL);
$rs1->Close();
$rs1 = null;
$conn->Close();
$conn = null;
}
}
$thisServer = $_SERVER['HTTP_HOST'];
header("Location: [url]http://[/url]$thisServer/senior_project/$nextpage");
?>
😕 😕 😕