|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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']')"; |
|
#2
|
||||
|
||||
|
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... |
|
#3
|
|||
|
|||
|
Thanx man problem solved!!
It was the quotes... |
|
#4
|
||||
|
||||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Newbie having trouble with Insert statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|