Okay, been plugging away at this for a while........
<?php
$sUserName = $_POST['username'];
$sUserEmail = $_POST['useremail'];
$sUserDesc = $_POST['userdesc'];
$nID = $_POST['ID'];
$imageinfo = getimagesize($_FILES['userfile']['tmp_name']);
$blacklist = array(".php", ".phtml", ".htm", ".zip", ".exe", ".asp", ".aspx", ".xml");
foreach ($blacklist as $item) {
if(preg_match("/$item\$/i", $_FILES['userfile']['name'])) {
echo "We do not allow uploading PHP files or executable scripts\n";
exit;
}
}
$uploaddir = 'images/grid/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
$sUserFile = ($_FILES['userfile']['name']);
echo "<br>";
echo $nID;
echo "<br><Br><Br>";
echo $sUserFile;
echo "<br><br>";
//=====================================//
// Database Section
//=====================================//
// creates a new Common-Object-Model (COM) connection object
$adoCon = new COM("ADODB.Connection");
// the path to the folder holding this PHP script
$sHere = dirname(__FILE__);
// opens the connection using a standard Access2007 connection string
$adoCon-> Open("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=$sHere/dbase/test1.accdb");
$sSQL = "UPDATE tbltest SET Descripton=$sUserDesc, URL=$sUserFile, UploadedBy=$sUserName, Email=$sUserEmail WHERE id=$nID;";
echo $sSQL;
echo "<br>";
$adoCon->Execute($sSQL);
} else {
echo "File uploading failed.\n";
}
?>
Everything is working fine, except for the query.
I've echoed the quesry string and it gives the following....
UPDATE tbltest SET Descripton=wdad, URL=004.jpg, UploadedBy=ee, Email=ssdaa WHERE id=4;
Which is exactly what needs to go across to the database.
But something is stopping it from being transferred.....and I get this error.
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Office Access Database Engine<br/><b>Description:</b> Syntax error (missing operator) in query expression '004.jpg'.' in C:\Program Files\EasyPHP 2.0b1\www\magpie3\upload.php:48 Stack trace: #0 C:\Program Files\EasyPHP 2.0b1\www\magpie3\upload.php(48): com->Execute('UPDATE tbltest ...') #1 {main} thrown in C:\Program Files\EasyPHP 2.0b1\www\magpie3\upload.php on line 48
I'm pretty sure it's something to do with the query, but can't figure out where I'm going wrong.
I know I can connect to the database and modify it as I've tried a 'delete row' query with success.
Thanks
TheMightySpud