473,405 Members | 2,141 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,405 software developers and data experts.

problem for inserting forms text values

hey all:
I do a loop that creates text forms on the fly kinda like this:

for (i,i<=$x,i++)(
echo "<input type=text name=$forname> <br>"
$values .= "$forname,"

)

echo "<input form type=submit name="submit">"

then

if ($submit)
//to get rid of the last comma:
$myvalues= str_replace($values,-1)
//i use a function to get the $namesofcolumns but im in a netcafe
right now so...
mysql_query(insert into blabla ($namesofcolumns) values ($myvalues);

the problem is that the insert works but only null values get
inserted, how can I do that?

thanx in advance
Jul 17 '05 #1
2 1521
<ki*********@yahoo.com> wrote in message
news:39**************************@posting.google.c om...
hey all:
I do a loop that creates text forms on the fly kinda like this:

for (i,i<=$x,i++)(
echo "<input type=text name=$forname> <br>"
$values .= "$forname,"

)

echo "<input form type=submit name="submit">"

then

if ($submit)
//to get rid of the last comma:
$myvalues= str_replace($values,-1)
//i use a function to get the $namesofcolumns but im in a netcafe
right now so...
mysql_query(insert into blabla ($namesofcolumns) values ($myvalues);

the problem is that the insert works but only null values get
inserted, how can I do that?

thanx in advance


I didn't see enough of your code to know for sure that this is the case, but
I'm guessing you're working on the assumption that register_globals in
php.ini is set to On. The best policy to go by is to use $_POST['somevar']
instead of $somevar, as that will be more reliable. For example, your line
"if ($submit)" should be "if ($_POST['submit'])". Or actually, "if
(isset($_POST['submit']))" for good measure...

- JP
Jul 17 '05 #2
ok this is my code, when I try to insert the values I get 1,2,3,4 etc
instead of what is entered in the form, can u tell me where is my
mistake please and how to solve the whole thing pease?

gracias
if ($material_to_be_added==$j)
{
$resultprod = $sqlquery ("describe $tabname");
echo "<form method=\"post\" action=$php_self>";
while($row = $sqlfetcharray($resultprod)) {
$col_name = $row['Field'];
$null_value = $row['Null'];
$translated_colname = 'translation_'.$col_name ;
$dispayed_colname = ${$translated_colname};

if ($col_name=='id' || $null_value=='YES')
echo "";
else {echo "<br>$dispayed_colname:<BR><INPUT TYPE=\"TEXT\"
NAME=\"$k\" SIZE=\"40\">";
$col_to_insert .= "$col_name,";
$cols_to_insert = substr_replace($col_to_insert,'',-1);
$val_to_insert .= "$k,";
$vals_to_insert = substr_replace($val_to_insert,'',-1);
$k = $k +1;
}
}
echo "<p><input type=\"submit\" name=\"submit\" value=\"$submit\">
</form><p> $cols_to_insert <p> $vals_to_insert";
if ($submit) {
$result=$sqlquery("INSERT INTO $tabname($cols_to_insert)".
"VALUES ($vals_to_insert)");
}
}
"kingofkolt" <je**********@comcast.net> wrote in message news:<ppyXc.322092$%_6.188275@attbi_s01>...
<ki*********@yahoo.com> wrote in message
news:39**************************@posting.google.c om...
hey all:
I do a loop that creates text forms on the fly kinda like this:

for (i,i<=$x,i++)(
echo "<input type=text name=$forname> <br>"
$values .= "$forname,"

)

echo "<input form type=submit name="submit">"

then

if ($submit)
//to get rid of the last comma:
$myvalues= str_replace($values,-1)
//i use a function to get the $namesofcolumns but im in a netcafe
right now so...
mysql_query(insert into blabla ($namesofcolumns) values ($myvalues);

the problem is that the insert works but only null values get
inserted, how can I do that?

thanx in advance


I didn't see enough of your code to know for sure that this is the case, but
I'm guessing you're working on the assumption that register_globals in
php.ini is set to On. The best policy to go by is to use $_POST['somevar']
instead of $somevar, as that will be more reliable. For example, your line
"if ($submit)" should be "if ($_POST['submit'])". Or actually, "if
(isset($_POST['submit']))" for good measure...

- JP

Jul 17 '05 #3

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

Similar topics

0
by: VIJAY KUMAR | last post by:
I have a problem with Refresh button when user add a new record. Sample Code: Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click...
1
by: pmud | last post by:
I have an ASP.NET web application using C# code. I am trying to insert values from a web form into an SQL database. I am using SQL COMMAND object for this. I need to know HOW TO INSERT THE RADIO...
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
4
by: PSL | last post by:
Hi, I am going through the training C# For Programmers made by TestOut and like the presentation. The only problem is that this tutorial has a nastie bug that renders this software practically...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
7
by: Andy C Matthews | last post by:
Hi there, I'm building an Access database and using VBA to generate Microsoft Word mailings for customers. It's all going fine so far. However, a variables named ParcelID, a ten-digit string such...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
1
by: arial | last post by:
I have two problem. 1) My insert statement here is not working. It is not inserting value into the database. I am not getting any error message but I can not figured out why it is not...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...

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.