Jump to content

Is theis Syntax completely wrong?


Accurax

Recommended Posts

Im trying to insert dtaa into an established database, and i want the data to go into the correct place for each user, I am trying to get the following to work, but im starting to worry that im off the mark a little.... any tips please?

[code]$query = "INSERT INTO members WHERE user_name='$username'(picture)
VALUES ('$filepath')";
$result = mysql_query($query)
or die ("could not add picture.");[/code]
Link to comment
Share on other sites

yes
[code]$query = "INSERT INTO members ('picture') Values ('$filepath') WHERE user_name='$username'";[/code]

Or I like to use the set function
[code]$query = "INSERT INTO members SET picture = '$filepath' WHERE user_name='$username'";[/code]

Either will do

Ray
Link to comment
Share on other sites

It doesnt work mate.... file uploads correctly, but the $filepath variable doesnt go to the database, heres the code, can u see the problem?

[code]
<?php
session_start();
include("conection.inc");
if ( $_SESSION['login'] != "true" )
{
header("location: hacker.php");
}

else
{
$filepath = "/pictures/".$_FILES['filename']['name'];
echo $filepath;

      $source = "pictures";
      move_uploaded_file($_FILES['filename']['tmp_name'],
              "../mysite/$source/".$_FILES['filename']['name']);
}

$connection=mysql_connect($host, $user, $passwd)
or die ("Could not connect !");
$db = mysql_select_db($database, $connection)
or die ("Could not connect to Database");



$query = "INSERT INTO members ('picture') VALUES ('$filepath') WHERE user_name='$username'";
$result = mysql_query($query)
or die ("could not add picture.");

?>[/code]
Link to comment
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.