function count_mysql_query($query, $hand, $reason = 'Unknown') { global $cqs; $cqs++; $err = 0; $GLOBALS['querylog'][$cqs]['T'] = xm(); $GLOBALS['querylog'][$cqs]['Q'] = $query; $GLOBALS['querylog'][$cqs]['L'] = $reason; $rez = @mysql_query($query, $hand); if ($err = @mysql_errno()) { if ($err == 1062) { return $rez; } echo '<br><b>MySQL Error ' . $err . ' occured. Trying to recover...</b><p>'; @mysql_close(); SQLConnect(); $rez = @mysql_query($query, $hand); $ere = 0; if ($ere = @mysql_errno()) { @mail('*****@*****.**', 'MySQL Error: ' . $err . ',' . $ere, $err . ',' . $ere . ' occured at ' . date('g:ia, F d (T)') . " for query:\n" . $query); die('<br><b>Could not recover. Secondary error ' . $ere . ' occured.</b>'); } } $GLOBALS['querylog'][$cqs]['T'] = xm() - $GLOBALS['querylog'][$cqs]['T']; return $rez; }
if (strcmp(getCommand(), "insertToSQL") == 0) { $nameToInsert = $_POST['username']; $passToInsert = $_POST['password']; insertToSQL($nameToInsert, $passToInsert, SQLConnect(), "LoginSystem"); } else { if (strcmp(getCommand(), "getFromSQL") == 0) { getFromSQL(SQLConnect(), "LoginSystem"); } else { if (strcmp(getCommand(), "updateSQL") == 0) { $nameToUpdate = $_POST['username']; $passToUpdate = $_POST['password']; /* needs the new ones too, deal with that later */ updateSQL($nameToUpdate, $passToUpdate, SQLConnect()); } else { if (strcmp(getCommand(), "loginCheck") == 0) { $name = $_POST['username']; $pass = $_POST['password']; loginCheck($name, $pass, SQLConnect()); } else { if (strcmp(getCommand(), "deleteFromSQL") == 0) { $name = $_POST['username']; echo $name; deleteFromSQL($name, SQLConnect()); } else { die("Invalid command."); /* die prints a message, in the bracket and exits the script */ } } } } }
function getMaxRequireIDFromDB() { SQLConnect(); $sql = "SELECT max(ID) FROM requiremanagerdb.requirement"; $result = mysql_query($sql); if (mysql_num_rows($result)) { $result = mysql_fetch_row($result); return $result[0]; } }