thepalace1 Posted March 29, 2007 Share Posted March 29, 2007 Can anyone give any pointers on the following code below. What is happening is 2 dumplicate records are inserting into my mysql database when i only want it to insert once, Its the $sqlquery8 that is duplicating twice rather than once. Any help much welcomed Thanks in advance David <?php require_once('../Connections/cpyorkshir.php'); ?> <?php if (!isset($_GET['fn'])) { $fnn = ""; } if (isset($_GET['fn'])) { $fnn = $_GET['fn']; } //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "login.php?code=You are logged out"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php?code=You must login for access"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; header("Location: ". $MM_restrictGoTo); exit; } mysql_select_db($database_cpyorkshir, $cpyorkshir); $query_Recordset1 = "SELECT * FROM users"; $Recordset1 = mysql_query($query_Recordset1, $cpyorkshir) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); mysql_select_db($database_cpyorkshir, $cpyorkshir); $query_uploadTypesRS = "SELECT * FROM uploadTypes"; $uploadTypesRS = mysql_query($query_uploadTypesRS, $cpyorkshir) or die(mysql_error()); $row_uploadTypesRS = mysql_fetch_assoc($uploadTypesRS); $totalRows_uploadTypesRS = mysql_num_rows($uploadTypesRS); mysql_select_db($database_cpyorkshir, $cpyorkshir); $query_nextnum = "SELECT * FROM nextimage"; $nextnum = mysql_query($query_nextnum, $cpyorkshir) or die(mysql_error()); $row_nextnum = mysql_fetch_assoc($nextnum); $totalRows_nextnum = mysql_num_rows($nextnum); $nn = $totalRows_nextnum + 1; mysql_select_db($database_cpyorkshir, $cpyorkshir); $query_nextnum2 = "SELECT * FROM items"; $nextnum2 = mysql_query($query_nextnum2, $cpyorkshir) or die(mysql_error()); $row_nextnum2 = mysql_fetch_assoc($nextnum2); $totalRows_nextnum2 = mysql_num_rows($nextnum2); $nn2 = $totalRows_nextnum2 + 1; //UPDATE NEXT NUM function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } mysql_select_db($database_cpyorkshir, $cpyorkshir); $wrt = "written"; $sqlquery7 = "INSERT INTO nextimage VALUES('$wrt')"; $results7 = mysql_query($sqlquery7); mysql_select_db($database_cpyorkshir, $cpyorkshir); $desc = $_SESSION['MM_description']; $ut = $_SESSION['UpType']; $un = $_SESSION['MM_Username']; $yy = "N/A"; $yu = $_SESSION['upfile']; $sqlquery8 = "INSERT INTO items VALUES ('$desc', '$ut', '$un', '$yu', '$nn2', '$yy', '$yy', '$yy', '$yy', '$yy')"; $results8 = mysql_query($sqlquery8); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Palace Archives</title> <meta name="resource-type" content="document"> <meta name="classification" content="Sports"> <meta name="description" content="A community built archive of the history of Crystal Palace Football Club."> <meta name="keywords" content="Crystal Palace, Eagles, Glaziers, Selhurst Park, Simon Jordan, SE25, Archives, CPFC, Palace Archives, Pictures, Audio, Articles"> <meta name="distribution" content="Global"> <meta name="rating" content="Safe For Kids"> <meta name="copyright" content="Palace Archives"> <meta name="author" content="David Curtis"> <meta http-equiv="reply-to" content="[email protected]"> <meta name="language" content="English"> <meta name="doc-rights" content="Copyrighted Work"> <link rel="stylesheet" type="text/css" href="style.css"> <link href="css/style.css" rel="stylesheet" type="text/css"> <link href="css/PA.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- #Layer1 { position:absolute; left:163px; top:72px; width:260px; height:23px; z-index:1; } .style1 { color: #FFFFFF; font-weight: bold; } #Layer2 { position:absolute; left:214px; top:212px; width:510px; height:118px; z-index:2; } .style2 { font-size: 16px; font-weight: bold; color: #FF0000; } .style5 {color: #FF0000} --> </style> </head> <body leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" bgcolor="#ffffff"> <div id="Layer1"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td><form action="searchresults.php" method="POST" name="searchForm" id="searchForm"> <label></label> <div align="center"> <p align="left"><span class="style1">Search:</span> <input name="Input3" type="text" class="small" value="Search Terms" size="15" /> <input name="Submit2" type="submit" class="small" value="Search"></p> </div> <input type="hidden" name="MM_insert" value="searchForm"> </form></td> </tr> </table> </div> <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%"> <tr> <td width="50%" background="images/bg.gif"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td> <td valign="bottom" background="images/bg_left.gif"><img src="images/bg_left.gif" alt="" width="17" height="16" border="0"></td> <td valign="top"> <table border="0" cellpadding="0" cellspacing="0" width="780"> <tr> <td><img src="images/top.jpg" width="780" height="109" alt="" border="0"></td> </tr> </table> <table width="780" height="25" border="0" cellpadding="0" cellspacing="0"> <tr> <td><div align="center"><script type="text/javascript" src="http://impgb.tradedoubler.com/imp?type(js)pool(102227)a(1326892)" charset="ISO-8859-1"></script><script type="text/javascript"> var uri = 'http://impgb.tradedoubler.com/imp?type(js)pool(102221)a(1326892)' + new String (Math.random()).substring (2, 11); document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>'); </script><script type="text/javascript" src="http://impgb.tradedoubler.com/imp?type(js)pool(102228)a(1326892)" charset="ISO-8859-1"></script> </div></td> </tr> </table> <table width="780" border="0" cellpadding="0" cellspacing="0"> <tr> <td><div align="center" class="style2"> <a href="index.php"><img src="images/homebtn.gif" alt="Home" width="99" height="20" border="0"></a><a href="members.php"><img src="images/membersbtn.gif" alt="Members Area" width="99" height="20" border="0"></a><a href="http://forum.palacearchives.co.uk" target="_blank"><img src="images/forumsbtn.gif" alt="Forums" width="99" height="20" border="0"></a><a href="search.php"><img src="images/search.gif" alt="Search Archives" width="99" height="20" border="0"></a><a href="contact.php"><img src="images/contact.gif" alt="Contact Us" width="99" height="20" border="0"></a></div></td> <? $ptf = "http://www.palacearchives/uploads/"; $ptf = $ptf .$fnn; ?> </tr> </table> <div align="center" class="searchpager"> <p><span class="style2"><? echo $_SESSION['MM_Username'];?></span> upload station. <a href="<?php echo $logoutAction ?>">[Logout]</a></p> <p class="size08">Thank you for contributing to Palace Archives - Your upload has been added to the database, however, we will screen this upload for quality purposes. You may have to wait until this upload has been authorised. </p> <table width="606" border="0" cellspacing="3" cellpadding="0"> <tr> <th width="211" class="form02" scope="row">Description</th> <td width="386" class="form02"><div align="left"><? echo $_SESSION['MM_description'] ?> </div></td> </tr> <tr> <th class="form02" scope="row">Uploaded By </th> <td class="form02"><div align="left"><? echo $_SESSION['MM_Username'] ?></div></td> </tr> <tr> <th class="form02" scope="row">Path To File </th> <td class="form02"><div align="left"><a href="audio.php?atp=<? echo $_SESSION['upfile'];?>"><? echo $_SESSION['upfile'];?></a></div></td> </tr> </table> <p align="left" class="bodytextlink"> </p> <p><a href="audioupload.php">Upload More Audio</a> <a href="upload.php">Different Upload </a></p> <p>We will instantly delete any materials deemed;</p> <p class="small_blue">Non Palace Related - Obstructive - Obscene - Racial - Bad Humoured - Material With Copyrite Infingements and anything else we deem unsuitable for this family enabled site. </p> <form name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <input name="descriptionf" type="hidden" id="descriptionf"> <input name="uploadedbyf" type="hidden" id="uploadedbyf"> <input name="pathf" type="hidden" id="pathf"> <input name="id" type="hidden" id="id"> <input name="s1" type="hidden" id="s1"> <input type="hidden" name="MM_insert" value="form1"> </form> <p> </p> </div> </td> <td valign="bottom" background="images/bg_right.gif"><img src="images/bg_right.gif" alt="" width="17" height="16" border="0"></td> <td width="50%" background="images/bg.gif"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td> </tr> </table> </body> </html> <?php mysql_free_result($Recordset1); mysql_free_result($uploadTypesRS); mysql_free_result($nextnum); ?> Link to comment https://forums.phpfreaks.com/topic/44845-can-anyone-help-on-this-code/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.