- Messages
- 5,609
- Reaction score
- 252
- Points
- 63
<?php
session_start();
ob_start();
function Submit(){
$server = ***;
$user = ***;
$password = ***;
$database = ***;
$mysqlconnection = mysql_connect($server, $user, $password);
$databaseconnection = mysql_select_db($database);
if (!$databaseconnection) {
header("Location:index.php?page=Result&error=".urlencode("Failed to Connect to Login Database"));
exit;
}
$querystring = "INSERT INTO `garrettr_Main`.`Comments` (`COM_ID` ,`AUTH_ID` ,`POST_ID` ,`DATE` ,`COMM_TITLE` ,`COMMENT` ,`ENABLED` ,`DELETED`) VALUES (NULL , '";
if(isset($_SESSION[username])){
$result0 = mysql_query("SELECT USERID FROM Logins WHERE USER_NAME='".$_SESSION[username]."'");
$row = mysql_fetch_array($result0);
$querystring .= $row[0]."', '";
}
else{
$querystring .= "0', '";
}
$querystring .= $_POST['post']."', '";
$querystring .= date('YmdHis',time())."', '";
if(isset($_POST['title'])){
$querystring .= $_POST['title']."', '";
}
else{
header("Location:index.php?page=Result&error=".urlencode("Comment Title Not Set"));
exit;
}
if(isset($_POST['comment'])){
$querystring .= $_POST['title']."', '";
}
else{
header("Location:index.php?page=Result&error=".urlencode("Comment Not Set"));
exit;
}
if(isset($_SESSION['authenticated'])){
$querystring .= "1', '0');";
}
else{
$querystring .= "0', '0');";
}
$result1 = mysql_query($querystring);
if(!$result1){
header("Location:index.php?page=Result&error=".urlencode("Insert Comment Failed"));
exit;
}
$result2 = mysql_query("UPDATE Posts SET NUM_COMS=NUM_COMS+1 WHERE POSTID='".$_GET['post']."'");
if(!isset($_GET['post'])){
header("Location:index.php?page=Result&error=".urlencode("Post Not Found"));
exit;
}
elseif(!$result2){
header("Location:index.php?page=Result&error=".urlencode("Post Update Failed").$result);
exit;
}
}
submit();
header("Location:index.php?page=Result");
ob_flush();
?>
The bold section above is behaving strangely. The query is not raising any errors. When copying the exact query and running it in PHP MyAdmin, it works without problem. When run in the browser "$result2" is false, so the query has failed. The previous two queries work without a hitch.
My initial thought was that there is a maximum to the number of queries active at once, but I could not find any information on it.
Thanks for the help!
Garrett
session_start();
ob_start();
function Submit(){
$server = ***;
$user = ***;
$password = ***;
$database = ***;
$mysqlconnection = mysql_connect($server, $user, $password);
$databaseconnection = mysql_select_db($database);
if (!$databaseconnection) {
header("Location:index.php?page=Result&error=".urlencode("Failed to Connect to Login Database"));
exit;
}
$querystring = "INSERT INTO `garrettr_Main`.`Comments` (`COM_ID` ,`AUTH_ID` ,`POST_ID` ,`DATE` ,`COMM_TITLE` ,`COMMENT` ,`ENABLED` ,`DELETED`) VALUES (NULL , '";
if(isset($_SESSION[username])){
$result0 = mysql_query("SELECT USERID FROM Logins WHERE USER_NAME='".$_SESSION[username]."'");
$row = mysql_fetch_array($result0);
$querystring .= $row[0]."', '";
}
else{
$querystring .= "0', '";
}
$querystring .= $_POST['post']."', '";
$querystring .= date('YmdHis',time())."', '";
if(isset($_POST['title'])){
$querystring .= $_POST['title']."', '";
}
else{
header("Location:index.php?page=Result&error=".urlencode("Comment Title Not Set"));
exit;
}
if(isset($_POST['comment'])){
$querystring .= $_POST['title']."', '";
}
else{
header("Location:index.php?page=Result&error=".urlencode("Comment Not Set"));
exit;
}
if(isset($_SESSION['authenticated'])){
$querystring .= "1', '0');";
}
else{
$querystring .= "0', '0');";
}
$result1 = mysql_query($querystring);
if(!$result1){
header("Location:index.php?page=Result&error=".urlencode("Insert Comment Failed"));
exit;
}
$result2 = mysql_query("UPDATE Posts SET NUM_COMS=NUM_COMS+1 WHERE POSTID='".$_GET['post']."'");
if(!isset($_GET['post'])){
header("Location:index.php?page=Result&error=".urlencode("Post Not Found"));
exit;
}
elseif(!$result2){
header("Location:index.php?page=Result&error=".urlencode("Post Update Failed").$result);
exit;
}
}
submit();
header("Location:index.php?page=Result");
ob_flush();
?>
The bold section above is behaving strangely. The query is not raising any errors. When copying the exact query and running it in PHP MyAdmin, it works without problem. When run in the browser "$result2" is false, so the query has failed. The previous two queries work without a hitch.
My initial thought was that there is a maximum to the number of queries active at once, but I could not find any information on it.
Thanks for the help!
Garrett