Here is the code i am having problem with... the first section...just establishes a table that acts like a master record.... the second section is building a big array of inserts to make to another table that provides the detail to the master record.
For some reason that I cannot understand. The master insert works fine... and the array of inserts gets built just fine... and when I apply them via the mysql_query command... their appears no error ....results =1 as it should but the table is not updated and mysql issues no error messages.
I have never tried this before,but it does not work and i dont know why...does it have something to do with closing one query before you can start another or something like that...I do switch tables... I dont know... I have never tried to do a bunch of inserts at one time... and it looks like i am not successful now. 🙂
Oh great gurus of MYSQL hear my plea... HELP.... Show me thy great knowledge and wizardy so that i may pay homage to you. Thanks in advance
/ do the database update /
$db_host = "localhost"; // Your mySQL server host address
$db_name = "database"; // The name of the database to use
$db_user = "theguy"; // Your mySQL username
$db_pass = "password"; // Your mySQL password
$cnx = mysql_connect($db_host, $db_user, $db_pass)or die("Unable to connect to database server.");
mysql_select_db($db_name, $cnx)or die("Unable to select database.");
$sql = "INSERT INTO KPIartist SET "
."userid = '".$_POST[bbuserid]."',"
."artistalias = '".$artistalias."',"
."realname = '".$realname."',"
."picture_name = '".$picture_name."',"
."bio = '".$bio."',"
."email = '".$email."',"
."bookemail ='".$bookemail."',"
."joindate ='".date(MDY)."',"
."startdate ='".$startdate."',"
."ipaddress ='".$something."'";
$result = mysql_query($sql);
if ($result) {
/ we updated the artist ok....so lets insert the details /
/ I tried connecting again to database to do inserts and also commenting out as below...neither worked /
/ $cnx = mysql_connect($db_host, $db_user, $db_pass)or die("Unable to connect to database server.");
/ mysql_select_db($db_name, $cnx)or die("Unable to select database."); /
/ THIS IS WHERE I START BUILDING THE INSERT DETAIL ARRAY /
/ do involvement /
If ($involvement_dj) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."involvement',"."tablevalue = '"."DJ'";
If ($involvement_producer) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."involvement',"."tablevalue = '"."Producer'";
If ($involvement_mc) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."involvement',"."tablevalue = '"."MC'";
/ end of involvement */
/ do styles /
If ($s_liquidfunk) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Liquid Funk'";
If ($s_neurofunk) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Neurofunk'";
If ($s_techstep) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Techstep'";
If ($s_rollerz) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Rollerz'";
If ($s_jumpup) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Jumpup'";
If ($s_ambient)$insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Ambient-Intelligent'";
If ($s_ragga) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Ragga'";
If ($s_bristol) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Bristol'";
If ($s_darkjungle) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Dark Jungle'";
If ($s_hiphop) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Hip-Hop'";
If ($s_triphop) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Trip-Hop'";
If ($s_jazzfunk) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Jazz Funk'";
If ($s_reggae) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Reggae'";
If ($s_dancehall) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Dancehall'";
If ($s_other) $insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."styles',"."tablevalue = '"."Other'";
/ end of styles /
/ do affiliations /
for ($i=1; $i<=5; $i++) {
$temp = "affiliate_name$i";
if ($$temp)$insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."affiliations',"."tablevalue = '".$$temp."'";
$temp = "affiliate_url$i";
if ($$temp)$insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."affiliations_url',"."tablevalue = '".$$temp."'";
}
/ end of affiliations /
/ do websites /
for ($i=1; $i<=5; $i++) {
$temp = "website_name$i";
if ($$temp)$insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."websites',"."tablevalue = '".$$temp."'";
$temp = "website_url$i";
if ($$temp)$insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."websites_url',"."tablevalue = '".$$temp."'";
}
/ end of do websites /
/ do top 10 /
for ($i=1; $i<=10; $i++) {
$temp = "current_ten$i";
if ($$temp)$insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."current10',"."tablevalue = '".$$temp."'";
}
/ end of top 10 /
/ do all 10 /
for ($i=1; $i<=10; $i++) {
$temp = "alltime_ten$i";
if ($$temp)$insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."all10',"."tablevalue = '".$$temp."'";
}
/ end of all 10 /
/ do the news /
for ($i=1; $i<=5; $i++) {
$temp = "news_name$i";
if ($$temp)$insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."news',"."tablevalue = '".$$temp."'";
$temp = "news_url$i";
if ($$temp)$insertarray[]= "INSERT INTO KPIartistdetail SET "."artistalias = '".$artistalias."',"."tabletype = '"."news_url',"."tablevalue = '".$$temp."'";
}
/ end of the news /
/ Inserted this code....so that i could see that the array of inserts were being constructed right /
$num = 0;
while ($num <= count($insertarray)) {
echo $insertarray[$num]."<br>";
$num++;
} / end of checking to see that the inserts were all constructed right /
$num = 0;
while ($num <= count($insertarray)) { / do all the table inserts that i put in the array /
$result = mysql_query($insertarray[$num]);
/ Put this message in just to make sure that the results were good during debugging /
echo "this was the result".$result."here was info".mysql_info()."<br>";
if ($result) { //we are ok
}
else { //we have a problem
include($DOCUMENT_ROOT.'/html/header.php'); / Display the Header /
$feedback .= "Data base Problem 3422. Please email webmaster@gt.com ";
$feedback .= mysql_errno().": ".mysql_error()."<BR>";
echo $feedback;
exit;
}
$num++;
HERE IS THE RESULTS THAT YOU SEE WHEN THE ECHOS ARE PRODUCED which look fine to me...but do not result in an insert.
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'involvement',tablevalue = 'DJ'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'involvement',tablevalue = 'Producer'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'involvement',tablevalue = 'MC'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'styles',tablevalue = 'Liquid Funk'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'styles',tablevalue = 'Ambient-Intelligent'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'styles',tablevalue = 'Trip-Hop'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'affiliations',tablevalue = 'one'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'affiliations_url',tablevalue = 'http://kineticpixels.com'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'affiliations',tablevalue = 'two'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'affiliations_url',tablevalue = 'http://kineticpixels.com'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'websites',tablevalue = 'one'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'websites_url',tablevalue = 'http://getgrimey.com'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'websites',tablevalue = 'two'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'websites_url',tablevalue = 'http://getgrimey.com'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'current10',tablevalue = 'one'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'current10',tablevalue = 'two'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'all10',tablevalue = 'one'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'all10',tablevalue = 'two'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'news_url',tablevalue = 'http://kineticpixels.com'
INSERT INTO KPIartistdetail SET artistalias = 'Kermit',tabletype = 'news_url',tablevalue = 'http://getgrimey.com'
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result1
this was the result
Here is what the table looks like that i am inserting to.....
Field Type Attributes Null Default Extra Action
table_id int(10) UNSIGNED No auto_increment Change Drop Primary Index Unique Fulltext
artistalias varchar(50) No Change Drop Primary Index Unique Fulltext
tabletype varchar(25) Yes NULL Change Drop Primary Index Unique Fulltext
tableorder tinyint(4) No 0 Change Drop Primary Index Unique Fulltext
tablevalue text No Change Drop Primary Index Unique Fulltext
valuedesc varchar(50) Yes NULL Change Drop Primary Index Unique Fulltext
tablecheck tinyint(4) No 0 Change Drop Primary Index Unique Fulltext
With selected: Or
Indexes : [Documentation]
Keyname Type Cardinality Action Field
PRIMARY PRIMARY None Drop Edit table_id
tabletype INDEX None Drop Edit tabletype
Create an index on columns Space usage : Type Usage
Data 7,276 Bytes
Index 7,168 Bytes
Total 14,444 Bytes
Row Statistic : Statements Value
Format dynamic
Rows 201
Row length ø 36
Row size ø 72 Bytes
Next Autoindex 202