Preserved Topic: php/sql - how to insert into a table? (Page 1 of 1) |
|
---|---|
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 05-24-2001 18:39
this is a stupid/newbie question, but i just dont get it. i wanna insert some values into a table and im using this code: |
Paranoid (IV) Mad Scientist From: Somewhere over the rainbow |
posted 05-24-2001 19:03
The poster has demanded we remove all his contributions, less he takes legal action. |
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 05-24-2001 19:09
thanks for the quick answer, ini! it works! |
Paranoid (IV) Inmate From: other places |
posted 05-24-2001 20:27
Your code is correct, but if PHP has sent *any* text at that point, it has sent headers already. So that command has to preced any code that outputs. Including HTML outside the <?php ?> delimiters. |
Maniac (V) Mad Scientist From: Belgrade, Serbia |
posted 05-24-2001 20:52 |
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
posted 05-26-2001 22:31
Hmm, no one mentioned that InI is wrong. Well, half wrong. The single quotes are indeed necessary for the insert. But concatenating the variables is UNNECESSARY. The way you originally had it was only missing the isngle quotes. For those who don't know, you can specify strings with either single or double quotes in PHP. If you use single quotes, the string is NOT PARSED and is literally exactly what you put in it. If you use double quotes then it parses for variables and special characters, such as \n for linefeed, and \t for tab. The one thing you need to watch out for is complex variable references (ie object or variable variable references). In this case you can encase the variable reference within curly braces for it to resolve correctly. code: $obj = new Object('10');
|
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 05-26-2001 23:57 |
Paranoid (IV) Inmate From: memphis TN |
posted 05-27-2001 14:28
if you wanna redirect a page after the headers are sent you can easily echo the code: <script language="javascript">
|
Maniac (V) Mad Scientist From: Belgrade, Serbia |
posted 05-27-2001 15:46 |