PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 31st, 2005, 07:27 AM
Bagolapie Bagolapie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 Bagolapie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 48 sec
Reputation Power: 0
Newbie having trouble with Insert statement

Ok so i'm having trouble with my insert statement, it adds a record to my database but it adds everything with the value zero but when I "echo" the variables jsut before the insert statement they all have their correct values, can anybody give me some advice, just started coding php on monday

INSERT INTO CLIENT_TABLE (RECEIPT_NO, INITIALS, SURNAME, LOG_NO, MODULE, DATE, AMOUNT, COST_CODE, ACCOUNT_CODE, CLIENT_TYPE)
VALUES ('$_POST['RecieptNo']', '$_POST['Initials']', '$_POST['Surname']', '$_POST['LogNo']', '$_POST['ModNo']', '$_POST['Date']', '$_POST['Amount']', '$_POST['CostCode']', '$_POST['AccountCode']', '$_POST['Client Type']')";

Reply With Quote
  #2  
Old January 31st, 2005, 08:03 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Are they integer values?
perhaps you shouldn't have them in quotes.

I've found in the past that printing array values within a string is kind of buggy... You might want to break out of the quotes... For example: "this is text ".$array['value']." more text"

You could also surround the value in {}... i personally don't like this as I find it jumbles up my code.

If you are setting your INSERT statement into a variable (like $sql), try outputting that before you submit your query...

finally, make sure you have an or die("There was an error inserting query"); statement on your mysql_query() statement...

Reply With Quote
  #3  
Old February 1st, 2005, 12:32 AM
Bagolapie Bagolapie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 Bagolapie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 48 sec
Reputation Power: 0
Thanx man problem solved!!

It was the quotes...

Reply With Quote
  #4  
Old February 1st, 2005, 07:48 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
stuff like that is hard to spot.

i often save the query to a variable and the output it for debugging purposes.
i usually output it in my die() statement.

glad you got it working

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Newbie having trouble with Insert statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT