Jump to content


Photo

Hey gain got another problem for you. lol


  • Please log in to reply
1 reply to this topic

#1 fixxxer

fixxxer
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 26 May 2006 - 06:33 PM

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

<?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';
}
}
?>
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

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 27 May 2006 - 01:27 PM

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

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users