473,405 Members | 2,171 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.

Form data to sql database

2
Hi,

I'm trying to setup a web form that will put data into a sql database. I had everything working with a simple test database (first name, last name, phone number). But once I added "address" and "city" to the process, the data collected in the database simply shows "Array(address)" or "Array(city)" and not the actual data I typed into the form. (The other fields work normally).

Any help would be appreciated.

Here is my code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $EntryDate= date('Y-m-d H:i:s');
  4.  
  5. $con = mysql_connect("localhost", "login", "password");
  6. if (!$con)
  7.     {
  8.     die('Could not connect: ' . mysql_error());
  9.     }
  10.  
  11. mysql_selectdb("database_name", $con);
  12.  
  13. $sql="INSERT INTO data (`EntryDate`, `FirstName`, `LastName`, `Institution`, `Address`, `City`)
  14. VALUES
  15. ('$EntryDate', '$_POST[fname]', '$_POST[lname]', '$_POST[inst]', '$_POST(address)', '$_POST(city)' )";
  16.  
  17. if (!mysql_query($sql,$con))
  18.     {
  19.     die('Error: ' . mysql_error());
  20.     }
  21. echo "Thank you.";
  22.  
  23. mysql_close($con);
  24.  
  25. ?>
Sep 4 '07 #1
3 1457
ak1dnar
1,584 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. ('$EntryDate', '$_POST[fname]', '$_POST[lname]', '$_POST[inst]', '$_POST[address]', '$_POST[city]' )";
  2.  
Mind the Brackets. It should be square ones. not the parenthesis.
Sep 4 '07 #2
wileee
2
Guess I was in a hurry to get things working.

Thank you very much.
Sep 4 '07 #3
ak1dnar
1,584 Expert 1GB
Guess I was in a hurry to get things working.

Thank you very much.
Glad to hear that.Good luck with your projects. If you ever need anything post back to the Forum.
Sep 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: cooldv | last post by:
i know how to replace the sign " when SUBMITTING a form in asp by this code: message = Replace(usermessage, "'", "''"). My problem is DISPLAYING data in an asp FORM, from an an access database,...
2
by: PinkBishop | last post by:
Hello All, Hope you can help. Below is the code I use to send data from form to database. Problem is if an apostrophe is entered in cQuestion field or any field for that matter the form...
4
by: intl04 | last post by:
How do I create a data input form in Access that is external to the Access database to which it's connected (if that's possible, which I believe it is)? For example, if someone clicks on an Access...
3
by: intl04 | last post by:
Is it possible to create a Word form as the data entry form for an Access database? I didn't see any reference to this possibility in my Access books, so I'm sorry if this is a question that is...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
4
by: sparks | last post by:
We have a database that reads in and formats raw data. We were using queries to format the data per person and outputing reports. The other database has the persons personal information. I changed...
0
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
2
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
15
by: Kevin Davis | last post by:
Hello, I'm a new person when it comes to PHP and I have a quick question. I would like to create a form that will allow the user to add more information using the same form in case they have...
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...
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.