Jump to content

Recommended Posts

Can someone help me. trying to say update details where admin_id equals the admin_id in the session.

 

//Store the filename, path other criteria in the database 
	$query = "UPDATE admin(avatar_name, avatar_path)
	VALUES('$filename', '$filepath')
	WHERE admin_id = $_SESSION['admin_id']";

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/201159-syntax-on-where/
Share on other sites

Than you, it doesnt error out now so thats a start but i wont update the db it just gets an error, i looked and my update is incorrect it should be this

 

$query = "UPDATE admin SET avatar_name='$filename', avatar_path='$filepath'

WHERE admin_id = {$_SESSION['name']}";

 

but i still get

Unable to add the avatar details to the database

 

Which is related to this code, can you see what i am doing wrong

 

<?php

include "securitycheck.php";

include("includes/connection.php");



    // Where the file is going to be placed 
    $avatarimage = "avatarImages/";

//This path will be stored in the database as it does not contain the filename
$currentdir = getcwd();
$path = $currentdir . '/' . $avatarimage;



//Use this path to store the path of the file in the database.
echo $filepath = $avatarimage;


//Create the folder if it does not already exist
if(!file_exists('avatarimages'))
    {
        if(mkdir('avatarimages'))
        {
            echo 'Folder ' . 'avatarImages' . ' created.';
        }
        else
        {
            echo 'Error creating folder ' . 'avatarImages';
        }
    }


//Store the folder for the course title.
    if(!file_exists( $filepath ))
    {
        if(mkdir( $filepath ))
        {
            echo 'Folder ' .  $avatarimage . ' created.';
        }
        else
        {
            echo 'Error creating folder ' .  $avatarimage;
        }
    }


// Where the file is going to be placed 
    $target_path = $filepath;

    // Add the original filename to our target path. Result is "uploads/filename.extension"
    $target_path = $target_path . '/' . basename( $_FILES['uploadedfile']['name']); 


if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) 
{
	echo "The file ".  basename( $_FILES['uploadedfile']['name'])." has been uploaded";
	$filename =  $_FILES['uploadedfile']['name'];

	//Store the filename, path other criteria in the database 
	$query = "UPDATE admin SET avatar_name='$filename', avatar_path='$filepath'
	WHERE admin_id = {$_SESSION['name']}";


	//Perform the query
	$add = mysql_query($query, $conn)
		or die("Unable to add the avatar details to the database");



	$message = 'Upload Successful';
	//Close the connection to the database	
	mysql_close($conn);
	header("Location:  admin.php? message=$message");
	exit();
} 
else
{	
	$message = 'There was an error uploading the file, please try again!';

	//Close the connection to the database	
	mysql_close($conn);
	header("Location:add_student_photos.php? message=$message");
	exit();
}
?>

Link to comment
https://forums.phpfreaks.com/topic/201159-syntax-on-where/#findComment-1055406
Share on other sites

Ok, so now it still wont send details to db.

 

I have echo out the sql query to check it and it gives me this

UPDATE admin SET avatar_name=1236336869_scary.gif, avatar_path=avatarImages/ WHERE email = deansaddigh@hotmail.comUnable to add the avatar details to the database

 

Which looks correct its got the name and path and updating it where email should equal my email.

 

Why wont it upload it still gives this message

to add the avatar details to the database

 

Heres the bit of code

 

//Store the filename, path other criteria in the database 
	$query = "UPDATE admin SET avatar_name=$filename, avatar_path=$filepath
	WHERE email = {$_SESSION['user']}";




	//Perform the query
	$add = mysql_query($query, $conn)
		or die("Unable to add the avatar details to the database");

Link to comment
https://forums.phpfreaks.com/topic/201159-syntax-on-where/#findComment-1055414
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.