deansaddigh Posted May 9, 2010 Share Posted May 9, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/201159-syntax-on-where/ Share on other sites More sharing options...
ignace Posted May 9, 2010 Share Posted May 9, 2010 Try: //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']}"; Quote Link to comment https://forums.phpfreaks.com/topic/201159-syntax-on-where/#findComment-1055390 Share on other sites More sharing options...
deansaddigh Posted May 9, 2010 Author Share Posted May 9, 2010 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(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/201159-syntax-on-where/#findComment-1055406 Share on other sites More sharing options...
deansaddigh Posted May 9, 2010 Author Share Posted May 9, 2010 Please ignore my last post would help if i was comparing to of the same things in my where clause Im an idiot Quote Link to comment https://forums.phpfreaks.com/topic/201159-syntax-on-where/#findComment-1055408 Share on other sites More sharing options...
deansaddigh Posted May 9, 2010 Author Share Posted May 9, 2010 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"); Quote Link to comment https://forums.phpfreaks.com/topic/201159-syntax-on-where/#findComment-1055414 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.