I have a PHP file upload feature that also gives the user the option to
assign more than 1 project association to the file. The file's name, title,
primary project, etc. is inserted into a document link table in a MySQL db
after the file is uploaded. The secondary (and multiple) project(s) are also
selected using a separate list box (there are 2 boxes - one for the primary
project, and one for any/all associated projects) The selected values from
the secondary box need to be inserted into a junction table that reflects
both the id for the newly uploaded file and the secondary project(s) - with
a primary key for the association itself, i.e,:
assoc_id doc_id proj_id
1 265 5
2 265 3
3 265 1
I would use a foreach statement to pull the projects from the select list,
but how do I get the newly generated doc_id in order to pass that value to
the association table? Can I assign it a variable at the same time I insert
the data into the primary table? The ID is auto-incremented and is inserted
into the primary table as follows:
$tool_insert = "INSERT INTO tools VALUES ('', '$uploadedname' , '$tooltitle',
'$tooldesc', '$tooltype_id', '$toolcat_id', '$primeproj_id' , '$location')";
Thanks for any help.
Christina 10 2836
Chris wrote:
I have a PHP file upload feature that also gives the user the option to
assign more than 1 project association to the file. The file's name, title,
primary project, etc. is inserted into a document link table in a MySQL db
after the file is uploaded. The secondary (and multiple) project(s) are also
selected using a separate list box (there are 2 boxes - one for the primary
project, and one for any/all associated projects) The selected values from
the secondary box need to be inserted into a junction table that reflects
both the id for the newly uploaded file and the secondary project(s) - with
a primary key for the association itself, i.e,:
assoc_id doc_id proj_id
1 265 5
2 265 3
3 265 1
I would use a foreach statement to pull the projects from the select list,
but how do I get the newly generated doc_id in order to pass that value to
the association table? Can I assign it a variable at the same time I insert
the data into the primary table? The ID is auto-incremented and is inserted
into the primary table as follows:
$tool_insert = "INSERT INTO tools VALUES ('', '$uploadedname' , '$tooltitle',
'$tooldesc', '$tooltype_id', '$toolcat_id', '$primeproj_id' , '$location')";
Thanks for any help.
Christina
I believe you're looking for mysql_last_inse rt_id()
Frizzle.
Thanks - that makes sense, I'll give it a try. Hard to find all the
built-in functions - I had seen mysql_insert_id , but hadn't seen this one.
"frizzle" <ph********@gma il.comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
>
I believe you're looking for mysql_last_inse rt_id()
Frizzle.
Chris wrote:
>I believe you're looking for mysql_last_inse rt_id()
Thanks - that makes sense, I'll give it a try. Hard to find all the
built-in functions - I had seen mysql_insert_id , but hadn't seen this
one.
That's because mysql_last_inse rt_id() is not a PHP function. Frizzle was
unfortunately on the fritz. mysql_insert_id () it is, which should work
Grtz,
--
Rik Wasmus
Rik wrote:
Chris wrote:
I believe you're looking for mysql_last_inse rt_id()
Thanks - that makes sense, I'll give it a try. Hard to find all the
built-in functions - I had seen mysql_insert_id , but hadn't seen this
one.
That's because mysql_last_inse rt_id() is not a PHP function. Frizzle was
unfortunately on the fritz. mysql_insert_id () it is, which should work
Grtz,
--
Rik Wasmus
I assume the result to be equal.
Would mysql_insert_id () still require a DB connection to be open?
Frizzle.
frizzle wrote:
Rik wrote:
>Chris wrote:
>>>I believe you're looking for mysql_last_inse rt_id()
Thanks - that makes sense, I'll give it a try. Hard to find all the built-in functions - I had seen mysql_insert_id , but hadn't seen this one.
That's because mysql_last_inse rt_id() is not a PHP function. Frizzle was unfortunately on the fritz. mysql_insert_id () it is, which should work
Grtz, -- Rik Wasmus
I assume the result to be equal.
Would mysql_insert_id () still require a DB connection to be open?
Yes. It's result isn't cached after a query in PHP, but queried from the
database itself.
Grtz,
--
Rik Wasmus
frizzle wrote:
Rik wrote:
>>Chris wrote:
>>>>I believe you're looking for mysql_last_inse rt_id()
Thanks - that makes sense, I'll give it a try. Hard to find all the built-in functions - I had seen mysql_insert_id , but hadn't seen this one.
That's because mysql_last_inse rt_id() is not a PHP function. Frizzle was unfortunate ly on the fritz. mysql_insert_id () it is, which should work
Grtz, -- Rik Wasmus
I assume the result to be equal.
Would mysql_insert_id () still require a DB connection to be open?
Frizzle.
Yes, it's a MySQL call.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Jerry Stuckle wrote:
frizzle wrote:
Rik wrote:
>Chris wrote:
I believe you're looking for mysql_last_inse rt_id()
Thanks - that makes sense, I'll give it a try. Hard to find all the built-in functions - I had seen mysql_insert_id , but hadn't seen this one.
That's because mysql_last_inse rt_id() is not a PHP function. Frizzle was unfortunatel y on the fritz. mysql_insert_id () it is, which should work
Grtz, -- Rik Wasmus
I assume the result to be equal.
Would mysql_insert_id () still require a DB connection to be open?
Frizzle.
Yes, it's a MySQL call.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
So you'd have to run another extra call to the database, instead of
getting it from cache ?
Wouldn't that make it slower?
Not quite getting this, but liked to know how it works ...
Frizzle
frizzle wrote:
Jerry Stuckle wrote:
>>frizzle wrote:
>>>Rik wrote:
Chris wrote:
>>I believe you're looking for mysql_last_inse rt_id() >> > >Thanks - that makes sense, I'll give it a try. Hard to find all the >built-in functions - I had seen mysql_insert_id , but hadn't seen this >one.
That's because mysql_last_inse rt_id() is not a PHP function. Frizzle was unfortunate ly on the fritz. mysql_insert_id () it is, which should work
Grtz, -- Rik Wasmus
I assume the result to be equal. Would mysql_insert_id () still require a DB connection to be open?
Frizzle. Yes, it's a MySQL call.
-- ============= ===== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. js*******@att global.net ============= =====
So you'd have to run another extra call to the database, instead of
getting it from cache ?
Wouldn't that make it slower?
Not quite getting this, but liked to know how it works ...
Frizzle
Yes, because it isn't returned so there's no cache to store it in.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
On 20 Jul 2006 14:36:19 -0700, "frizzle" <ph********@gma il.comwrote:
>>I assume the result to be equal. Would mysql_insert_id () still require a DB connection to be open?
Yes, it's a MySQL call.
So you'd have to run another extra call to the database, instead of getting it from cache ? Wouldn't that make it slower? Not quite getting this, but liked to know how it works ...
Interesting question, as the docs don't seem to explicitly state whether it
does or does not.
Tracing network traffic with Ethereal, MySQL client 5.0.22, server version
4.1.7 on another machine, and sleep() calls between each step to make it
obvious what is happening at each stage, shows that calling mysql_insert_id ()
does not result in any communication with the server; so the value must be sent
across and stored in the client as part of running the previous mysql_query().
Looking at the individual packets, this is indeed the case; the ID is returned
as part of the payload in the "OK" packet in reply to the query:
No. Time Source Destination Protocol Info
12 0.006948 192.168.1.101 192.168.1.100 MySQL Request
Command: Query : insert into t (id) values (null)
Frame 12 (91 bytes on wire, 91 bytes captured)
Ethernet II, Src: SC&C_d5:81:1c (00:00:21:d5:81 :1c), Dst: SC&C_d5:81:1a
(00:00:21:d5:81 :1a)
Internet Protocol, Src: 192.168.1.101 (192.168.1.101) , Dst: 192.168.1.100
(192.168.1.100)
Transmission Control Protocol, Src Port: 3693 (3693), Dst Port: 3306 (3306),
Seq: 86, Ack: 83, Len: 37
MySQL Protocol
Packet Length: 33
Packet Number: 0
Command
Command: Query (3)
Parameter: insert into t (id) values (null)
No. Time Source Destination Protocol Info
13 0.008511 192.168.1.100 192.168.1.101 MySQL Response
OK
Frame 13 (65 bytes on wire, 65 bytes captured)
Ethernet II, Src: SC&C_d5:81:1a (00:00:21:d5:81 :1a), Dst: SC&C_d5:81:1c
(00:00:21:d5:81 :1c)
Internet Protocol, Src: 192.168.1.100 (192.168.1.100) , Dst: 192.168.1.101
(192.168.1.101)
Transmission Control Protocol, Src Port: 3306 (3306), Dst Port: 3693 (3693),
Seq: 83, Ack: 123, Len: 11
MySQL Protocol
Packet Length: 7
Packet Number: 1
Response Code: 0
Payload: \001\017\002
In this case the ID was 15 - which is octal \017 - the middle byte in the
payload of the response to the query.
--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: tornado |
last post by:
Hi all,
I am pretty new to PHP. I was reading PHP manual and trying out the
example from 2nd
chapter (A simple Tutorial). When i try to print the variable as
given in the example it returns
a empty value instead of returning the browser type.
Here is the line which i am using in my code and from manual:
<?php echo $_SERVER; ?>
|
by: cschang |
last post by:
I have a file upload module written in .aspx. I want to write the
filename (just the name) uploaded back to the my parent .asp file (the
..aspx file was a pop-up window related to the .asp) so that the parent
page can display what file has been just uploaded. How can I do that?
especially I want to write the uploaded filename back to the <a> tag's
innerText property and the value of a checkbox field. I have tried with
the codes in my...
|
by: Peter Row |
last post by:
Hi,
To allow users to upload files larger than 4MB in size I added:
<httpRuntime maxRequestLength="102400" executionTimeout="600" />
...to my web.config file. Fair enough this works fine. However how do
I check the maxRequestLength value through code?
Let me set a bit of background. I don't actually have any ASPX pages I have
|
by: Dotcom |
last post by:
I have an ASP.NET application that is mysteriously acquiring height and width
attributes on a particular IMG element on multiple pages. This is not being
caused by someone editing or uploading new copies of the files.
There are various scripting and "active" technologies enabled on the server:
ASP.NET
ASP
Front Page Extensions
Perl
|
by: Brandon |
last post by:
I created a setup project in VS.NET 2k5 and added an additional dialog to ask
the user where they would like to place icons for my application. The options
are Desktop and QuickLaunch Menu.
When the user unchecks one of these, or checks one of these, the value is
completely disregarded by my setup project when installation commences. I
have found other users complaining of the same thing, and I have followed the
instructions given at:...
| |
by: bhcob1 |
last post by:
Hi guys,
This is the situation.
I have 3 tables, with the following relevent fields
tblSubFile (Substantiation Files)
- autonumber
- Primary Key
- Primary Key
|
by: happyse27 |
last post by:
Hi All,
my html code is sno 1) and perl code is sno 2).
a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it didnt display the html after the perl script executed. Using perl 5.1 and apache 2.2.9 version(apache installed and run without any errors and no warning, perl tested fine)
b) Also, when i clicked the html code to submit the upload of the...
|
by: ajeeshc |
last post by:
i want to display the path of file in browser that i am uploaded to the server
for later downloading but when iam trying to do this using the mysql_fetch_array()
it not working
an error like
here the code i used
<html>
|
by: liberty1 |
last post by:
Hi everyone. I appreciate your effort at helping newbies like me. I have the following problems and will appreciate urgent help.
PROBLEM NUMBER 1:
Using PHP and MySQL, I am able to upload picture successfully unto the server but not so with the file name of the picture even though other parameters in my form got inserted successfuly in the database. I have read several posts on this topic including here on this site but I can't get around...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |