sql insert question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
hi all thanks again for all th direction you guys have given me..

i have a partial backend done for uploading graphics to a directory
and information into mysql. Now what i'm having problems with is
getting the file path with the file name to upload to the sql

Right now i have 2 unique qualifiers carrying over (jobnum, custID).
I'm querying the database to find those matching qualifier and i need
to fill in the file name into the directorytile field in the db. here
is what i have now (excuse the sloppy code i'm a newbie!):


                mysql_connect ('localhost', 'acme', 'acme') ;
mysql_select_db ('olcg');
$query = mysql_query("SELECT directorytile FROM itl WHERE
jobnum='$jobnum' AND custID='$custID'") or die (mysql_error());

if (isset($_POST['submit'])) {
      $sql = "INSERT INTO itl SET


if($file_name !="")
copy ("$file", "/home/guestdir/www/olcg/$file_name")
         or die("Could not copy file");
else { die("No file specified"); }


again thanks so much!!!!!

Re: sql insert question

phatnugs420@comcast.net (Mikey P) wrote:
Quoted text here. Click to load it

INSERT is only used to add an entirely new record.  To update the fields in
an existing record, you use UPDATE.  Further, an SQL connection has no
concept of a "current record", so you have to tell it exactly which
record(s) to update.  Hence:

    $sql = "UPDATE itl SET directorytile='$file_name' " .
           "WHERE jobnum='$jobnum' AND custID='$custID';";
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.

Site Timeline