Jump to content

Recommended Posts

Hi all,

 

I have an upload on and at present it uploads fine to the correct destination. As I'm uploading images I want to be able to store the image in a specific table which is users.

 

$query = "insert into users values where userid= $userid (0,'".$filename."')";

 

So I run the above query but I errors saying:

 

Unable to perform query insert into users value where userid= 1 (0,'Lighthouse.jpg')

 

I'm storing the user id from the session variable into $user id as below and also putting the filename into the $filename variable.

 

$userid = $_SESSION['userid'];

$filename = $_FILES["file"]["name"];

 

Not sure if I'm doing anything wrong any one able to help?

Link to comment
https://forums.phpfreaks.com/topic/198004-query-structure-why-would-this-not-work/
Share on other sites

where is a condition. You don't require a condition on an insert, (unless, perhaps, you are inserting from a select query).

 

something likes this should be more than good enough:

 

<?php
$query = "insert into users(<fieldlist>)
  values (0, '".$filename."')";
?>

 

You may also need to think about what you are trying to do. Are you trying to create a new users, or are you trying to update an old user with a new profile picture (or something completely different yet again).

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.