[thelist] MySQL Inserts

AJ McKee aj.mckee at nmtbmedia.com
Tue Jan 28 15:56:58 CST 2003


I rewrote this for you in basic php with some comments, hope it helps
but I am no php guru.

/* Enter in the name of the database server.
 This  should be a FQDN (Fully Quallified Domain Name).*/
$dbhost = "127.0.0.1";
/* Enter in the user name that you use to connect to
the database server. Ideally this should not be root */
$dbuser = "YOURUSERNAME";
/* Enter in the password we use */
$dbpass = "YOURPASSWD";
/* Enter in the name of the database that you want to use */
$dbase = "YOURDB";
/* OK now we begin the connection to the database server*/
$db = mysql_connect("$dbhost", "$dbuser","$dbpass");
/* Select the Database*/
mysql_select_db("$dbase",$db);
/*
Your query, you should specify the field names that you want to insert
into (I am guessing them here, they may not be called that in your DB).
Also have a look at using ADODB as it makes your code more portable.
*/
mysql_query("INSERT into Items
(ItemSKU,ItemName,ItemDecription,ItemCost,Category,ShippingCost,ItemID)
VALUES
('$ItemSKU','$ItemName','$ItemDescription','$ItemCost','$Category','$Shi
ppingCost','$ItemID')") or DIE (mysql_error()); // Handy to know if it
works or not

Basically if you want to insert into two tables then AFAIK use two
inserts, (but I am not too sure on this as version 4 of mysql is
out)That's about it I think, if I am wrong somebody will envitably
correct me and I apoligise now for it :-)

Aj

----------------------------------------
AJ McKee
NMTB Media
http://www.nmtbmedia.com
-----------------------------------------


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Mailscanner thanks transtec Computers for their support.




More information about the thelist mailing list