By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,719 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,719 IT Pros & Developers. It's quick & easy.

sql insert question

P: n/a
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
database.

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!):
<?php
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
directorytile='$file_name'";
}
?>

<?php

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!!!!!
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ph*********@comcast.net (Mikey P) wrote:

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
database.

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_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
directorytile='$file_name'";
}


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, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.