Jump to content

Database Queries not Working?


Warptweet

Recommended Posts

This ENTIRE code says it works, but yet it does absolutely NOTHING!

Can anyone tell me why the the rows are not being sent to other database tables, or not being deleted?

 

if ($_GET['cmd'] == 'admin'){
if ($_GET['acp'] == 'editdecision'){

$decision = $_POST['editentry'];

if ($decision == 'Keep Entry'){
echo "Administration Function Chosen: Keep Entry</br></br>The submission you selected has been successfully Kept in the Database, with no editing functions occuring.";
}
if ($decision == 'Decline Entry'){

$uploadid = $_POST['uploadid'];
$uploadname = $_POST['uploadname'];
$uploaddescription = $_POST['uploaddescription'];
$uploadicon = $_POST['uploadicon'];
$uploadlink = $_POST['uploadlink'];
$uploadtype = $_POST['uploadtype'];
$uploadgenre = $_POST['uploadgenre'];
$uploadstyle = $_POST['uploadstyle'];

$con = mysql_connect("localhost","warp_gm","Forest77");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("warp_gm", $con);

$qu = mysql_query("SELECT uploadname, uploadauthor,uploadid,uploaddescription,uploadlink,deleteupload FROM pending_uploads WHERE uploadid = '$uploadid'") or DIE(mysql_error());

while ($row = mysql_fetch_array($qu)) {
       mysql_query("INSERT INTO declined_uploads (uploadname, uploadauthor,uploadid,uploaddescription,uploadlink) VALUES ('$uploadname', '$uploadauthor','$uploadid','$uploaddescription','$uploadlink')") or DIE(mysql_error());

       mysql_query("DELETE FROM accepted_uploads WHERE uploadname = '$uploadname' AND uploadauthor='$uploadauthor' AND uploadid='$uploadid' AND uploaddescription = '$uploaddescription' AND uploadlink='$uploadlink' LIMIT 1");
}
mysql_close($con);

echo "Administrator Function Chosen: Decline Entry</br></br>The entry with the ID of $uploadid that was once marked as accepted and valid for Warptweet.com has not officially been deleted from the MySQL Database _gm and table accepted_uploads. Backup information and the link to this deleted upload has been stored in the MySQL Database _gm with the table name declined_uploads. OMIT: Type, Genre, Style. If a mental note or you need to write the name of the deleted upload, then please take note of the deleted uploads name: $uploadname</br></br>If there are multiple uploads with this name, you can also narrow it down by the description, if needed: $uploaddescription";
}

if ($decision == 'Pend Entry'){

$uploadid = $_POST['uploadid'];
$uploadname = $_POST['uploadname'];
$uploaddescription = $_POST['uploaddescription'];
$uploadicon = $_POST['uploadicon'];
$uploadlink = $_POST['uploadlink'];
$uploadtype = $_POST['uploadtype'];
$uploadgenre = $_POST['uploadgenre'];
$uploadstyle = $_POST['uploadstyle'];

$con = mysql_connect("localhost","warp_gm","Forest77");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("warp_gm", $con);

$qu = mysql_query("SELECT uploadname, uploadauthor,uploadid,uploaddescription,uploadlink,deleteupload FROM pending_uploads WHERE uploadid = '$uploadid'") or DIE(mysql_error());

while ($row = mysql_fetch_array($qu)) {
       mysql_query("INSERT INTO pending_uploads (uploadname, uploadauthor,uploadid,uploaddescription,uploadlink,deleteupload) VALUES ('$uploadname', '$uploadauthor','$uploadid','$uploaddescription','$uploadlink','no')") or DIE(mysql_error());

       mysql_query("DELETE FROM accepted_uploads WHERE uploadname = '$uploadname' AND uploadauthor='$uploadauthor' AND uploadid='$uploadid' AND uploaddescription = '$uploaddescription' AND uploadlink='$uploadlink' LIMIT 1");
}
mysql_close($con);

echo "The upload has been successfully sent to the Pending Database List, MySQL Database _gm and the table pending_uploads. The ID of this pending upload is $uploadid, please keep note of it. For recognition, the name is $uploadname and the description is: $uploaddescription";
}
}
}

 

I'm positive it should work, are there any errors? Because it doesn't say any errors, it looks and returns the "success" message.

Link to comment
Share on other sites

You're not checking most of the mysql_query() functions for success or failure, so how can you say that  work?

 

Each of the functions should be written something like:

<?php
$q = "INSERT INTO pending_uploads (uploadname, uploadauthor,uploadid,uploaddescription,uploadlink,deleteupload)
          VALUES ('$uploadname', '$uploadauthor','$uploadid','$uploaddescription','$uploadlink','no')";
$rs = mysql_query($q) or die("Problem with the query <pre>$q</pre><br>" . mysql_error());
?>

 

Ken

Link to comment
Share on other sites

If its on the decision == 'Keep Entry' then it would just do nothing, as the entry will stay as it is.

 

If its on the decision == 'Delete Entry' then it create a row in the table declined_uploads containing a backup of all the exact same information of the entry your deleting. After creating a backup, the entry in the accepted_uploads table is completely wiped out, leaving only a small backup row in the declined_uploads for its history.

 

if its on the decision == 'Pend Entry' then it will create the row like above, except it creates the row containing the same information on the pending_uploads table INSTEAD of the declined_uploads table. That way on my other page (which doesnt have anything to do with this right now) I can see all the pending_uploads that have been submitted. Then, it deletes the row from the accepted_uploads table, transferring all the information to the pending_uploads table

 

The output it was the echo "something here"; says after each (decision == 'something'){

No mysql errors were sent as output

Link to comment
Share on other sites

I have a few more questions.

 

1.  Is what you posted your entire script?

2.  How do you test to see if the database has been altered?

3.  What happens if you add an echo inside the while loop?  Do you get any output?  If not, it's possible your select is not returning any rows.

Link to comment
Share on other sites

NOTE: I EDITED THE SCRIPT A TINY BIT TO FIX THE TABLES, PLEASE TAKE NOTE OF THE SMALL CHANGES

Here is my entire script, including the part where you select which option for your decision...

 

if ($_GET['cmd'] == 'admin'){

if ($_GET['acp'] == 'editsubmissions'){

 

$con = mysql_connect("localhost","warp_gm","Forest77");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("warp_gm", $con);

 

$result = mysql_query("SELECT * FROM accepted_uploads ORDER BY uploadid");

 

echo "<table border='1'>

<tr>

<th>ID</th>

<th>Name</th>

<th>Description</th>

<th>Icon</th>

<th>More</th>

<th>Edit</th>

</tr>";

 

while($row = mysql_fetch_array($result))

  {

  echo "<tr>";

  echo "<td>" . $row['uploadid'] . "</td>";

  echo "<td>" . $row['uploadname'] . "</td>";

  echo "<td>" . $row['uploaddescription'] . "</td>";

  echo "<td><img src=\"" . $row['uploadicon'] . "\" width=\"100\" height=\"100\"></td>";

  echo "<td>" . $row['uploadtype'] . "  " . $row['uploadgenre'] . "  " . $row['uploadstyle'] . "</td>";

  echo "<td><form method=\"POST\" action=\"?cmd=admin&acp=editdecision\">

  <p>

  <select size=\"1\" name=\"editentry\">

  <option selected>Keep Entry</option>

  <option>Decline Entry</option>

  <option>Pend Entry</option>

  </select><input type=\"submit\" value=\"Submit\" name=\"B1\"></p>

</form></td>

<input type='hidden' name='uploadid' value='" . $row['uploadid'] . "'>

<input type='hidden' name='uploadname' value='" . $row['uploadname'] . "'>

<input type='hidden' name='uploaddescription' value='" . $row['uploaddescription'] . "'>

<input type='hidden' name='uploadicon' value='" . $row['uploadicon'] . "'>

<input type='hidden' name='uploadlink' value='" . $row['uploadlink'] . "'>

<input type='hidden' name='uploadtype' value='" . $row['uploadtype'] . "'>

<input type='hidden' name='uploadgenre' value='" . $row['uploadgenre'] . "'>

<input type='hidden' name='uploadauthor' value='" . $row['uploadauthor'] . "'>

<input type='hidden' name='uploadstyle' value='" . $row['uploadstyle'] . "'>

";

}

mysql_close($con);

}

}

if ($_GET['cmd'] == 'admin'){

if ($_GET['acp'] == 'editdecision'){

 

$decision = $_POST['editentry'];

 

if ($decision == 'Keep Entry'){

echo "Administration Function Chosen: Keep Entry</br></br>The submission you selected has been successfully Kept in the Database, with no editing functions occuring.";

}

if ($decision == 'Decline Entry'){

 

$uploadid = $_POST['uploadid'];

$uploadname = $_POST['uploadname'];

$uploaddescription = $_POST['uploaddescription'];

$uploadicon = $_POST['uploadicon'];

$uploadlink = $_POST['uploadlink'];

$uploadtype = $_POST['uploadtype'];

$uploadgenre = $_POST['uploadgenre'];

$uploadstyle = $_POST['uploadstyle'];

 

$con = mysql_connect("localhost","warp_gm","Forest77");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }mysql_select_db("warp_gm", $con);

 

$qu = mysql_query("SELECT uploadname, uploadauthor,uploadid,uploaddescription,uploadlink,deleteupload FROM pending_uploads WHERE uploadid = '$uploadid'") or DIE(mysql_error());

 

while ($row = mysql_fetch_array($qu)) {

      mysql_query("INSERT INTO declined_uploads (uploadname, uploadauthor,uploadid,uploaddescription,uploadlink) VALUES ('$uploadname', '$uploadauthor','$uploadid','$uploaddescription','$uploadlink')") or DIE(mysql_error());

 

      mysql_query("DELETE FROM accepted_uploads WHERE uploadname = '$uploadname' AND uploadauthor='$uploadauthor' AND uploadid='$uploadid' AND uploaddescription = '$uploaddescription' AND uploadlink='$uploadlink' LIMIT 1") or DIE(mysql_error());

 

echo "Administrator Function Chosen: Decline Entry</br></br>The entry with the ID of $uploadid that was once marked as accepted and valid for Warptweet.com has not officially been deleted from the MySQL Database _gm and table accepted_uploads. Backup information and the link to this deleted upload has been stored in the MySQL Database _gm with the table name declined_uploads. OMIT: Type, Genre, Style. If a mental note or you need to write the name of the deleted upload, then please take note of the deleted uploads name: $uploadname</br></br>If there are multiple uploads with this name, you can also narrow it down by the description, if needed: $uploaddescription";

}

 

mysql_close($con);

 

}

 

if ($decision == 'Pend Entry'){

 

$uploadid = $_POST['uploadid'];

$uploadname = $_POST['uploadname'];

$uploaddescription = $_POST['uploaddescription'];

$uploadicon = $_POST['uploadicon'];

$uploadlink = $_POST['uploadlink'];

$uploadtype = $_POST['uploadtype'];

$uploadgenre = $_POST['uploadgenre'];

$uploadstyle = $_POST['uploadstyle'];

 

$con = mysql_connect("localhost","warp_gm","Forest77");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }mysql_select_db("warp_gm", $con);

 

$qu = mysql_query("SELECT uploadname, uploadauthor,uploadid,uploaddescription,uploadlink,deleteupload FROM pending_uploads WHERE uploadid = '$uploadid'") or DIE(mysql_error());

 

while ($row = mysql_fetch_array($qu)) {

      mysql_query("INSERT INTO pending_uploads (uploadname, uploadauthor,uploadid,uploaddescription,uploadlink,deleteupload) VALUES ('$uploadname', '$uploadauthor','$uploadid','$uploaddescription','$uploadlink','no')") or DIE(mysql_error());

 

      mysql_query("DELETE FROM accepted_uploads WHERE uploadname = '$uploadname' AND uploadauthor='$uploadauthor' AND uploadid='$uploadid' AND uploaddescription = '$uploaddescription' AND uploadlink='$uploadlink' LIMIT 1");

 

echo "The upload has been successfully sent to the Pending Database List, MySQL Database _gm and the table pending_uploads. The ID of this pending upload is $uploadid, please keep note of it. For recognition, the name is $uploadname and the description is: $uploaddescription";

}

 

mysql_close($con);

 

}

}

}

 

NOTE: In tried putting the echo inside the while { thing, and it displayed NO output, so I guess something is wrong, except no error is displayed.

 

NOTE: I use the phpmyadmin to manually check my database rows, and I have clearly checked throughly that it isn't happening.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.