I'm having problems with the following function:
It works only about a quarter of the time.
Usually it gives the following errors, but the row is in fact created:
error
uplicate entry '!test' for key 2
rows affected:-1
Last inserted record has id 0
Max of CID:157
Also it seems more likely to work when I run the PHP page from Netscape instead of Explorer. I don't know if that's just coincidence.
What am I doing wrong???
Code:
Function Commit_Company ($uid, $company, $description, $address, $city,
$province, $postalcode, $country, $web, $print, $online, $radio, $venue)
{
global $hostname, $password, $user;
mysql_connect($hostname,$user,$password);
mysql_select_db("HIV");
$result = mysql_query("INSERT INTO Media (Company, Description, Address,
City, State, PostalCode, Country, Web, Print, Online, Radio, Venue)
VALUES ('$company', '$description', '$address', '$city',
'$province', '$postalcode', '$country', '$web',
'". ($print=="on" ? "-1" : "0"). "',
'". ($online=="on" ? "-1" : "0"). "',
'". ($radio=="on" ? "-1" : "0"). "',
'". ($venue=="on" ? "-1" : "0"). "');");
echo"<BR>error:";
printf(mysql_error());
echo"<BR>rows affected:";
printf(mysql_affected_rows());
echo"<BR>";
printf("Last inserted record has id %d\n", mysql_insert_id());
$new_cid = mysql_insert_id();
$lastID = mysql_query("SELECT max(Media.CompanyID) as CID FROM Media");
echo"<BR>Max of CID:";
printf(mysql_result($lastID,0,"CID"));
$state = "CreateContact";
/*Contact_Form($state,$blank,$new_cid);*/
}
It works only about a quarter of the time.
Usually it gives the following errors, but the row is in fact created:
error

rows affected:-1
Last inserted record has id 0
Max of CID:157
Also it seems more likely to work when I run the PHP page from Netscape instead of Explorer. I don't know if that's just coincidence.
What am I doing wrong???