Re: [php] INSERT INTO
| From: | Marek Kilimajer | Date: | Tue, 17 Dec 2002 11:26:12 +0000 |
| Subject: | Re: [php] INSERT INTO | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128536@lists.php.net to get a copy of this message | ||
For 40 variables I would recomend keeping them in a single array and then loop the array:
$vars['part1']='something';
$vars['part2']='something else';
foreach($vars as k => $v) {
$vars[$k]=addslashes($v);
}
John Taylor-Johnston wrote:
Yes I'm reading the FM :) http://www.php.net/manual/en/ref.mysql.php I should know this. How will I PHP this SQL into my MySQL table? INSERT INTO testals VALUES ($part1, $part2, $part3, $part4); I'm particularily concerned aboute single quotes. How do I escape them? Should I? Here is what I think is right. ----------snip---------- $myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection); $query = "INSERT INTO testals VALUES (addslashes($part1), addslashes($part2), addslashes($part3), addslashes($part4));"; mysql_query($query); mysql_close($myconnection); ----------snip---------- That's it, right? I have about 40 variables. I wanted to run the code through here before I start. Thanks, John