Okay, lassen Sie mich mich hier erklären:MySQL-Abfrage läuft, aber nicht läuft
Ich mache ein Online-Text-basierten Spiel. Ich habe eine Seite, wo drei Dinge passieren kann:
löschen Bisher habe ich Arbeit eine Position haben, zu schaffen. Ich löste als nächstes eine Position. Alles war gut und ich habe keine Fehler, keine Warnungen, etc .. Und als ich es ausgeführt habe, kam es zurück zum Bildschirm, der nach dem Skript zum Löschen der Position ausgeführt werden sollte. Es soll nur hierher kommen, nachdem die Abfrage ausgeführt wurde.
Nun nichts passiert ist und nach 3 Stunden versuchen Mist komme ich zu euch Jungs b/c Ich bin auf meinem letzten Bein. Ich habe immer noch keine kritischen Fehler, nichts bringt es zum Scheitern: Hier ist mein Code.
<?php
//In the include file is the connection to the db
include("library/new_library.php");
//Below is the session id, gets their position id from the DB, than grabs whether or not they can edit the company
$user_id = $_SESSION['user_id'];
$sql = "SELECT ID, PositionID FROM users WHERE ID = '$user_id'";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query))
{
$position = $row['PositionID'];
}
$sql = "SELECT * FROM tblCPositions WHERE PositionID = '$position'";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query))
{
$editCompany = $row['Edit_Company'];
}
//Next I check for position edit and if they try to put in the position id of a position the company does not control it gives them a "nice" message.
$company = $_SESSION['company'];
if($_GET['pidedit']){
$position = $_GET['pidedit'];
$sql = "SELECT * FROM tblCPositions WHERE PositionID = '$position'";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query))
{
if($row['CompanyID'] != $company)
{
$warning = "<div class='warning'>You are trying to edit a position that does not belong to your company. DO NOT TRY TO CHEAT THE SYSTEM!</div>";
}
else
{
$positionArray[] = array(ID => $row['PositionID'], name => $row['Name'], hire => $row['Hire'], fire => $row['Fire'], bid => $row['Contract'], edit => $row['Edit_Company'], finances => $row['Finances']);
}
}
}
//Here I check for $_GET delete
elseif($_GET['piddelete'])
{
$position = $_GET['piddelete'];
$sql = "SELECT * FROM tblCPositions WHERE PositionID = '$position'";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query))
{
if($row['CompanyID'] != $company)
{
$warning = "<div class='warning'>You are trying to delete a position that does not belong to your company. DO NOT TRY TO CHEAT THE SYSTEM!</div>";
}
}
}
else
{
$sql = "SELECT * FROM tblCPositions WHERE CompanyID = '$company'";
$query = mysql_query($sql);
$number = mysql_num_rows($query);
$numberLeft = 12 - $number;
while($row = mysql_fetch_assoc($query))
{
$positionArray[] = array(ID => $row['PositionID'], name => $row['Name'], hire => $row['Hire'], fire => $row['Fire'], bid => $row['Contract'], edit => $row['Edit_Company'], finances => $row['Finances']);
}
}
//
if($_POST['submitNewPosition'])
{
$name = $_POST['positionName'];
$hire = $_POST['hire'];
$fire = $_POST['fire'];
$bid = $_POST['bid'];
$edit = $_POST['edit'];
$finances = $_POST['finances'];
$cid = $_SESSION['company'];
$sql = "INSERT INTO tblCPositions(CompanyID, Name, Hire, Fire, Contract, Edit_Company, Finances) VALUES ('$cid','$name','$hire','$fire','$bid','$edit','$finances')";
$query = mysql_query($sql);
if($query)
{
header("location: view_company.php?newp=success");
}
}
//Haven't finished this section yet
if($_POST['submitEditPosition'])
{
$name = $_POST['positionName'];
$fire = $_POST['hire'];
$fire = $_POST['fire'];
$bid = $_POST['bid'];
$edit = $_POST['edit'];
$finances = $_POST['finances'];
}
//This this is my problem area, this is where it says its running the query but its not.
if(isset($_POST['deletePosition']))
{
$deleteID = $_GET['piddelete'];
$deleteSql = "DELETE FROM tblCPositions WHERE PositionID = '$deleteID'";
$deleteQuery = mysql_query($deleteSql);
if($deleteQuery)
{
header("location: view_company.php?delete=success");
}
if(!$deleteQuery)
{
header("location: view_company.php?delete=failure");
}
}
UPDATE -
Ok, so habe ich es funktioniert das Problem war etwas, das ich vergessen, diese Form wurde nur ein „ja oder nein Form“ sein soll, damit ich Post tun nur Post der Submit-Button, nichts anderes war auf dem Formular. Was ich vergessen hatte, war auf der action = "file.php" (was ich hatte) Ich hatte vergessen, die get Variable weiterzuleiten, sobald ich es in action = "file.php? Piddelete = 12" geändert hatte, funktionierte es.
Danke für die Hilfe, die ich wirklich schätze.
Muss sagen, sehr interessante Titel :) – codaddict
uhm, haben Sie wethhere überprüft error_reporting = E_ALL & ~ E_NOTICE & ~ E_DEPRECATED ist gesetzt? – lock
Ja es ist aber ich konnte mir keine andere Möglichkeit vorstellen es zu erklären, ich werde mit der Fehlermeldung zurückschreiben. – jefffan24