Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8860997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:23:31+00:00 2026-06-14T15:23:31+00:00

i am using following code for uploading image files, when uploading process to path

  • 0

i am using following code for uploading image files, when uploading process to path working well, but when file path insert to database table field i get error

uploader.php

<?php
$db = mysql_connect('localhost', 'root', '') or die('Could not connect:' . mysql_error());
mysql_select_db('fileupload4',$db);
$allowed_filetypes = array('.jpg','.gif','.bmp','.png');
$max_filesize = 10000000;
$upload_path = 'images/'; 
$filename = $_FILES['userfile']['name'];
$extension = substr($filename, strpos($filename,'.'), strlen($filename)-1);
if(!in_array($extension , $allowed_filetypes)) {
    die('The file you attempted to upload is not allowed.');
}
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) {
    die('The file you attempted to upload is too large.');
}
if(!is_writable($upload_path)) {
   die('You cannot upload to the specified directory, please CHMOD it to 777.');
}
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_path.$filename)) {
    echo 'Your file upload was successful, view the file <a href="'.$upload_path.$filename.'" title="Your File">Here</a>';
} else {
    echo 'There was an error during the file upload.  Please try again.'; // It failed
}
$sql = "UPDATE students SET image = '".$upload_path."' WHERE id = 'student_id'";
mysql_query($sql) OR die(mysql_error());
?>

this is what i get error when uploading image

Unknown column 'id' in 'where clause'

thanks for any help…

my table structure

CREATE TABLE IF NOT EXISTS `students` (
  `student_id` int(11) NOT NULL AUTO_INCREMENT,
  `image` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  PRIMARY KEY (`student_id`),
  KEY `student_id` (`student_id`),
  KEY `image` (`image`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:23:32+00:00Added an answer on June 14, 2026 at 3:23 pm

    It looks like the line

    $sql = "UPDATE students SET image = '".$upload_path."' WHERE id = 'student_id'";
    

    needs to be changed to

    $sql = "UPDATE students SET image = '".$upload_path."' WHERE student_id = 'student_id'";
    

    since you don’t have a column named id but you have one named student_id

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code for uploading an multiform/data form with a file upload:
I am uploading HTML5 canvas base64 image over servlet using following JavaScript code function
I'm using WordPress and I'm following W3's guide for uploading a file: HTML code:
I using following code and it is successfully uploading files on my local machine.
Greetings, I'm uploading an image to my server using the following code: http://cocoadev.com/index.pl?HTTPFileUploadSample However,
I using following code: var search = 'test'; if ($('#sku').find(search) ){ //alert(search); $(document).find(search).css('color','red'); <TABLE>
I am using following code to get source for image in wpf (image is
How to a create thumb image while uploading a video, am using the following
I am uploading some image files using servelt. I want to resize the images.
I've implemented the following code for uploading photos inside a jQuery dialog (using an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.