Jenny Dithe
12-08-2010, 08:25 AM
Hi,
I have a script that works fine for uploading an album but I want to add a reference number and I can't seem to do this. The reference number is generated from another page and sent to this page as part of a query string q=reference number.
I will just paste below the relevant parts of the script from the main page, it is all on one page, let me know if you do need the whole script to makes sense of it.
The code is as follows:
$ref=$HTTP_GET_VARS["q"];
//edited out
function save($data) {
if($sql="INSERT INTO photos (Id, ref, subcategory, photo, date)
VALUES ('".$_SESSION['Id']."', '".$data['ref']."', '".$data['photo']."', '".$data['filename']."', NOW())"){
echo "This is " . $sql . "<br />";
return true;
}
//edited out
if(move_uploaded_file($_FILES['file']["tmp_name"][$key], UPLOADS_DIR . $newFileName.$fileType)) {
if($this->createThumb(UPLOADS_DIR . $newFileName.$fileType, $fileType, THUMBS_DIR . $newFileName.$fileType, 200, 200)) {
$data['ref'] = $ref;
$data['photo'] = $key;
$data['filename'] = $newFileName.$fileType;
if($this->save($data)) {
$this->status = 'Photo #'.$key.' is uploaded and saved to the db<br />';
} else {
Now I have tried all variations:
$data['ref1'] = '.$ref.';
$data['ref2'] = "$ref";
$data['ref3'] = $ref;
$data['ref4'] = "{$ref}";
$data['ref5'] = ".$ref.";
I have even tried changing the insert command:
if($sql="INSERT INTO blogphotos (Id, ref, subcategory, photo, date)
VALUES ('".$_SESSION['Id']."', '".$ref."', '".$data['photo']."', '".$data['filename']."', NOW())"){
Nothing works. But if I echo $ref, it shows wonderfully.
I'm also not sure where I have gone wrong in my logic here?
I have a script that works fine for uploading an album but I want to add a reference number and I can't seem to do this. The reference number is generated from another page and sent to this page as part of a query string q=reference number.
I will just paste below the relevant parts of the script from the main page, it is all on one page, let me know if you do need the whole script to makes sense of it.
The code is as follows:
$ref=$HTTP_GET_VARS["q"];
//edited out
function save($data) {
if($sql="INSERT INTO photos (Id, ref, subcategory, photo, date)
VALUES ('".$_SESSION['Id']."', '".$data['ref']."', '".$data['photo']."', '".$data['filename']."', NOW())"){
echo "This is " . $sql . "<br />";
return true;
}
//edited out
if(move_uploaded_file($_FILES['file']["tmp_name"][$key], UPLOADS_DIR . $newFileName.$fileType)) {
if($this->createThumb(UPLOADS_DIR . $newFileName.$fileType, $fileType, THUMBS_DIR . $newFileName.$fileType, 200, 200)) {
$data['ref'] = $ref;
$data['photo'] = $key;
$data['filename'] = $newFileName.$fileType;
if($this->save($data)) {
$this->status = 'Photo #'.$key.' is uploaded and saved to the db<br />';
} else {
Now I have tried all variations:
$data['ref1'] = '.$ref.';
$data['ref2'] = "$ref";
$data['ref3'] = $ref;
$data['ref4'] = "{$ref}";
$data['ref5'] = ".$ref.";
I have even tried changing the insert command:
if($sql="INSERT INTO blogphotos (Id, ref, subcategory, photo, date)
VALUES ('".$_SESSION['Id']."', '".$ref."', '".$data['photo']."', '".$data['filename']."', NOW())"){
Nothing works. But if I echo $ref, it shows wonderfully.
I'm also not sure where I have gone wrong in my logic here?