Jump to content

Will not insert data


josephman1988

Recommended Posts

Hi, I dunno why but all of a sudden this script wont work.

 

The following is the code for the parts of the form in question then the query.

<?php

$result3 = mysql_query( "SELECT * FROM consoles LEFT JOIN portedto ON (cId=consolescId AND gamesgId=$gId)" );
while ( $row3 = mysql_fetch_assoc( $result3 ) ) {
     if ( !empty( $row3["gamesgId"] ) ) { $checked3 = " checked=\"checked\""; } else { $checked3 = ""; }
     print "<input type=\"checkbox\" name=\"portedto[".$row3["cId"]."]\" ".$checked3." /> ".$row3["cName"]."<br />";
}

?>


</div>
</div>
<div id="adminconsolecheckbox3">
<strong>Included In</strong><br />
<div id="formupload3">
<?php


$result4 = mysql_query( "SELECT * FROM included LEFT JOIN includedgamesconnect ON (iId=includediId AND gamesgId=$gId)" );
while ( $row4 = mysql_fetch_assoc( $result4 ) ) {
     if ( !empty( $row4["gamesgId"] ) ) { $checked4 = " checked=\"checked\""; } else { $checked4 = ""; }
     print "<input type=\"checkbox\" name=\"included[".$row4["iId"]."]\" ".$checked4." /> ".$row4["iTitle"]."<br />";
}

?>

 

<?php

if (isset($_POST['Submit'])) 
    { 
mysql_query( "DELETE FROM subseriesgamesconnect WHERE gamesgId=$gId" ); 
foreach( $_POST['subseries'] as $subseries => $value ) { 
    if ( $value == "true" ){
       mysql_query("INSERT INTO subseriesgamesconnect (`subseriessId`, `gamesgId`) VALUES ( '$subseries', '$gId' )");  
}
}
        
mysql_query( "DELETE FROM originalrelease WHERE gamesgId=$gId" ); 
foreach( $_POST['originalrelease'] as $originalrelease => $value2 ) { 
    if ( $value2 == "true" ) { 
       mysql_query("INSERT INTO originalrelease (`consolescId`, `gamesgId`) VALUES ( '$originalrelease', '$gId' )");  
	}
        } 
mysql_query( "DELETE FROM portedto WHERE gamesgId=$gId" ); 
foreach( $_POST['portedto'] as $portedto => $value3 ) { 
    if ( $value3 == "true" ) {
       mysql_query("INSERT INTO portedto (`consolescId`, `gamesgId`) VALUES ( '$portedto', '$gId' )") or die(mysql_error());  

        } 
	}
mysql_query( "DELETE FROM includedgamesconnect WHERE gamesgId=$gId" ); 
foreach( $_POST['included'] as $included => $value4 ) { 
    if ( $value4 == "true" ) {
       mysql_query("INSERT INTO includedgamesconnect (`includediId`, `gamesgId`) VALUES ( '$included', '$gId' )") or die(mysql_error());  

	}
	}
$gJDate = $_POST['gJDateDay'] . "/" . $_POST['gJDateMonth'] . "/" . $_POST['gJDateYear'];
$gADate = $_POST['gADateDay'] . "/" . $_POST['gADateMonth'] . "/" . $_POST['gADateYear'];
$gEDate = $_POST['gEDateDay'] . "/" . $_POST['gEDateMonth'] . "/" . $_POST['gEDateYear'];

$gTitle = $_POST['gTitle'];
$gDevelopment = $_POST['gDevelopment'];
mysql_real_escape_string($gJDate);
mysql_real_escape_string($gADate);
mysql_real_escape_string($gEDate);
mysql_real_escape_string($gTitle);
mysql_real_escape_string($gDevelopment);
$sql5 = mysql_query("UPDATE games SET gTitle = '$gTitle', gJDate = '$gJDate', gEDate = '$gEDate', gADate = '$gADate', 
					gDevelopment = '$gDevelopment' WHERE gId = $gId");


}

?>

 

Ok so the queries:

mysql_query( "DELETE FROM portedto WHERE gamesgId=$gId" ); 
foreach( $_POST['portedto'] as $portedto => $value3 ) { 
    if ( $value3 == "true" ) {
       mysql_query("INSERT INTO portedto (`consolescId`, `gamesgId`) VALUES ( '$portedto', '$gId' )") or die(mysql_error());  

        } 
	}
mysql_query( "DELETE FROM includedgamesconnect WHERE gamesgId=$gId" ); 
foreach( $_POST['included'] as $included => $value4 ) { 
    if ( $value4 == "true" ) {
       mysql_query("INSERT INTO includedgamesconnect (`includediId`, `gamesgId`) VALUES ( '$included', '$gId' )") or die(mysql_error());  

	}
	}

 

Just dont work at all. If i enter the queries into the php myadmin method, it works fine, but hwhen i re - enter the form it deletes the data but then doesnt re-write the newly checked boxes.

 

Whats happened?

Link to comment
https://forums.phpfreaks.com/topic/122457-will-not-insert-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.