Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Inserting form fields into MySQL database
Old 01-02-2010, 03:15 PM Inserting form fields into MySQL database
choskins102's Avatar
Super Talker

Posts: 137
Name: Casey
Trades: 3
Okay, I don't really consider myself a novice when it comes to PHP and MySQL, but it has been over a year since I messed with it. The problem I am having is getting my form data stored in a MySQL table. The data is being sent properly, but, for some reason, only 3 fields will go into the table. Here is my very basic code:

Code:
<?php
                         
$connect = mysql_connect("localhost", "$user", "$password");
mysql_select_db("database", $connect);
              
mysql_query("INSERT INTO new (email, name, yourclass, mspec) 
VALUES('$_POST[email]','$_POST[name]','$_POST[yourclass]','$_POST[mspec]')");
              
echo "Done!";
?>
Now, if I remove the 'mspec' variable, the email, name, and yourclass variable will be placed in my table like I want them. However, as soon as I add the mspec variable...nothing. I need to add 13 fields into a table and it is seriously starting to tick me off that something that should have taken 10 minutes is taking me 2 hours. Can anyone spot something that I am just doing wrong?
choskins102 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-02-2010, 03:36 PM Re: Inserting form fields into MySQL database
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Your query is right... As long as your db table have the schema that correspond to it.
Are you sure you have a field named "mspec" in your table, and that this field is in a text or varchar datatype ?
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 01-02-2010, 03:49 PM Re: Inserting form fields into MySQL database
choskins102's Avatar
Super Talker

Posts: 137
Name: Casey
Trades: 3
Wow, I am such an idiot. My form has it listed as mspec, but my database has it as m_spec. I can't believe I wasted all that time for this. Thanks, dude.
choskins102 is offline
Reply With Quote
View Public Profile
 
Old 01-02-2010, 07:40 PM Re: Inserting form fields into MySQL database
Defies a Status

Posts: 1,606
Trades: 0
And since I did about the same thing last month, allow me to add that Myfield and myfield are not the same either.


And I knew better.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 01-02-2010, 08:54 PM Re: Inserting form fields into MySQL database
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
This isn't related to your question, but I noticed that you've left yourself wide open to sql injection. You should validate and sanitize your post data before inserting it into the database.

http://us2.php.net/manual/en/functio...ape-string.php
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 01-03-2010, 12:57 PM Re: Inserting form fields into MySQL database
freezea's Avatar
Experienced Talker

Posts: 45
Trades: 0
Hi.
Please refer to the url below:
http://www.infinite-fire.net/tutoria...mysql-database
I wish it will be helpful.
Regards,
freezea.
__________________

Please login or register to view this content. Registration is FREE
: Web-based Excel-like Java reporting tool.
freezea is offline
Reply With Quote
View Public Profile
 
Old 01-03-2010, 02:48 PM Re: Inserting form fields into MySQL database
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Originally Posted by colbyt View Post
And since I did about the same thing last month, allow me to add that Myfield and myfield are not the same either.


And I knew better.

It's even worse than that.
Mysql using files for the table storage, and the convention being that the table name IS the file name, the tables names follow the OS case sensitivity.
Meaning that the tables names are case sensitive on unixes/bsd boxes, but case insensitive on windows.
And what is true for the tables is true for the field, in my memory.
The fields are case insensitive on windows, but case sensitive on linux.

I found out the hard way (ie, rewriting case sensitive query from a dev that did everything on windows when installing on a linux server)
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 01-03-2010, 03:20 PM Re: Inserting form fields into MySQL database
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
And what is true for the tables is true for the field, in my memory
Your memory serves you correctly.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-03-2010, 03:29 PM Re: Inserting form fields into MySQL database
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Your memory serves you correctly.
I cannot tell you, as a DBA, how much I hate literally working with mysql.
I seriously don't understand how it could gain so much traction.
Sigh...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Inserting form fields into MySQL database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41610 seconds with 12 queries