473,394 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Getting the dynamic 'name' with $_REQUEST[] , Pls help

Dear Group,

Please look at the following demo link.

http://www.itsravi.com/demo/new_pms/...addproject.php

I am trying to implement the "more attachment" and "more url" tasks in that
page. The data base design is like this. Keeping a separate table for the
"more file upload" (File uploaded directly to mysql). If the user closes
after simply uploading the files without submitting the whole project
information, or an exception occurs then the db table with extra files and
url is inserted un-necessary. So I thought to put all the uploaded
information in a array. At the end of submitting the full project
information in the db the array values will get stored in the corresponding
url and file table which is the child table which has got the FK key points
to the corresponding project (parent)table.

Following is the code I wrote for inputting the multiple url upload.

<?php

$number_tot = $number; /*if 3 given in the text box then 3 box to get urls*/

print "<form name=more_url_comp action=more_url_comp.php method=post>";

for($i=1 ; $i<= $number_tot ; $i++)

{

print "More Url $i:<input type='text' name='url_comp_'.$i><br>";

$more_url_comp[] = "url_comp_".$i; /*All the url name array*/

$test = $_REQUEST['url_comp_'.$i]; /*This is not wrking*/

}

echo '<input type="submit" name="more_comp_url" value="Upload Now!">';

print "</form>";

I got really stuck with the following. I don't know who to get the

$test = $_REQUEST['url_comp_'.$i]

in a array. Since the variable $i getting appended in the end. If, on the
other hand, I use array in the name of the text box such as text[], then can
I use serialize and unserialize function. If this can be done then there is
no need to use a separate db table to hold the value for url. Or I am
missing some thing very basic.?

I have not started to implement this with multiple file upload to the
mysql directly. I don't know what could be the problem that will arise in
that situation.

Any help will be very help full. Thanks.
Jun 26 '07 #1
6 2473
sathyashrayan kirjoitti:
Dear Group,

Please look at the following demo link.

http://www.itsravi.com/demo/new_pms/...addproject.php

I am trying to implement the "more attachment" and "more url" tasks in that
page. The data base design is like this. Keeping a separate table for the
"more file upload" (File uploaded directly to mysql). If the user closes
after simply uploading the files without submitting the whole project
information, or an exception occurs then the db table with extra files and
url is inserted un-necessary. So I thought to put all the uploaded
information in a array. At the end of submitting the full project
information in the db the array values will get stored in the corresponding
url and file table which is the child table which has got the FK key points
to the corresponding project (parent)table.

Following is the code I wrote for inputting the multiple url upload.

<?php

$number_tot = $number; /*if 3 given in the text box then 3 box to get urls*/

print "<form name=more_url_comp action=more_url_comp.php method=post>";
please change this to
print "<form name='more_url_comp' action='more_url_comp.php'
method='post'>";

Unquoted string literals make Tim Berners-Lee cry.
>
for($i=1 ; $i<= $number_tot ; $i++)

{

print "More Url $i:<input type='text' name='url_comp_'.$i><br>";

$more_url_comp[] = "url_comp_".$i; /*All the url name array*/

$test = $_REQUEST['url_comp_'.$i]; /*This is not wrking*/
What the heck you mean it's not working? You're not using $test for
anything, how is it supposed to work?
>
}

echo '<input type="submit" name="more_comp_url" value="Upload Now!">';

print "</form>";

I got really stuck with the following. I don't know who to get the

$test = $_REQUEST['url_comp_'.$i]

in a array.
In what array? What is it that you exactly want to do with it? How come
you're dealing with $_REQUEST (and by the way, you should always use
either $_GET or $_POST, depending what your form method is, never
$_REQUEST) even before the form is submitted, you're just outputting the
form, what would $_REQUEST contain at that point?
Since the variable $i getting appended in the end. If, on the
other hand, I use array in the name of the text box such as text[], then can
I use serialize and unserialize function. If this can be done then there is
no need to use a separate db table to hold the value for url. Or I am
missing some thing very basic.?
If I understand right, you're talking about having multiple values in
one database field? No, no, and no. Very wrong. Just use the extra table
like you intended. (Why: check out Codd's database normalization rules)
I have not started to implement this with multiple file upload to the
mysql directly. I don't know what could be the problem that will arise in
that situation.

Any help will be very help full. Thanks.
--
Ra*********@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Jun 26 '07 #2
sathyashrayan kirjoitti:
>
print "More Url $i:<input type='text' name='url_comp_'.$i><br>";
The line above is producing malformed html, it will print:

More Url 1:<input type='text' name='url_comp_'.1><br>
This is just wrong. The browser will take the name as url_comp_ and
wonder what the heck the .1 is doing there but not taking them into account.

I assume you wanted:
More Url 1:<input type='text' name='url_comp_1'><br>

To get that, change the code like this:
print "More Url $i:<input type='text' name='url_comp_$i'><br>";
--
Ra*********@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Jun 26 '07 #3
Rami Elomaa wrote:
sathyashrayan kirjoitti:
>>
print "More Url $i:<input type='text' name='url_comp_'.$i><br>";

The line above is producing malformed html, it will print:

More Url 1:<input type='text' name='url_comp_'.1><br>
This is just wrong. The browser will take the name as url_comp_ and
wonder what the heck the .1 is doing there but not taking them into
account.

I assume you wanted:
More Url 1:<input type='text' name='url_comp_1'><br>

To get that, change the code like this:
print "More Url $i:<input type='text' name='url_comp_$i'><br>";

Actually, it will print:

More Url 1:<input type='text' name='url_comp_1'><br>"

Which is correct.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '07 #4
sathyashrayan wrote:
Dear Group,

Please look at the following demo link.

http://www.itsravi.com/demo/new_pms/...addproject.php

I am trying to implement the "more attachment" and "more url" tasks in that
page. The data base design is like this. Keeping a separate table for the
"more file upload" (File uploaded directly to mysql). If the user closes
after simply uploading the files without submitting the whole project
information, or an exception occurs then the db table with extra files and
url is inserted un-necessary. So I thought to put all the uploaded
information in a array. At the end of submitting the full project
information in the db the array values will get stored in the corresponding
url and file table which is the child table which has got the FK key points
to the corresponding project (parent)table.

Following is the code I wrote for inputting the multiple url upload.

<?php

$number_tot = $number; /*if 3 given in the text box then 3 box to get urls*/

print "<form name=more_url_comp action=more_url_comp.php method=post>";

for($i=1 ; $i<= $number_tot ; $i++)

{

print "More Url $i:<input type='text' name='url_comp_'.$i><br>";

$more_url_comp[] = "url_comp_".$i; /*All the url name array*/

$test = $_REQUEST['url_comp_'.$i]; /*This is not wrking*/

}

echo '<input type="submit" name="more_comp_url" value="Upload Now!">';

print "</form>";

I got really stuck with the following. I don't know who to get the

$test = $_REQUEST['url_comp_'.$i]

in a array. Since the variable $i getting appended in the end. If, on the
other hand, I use array in the name of the text box such as text[], then can
I use serialize and unserialize function. If this can be done then there is
no need to use a separate db table to hold the value for url. Or I am
missing some thing very basic.?

I have not started to implement this with multiple file upload to the
mysql directly. I don't know what could be the problem that will arise in
that situation.

Any help will be very help full. Thanks.

First of all, when setting the url, your current code is generating:

More Url 1:<input type='text' name='url_comp[]'><br>

First of all, IMHO since you're posting the form, you should use
$_POST['xxx'] instead of $_REQUEST['xxx']. Just a little safer; the
former works only with POSTed values; your way works with either $_POST
or $_GET (potential security exposure).

To get it from this array, you can use:

$url_array= array();
foreach ($POST['url_comp'] as $url)
$url_array[] = $url;

Also remember - unless you save these values, i.e. in the $_SESSION,
they will only exist for this one page.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '07 #5
Jerry Stuckle kirjoitti:
Rami Elomaa wrote:
>sathyashrayan kirjoitti:
>>>
print "More Url $i:<input type='text' name='url_comp_'.$i><br>";

The line above is producing malformed html, it will print:

More Url 1:<input type='text' name='url_comp_'.1><br>
This is just wrong. The browser will take the name as url_comp_ and
wonder what the heck the .1 is doing there but not taking them into
account.

I assume you wanted:
More Url 1:<input type='text' name='url_comp_1'><br>

To get that, change the code like this:
print "More Url $i:<input type='text' name='url_comp_$i'><br>";


Actually, it will print:

More Url 1:<input type='text' name='url_comp_1'><br>"

Which is correct.
Nope, the script _is_ incorrect and here's an easy way to test it:

Here is my test script:
<?php
$i = 1;
print "More Url $i:<input type='text' name='url_comp_'.$i><br>";
?>

Here is my output:
More Url 1:<input type='text' name='url_comp_'.1><br>

See what I mean?

--
Ra*********@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Jun 27 '07 #6
Rami Elomaa wrote:
Jerry Stuckle kirjoitti:
>Rami Elomaa wrote:
>>sathyashrayan kirjoitti:

print "More Url $i:<input type='text' name='url_comp_'.$i><br>";
The line above is producing malformed html, it will print:

More Url 1:<input type='text' name='url_comp_'.1><br>
This is just wrong. The browser will take the name as url_comp_ and
wonder what the heck the .1 is doing there but not taking them into
account.

I assume you wanted:
More Url 1:<input type='text' name='url_comp_1'><br>

To get that, change the code like this:
print "More Url $i:<input type='text' name='url_comp_$i'><br>";


Actually, it will print:

More Url 1:<input type='text' name='url_comp_1'><br>"

Which is correct.

Nope, the script _is_ incorrect and here's an easy way to test it:

Here is my test script:
<?php
$i = 1;
print "More Url $i:<input type='text' name='url_comp_'.$i><br>";
?>

Here is my output:
More Url 1:<input type='text' name='url_comp_'.1><br>

See what I mean?
Sorry - you're right. I wasn't thinking about all the quotes.

Teach me to try to update when I'm tired... :-)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: toufik toufik | last post by:
Hi, I've a variable that can come with the GET and POST method, So I use $_REQUEST to get it When I use a simple href href="myFile.php?myVar=value" I have myVAr in the $GET and $_REQUEST arrays....
1
by: hjyn | last post by:
Hi All, I create a form for the user to enter the information, the form contains two table, table A and table B. I wrote a script to prompt the user to fill all the necessary data if they miss to...
4
by: Geoff Soper | last post by:
I'm working on an authentication system in which it's possible that a user might be requested to log-in as a result of submitting a form if the inactivity timeout is exceeded. In order that they...
5
by: K | last post by:
I have found a script online that I want to use (I am new to PHP). It creates dynamic images based on the text that you pass it. However, no matter how I try, I can't get anything other than a...
2
by: Geoff Winkless | last post by:
Hi My knowledge of php is regrettably poor but I need to call a third-party php script from within a bash cgi script (don't ask why, it's a long story). Now normally (with eg perl-cgi) to do...
11
by: Ray Muforosky | last post by:
I have this: ------------ print "<FORM name=\"form3\" ACTION=\"cmdlog_rep.php\">\n"; print "<TD><INPUT TYPE=\"submit\" VALUE=\"Submit\"></TD>\n"; .. print "<INPUT type=\"HIDDEN\"...
10
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're...
22
by: Sri | last post by:
All Recenetly our shop migrated to DB2 V8 from V7. We are in IBM System Level: z/OS 1.6.1 @ RSU 0702. Processor : IBM 2064-1C7 (z/900) # 1B89 Mode: 64-bit One of my application is facing...
2
by: jej1216 | last post by:
I have a multi-field search PHP page, and the resulting PHP page builds dynamic WHERE statements to do the database search. The first field is numeric, and works: $facility = $_REQUEST; if...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
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...
0
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...

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.