Is it $UPLOAD_DIR ........?
This is my whole code:
[PHP]<?php require_once('Connections/PhotoABC.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_Recordset1 = "-1";
if (isset($_SESSION['username'])) {
$colname_Recordset1 = $_SESSION['username'];
}
mysql_select_db($database_PhotoABC, $PhotoABC);
$query_Recordset1 = sprintf("SELECT user_id FROM `user` WHERE username = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $PhotoABC) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
//define constant for the maximum upload
define ('MAX_FILE_SIZE', 100000);
if (array_key_exists('upload', $_POST)) {
//define constant for upload folder
define('UPLOAD_DIR', 'C:\htdocs\PhotoABC\upload_test\\');
//replace any spaces with underscore
//also assign to simple variable
$file = str_replace(' ', '_', $_FILES['image']['name']);
//convert the max size to KB
$max = number_format(MAX_FILE_SIZE/1024,1).'KB';
//create variable of correct file typr
$correct = array('image/jpeg','image/pjpeg');
// begin by saying file is unacceptable
$sizeOK = false;
$typeOK = false;
//check file is correct size
if ($_FILES['image']['size'] > 0 && $_FILES['image']['size'] <=MAX_FILE_SIZE){
$sizeOK = true;
}
//check file is correct type
foreach ($correct as $type){
if($type == $_FILES['image']['type']){
$typeOK = true;
break;
}
}
if ($sizeOK && $typeOK){
switch($_FILES['image']['error']){
case 0:
//.$_SESSION['MM_Username']
if (!is_dir(UPLOAD_DIR.$_SESSION['MM_Username'])){
mkdir(UPLOAD_DIR.$_SESSION['MM_Username']);
}
//move file to the upload folder and rename it
//get date and time
ini_set('date.timezone', 'Europe/Dublin');
$now = date('Y-m-is-');
$success = move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR.$_SESSION[ 'MM_Username'].'/'.$now.$_SESSION['MM_Username'].'-'.$file);
//copy image to database ????
INSERT INTO gallery (user_id, image_name)
VALUES ($RecordsetUserID,
UPLOAD_DIR.$_SESSION['MM_Username'].'/'.$now.$_SESSION['MM_Username'].'-'.$file);
if ($success){
$result= "$file uploaded successfully";
}
break;
}
}
elseif ($_FILES['image']['error'] == 4){
$result = 'No file selected';
}
else {
$result = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: jpg";
}
}
mysql_free_result($Recordset1);
?>
[/PHP]
Maybe i am not using the SQL correctly for the insert query?