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
https://forums.phpfreaks.com/topic/30234-is-theis-syntax-completely-wrong/
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
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.