[php] INSERT INTO
| From: | John Taylor-Johnston | Date: | Tue, 17 Dec 2002 07:12:20 +0000 |
| Subject: | [php] INSERT INTO | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-128517@lists.php.net to get a copy of this message | ||
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