Hello,
Could someone please explain how I can Update a data base with this code
$link = mysql_connect("localhost", "pelicandecal", "pelsto");
mysql_select_db("pelicandecal", $link);
$result = mysql_query("UPDATE orders SET comp = '$compa', item1 = '$itema', item2 = '$itemb', item2 = '$itemc'
WHERE code = 1", $link);
but I can't Insert a new record with this code
$link = mysql_connect("localhost", "pelicandecal", "pelsto");
mysql_select_db("pelicandecal", $link);
$result = mysql_query ("INSERT INTO orders (code, comp, item1, item2, item3)
VALUES (Null, '$compa', '$itema','$itemb','$itemc' )",$link);
Thank-you very much
Addin records to msql
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Try using mysql_error() to trap any problems printing out the SQL statement might help you debug too:
Mac
Code: Select all
$link = mysql_connect('localhost', 'pelicandecal', 'pelsto') or die(mysql_error());
mysql_select_db('pelicandecal') or die(mysql_error());
$sql = "INSERT INTO orders (code, comp, item1, item2, item3) VALUES (NULL, '$compa', '$itema','$itemb','$itemc')";
echo $sql;
mysql_query ($sql) or die(mysql_error());-
birchtrees
- Forum Newbie
- Posts: 3
- Joined: Thu Sep 05, 2002 2:29 pm
Problem solved
Thanks for your help. It's working perfectly.