Re: Array in a Loop Question
| From: | Erik Price | Date: | Tue, 26 Mar 2002 19:35:10 +0000 |
| Subject: | Re: Array in a Loop Question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90255@lists.php.net to get a copy of this message | ||
On Tuesday, March 26, 2002, at 02:12 PM, Jeff Hatcher wrote:
So my question is how can I put this in the database without having to reassign my variable name?You have to "jump out" of the quoted string that represents your SQL query when you echo the value of the $_POST variable. Like this: $sql = "SELECT a FROM b WHERE c='" . $_POST['d'] . "'"; Note that I 'jumped out' immediately after the singlequote mark (which you need if your value is going into a string field) by closing the double-quoted string, using the dot to append the value of the variable $_POST['d'], and then using a dot to append another double-quoted string (which contains nothing but a single quote in it). Sometimes, depending on what your variable names look like, you can just escape your variable by using braces ('{' and '}'), but I think it's just easier to use the dot do appending from string to variable value to string again. Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.com