473,486 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sql insert question

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
1 1557
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3078
by: Bob Bedford | last post by:
I've a textarea and would like to save the content in a mysql table each time a user click on a form. How can I do for avoiding error when the user put a " or a ' in the message, or any other...
8
5501
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
4
6911
by: soni29 | last post by:
hi, i have a small question regarding sql, there are two tables that i need to work with on this, one has fields like: Table1: (id, name, street, city, zip, phone, fax, etc...) about 20 more...
5
4699
by: TThai | last post by:
HI, I'm trying to insert records to a table using bcp command. The problem is the input file to the bcp is a text file that looks like this: Text file data: 1234 abc def ghi jkl mno ...
11
7479
by: Jean-Christian Imbeault | last post by:
I have a table with a primary field and a few other fields. What is the fastest way to do an insert into that table assuming that sometimes I might try to insert a record with a duplicate primary...
25
11065
by: Andreas Fromm | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Im building an user database with many tables keeping the data for the Address, Phone numbers, etc which are referenced by a table where I...
16
3838
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
1
3017
by: javedna | last post by:
Can PHP help with the following as I have tried in the MYSQL Forums and cant get any help Thanks Nabz ---------------------------------------- Hi I am developing a PHP MYSQL questionnaire...
10
10470
by: Aditya | last post by:
Hi All, I would like to know how it is possible to insert a node in a linked list without using a temp_pointer. If the element is the first element then there is no problem but if it is in...
24
7089
by: Henry J. | last post by:
My app needs to insert thousand value rows into a mostly empty table (data are read from a file). I can either use inserts, or use merge. The advantage of using merge is that in the few cases...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.