Jump to content

Hey gain got another problem for you. lol


fixxxer

Recommended Posts

hey again everybody,

first of all thanks to the people who helped me out last time, with my $_REQUEST problem. i contacted the people who wrote the book and told them they were idiots.

this ones been bugging me for five hours now and i cant get it work. ill start by showing you the code

[code]
<?php
session_start();

if (isset($_REQUEST['action'])) {

$action = $_REQUEST['action'];



if ($action = 'Submit and Add Screenshots' || 'Submit and Go To Review') {

//make variables available
$cover_caption = $_POST['image_caption'];
$cover_id = $_POST['cover_id'];
$cover_user_id = $_POST['cover_user_id'];
$cover_game_id = $_POST['cover_game_id'];
$cover_format_id = $_POST['cover_format_id'];
$cover_tempname = $_FILES['image_filname']['name'];
$today = date("Y-m-d");



//upload image and check for image type
$ImageDir = "gamesdb2/images/covers/";
$ImageName = SImageDir . $cover_tempname;

if (move_uploaded_file($_FILES['image_filename']['tmp_name'],$ImageName)) {

echo $today;
    //get info about image being uploaded
    list($width, $height, $type, $attr) = getimagesize($ImageName);
    
    switch ($type) {
    
    case 1:
    $ext = ".gif";
    break;
    
    case 2:
    $ext = ".jpg";
    break;
    
    case 3:
    $ext = ".png";
    break;
    default:
        
    echo "Sorry, but the file you uploaded was not a GIF, JPG or PNG file.<br>";
    echo "Please hit your browsers 'back' button and try again.";
    
     }
    
    //image is acceptable; proceed to next step
    echo $ext;
    $newfilename = $ImageDir . $cover_id . $ext;
    rename($ImageName, $newfilename);
    
    $update = "UPDATE game_format_cover " .
                "SET cover_user_id='$cover_user_id',
                cover_caption='$cover_caption',
                cover_image_location='$newfilename',
                cover_uploaded='$date'" .
                "WHERE cover_id ='$cover_id'";
    $updatetable = mysql_query($update)
        or die(mysql_error());
        
        
                
    } else {
    
    echo 'action not set';
    
    }


} else {

echo 'unable to upload photo';
}
}
?>
[/code]
the idea for the code is to upload a graphic amend its name and then insert its address into the sql database. Im aware that the sql syntax is probs wrong and i can sort that out myself, dont wont to bother you all with that problem.

my problem is that when i run the script the first part executes fine the variables are all set (i test it by echoing them to see how far it gets, the problem appears to occur here :-

if (move_uploaded_file($_FILES['image_filename']['tmp_name'],$ImageName)) {

to check whether the if statement was working i echoed the date variable and no matter what i change i always get the same output of 'action not set'
this has led me to think the above statement is wrong in some way. also i started fiddling with the curly brackets and now i mucked it up as well. cos if thats where the error i would have expected to get a blank page, think i mucked the curlies up.

so rather than beat my girlfriend up cos im a failure (joking, though sometimes i wish i could. (lol)) i was hoping someone could point in the direction im going wrong, dont need anyone to solve it, cos otherwise ill never learn, just an idea of whats not working.

if its something really easy feel free to tell me im an idiot, ur probably right

thanks
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.