HELP-DELETE SOMETHING

Hi,
I am editing a webtester page, and there’s a reports page, on which I display reports using:

[php]
$resultsSQL=‘SELECT * FROM Results LEFT JOIN Tests ON Results.TestID=Tests.ID WHERE Tests.Creator =’’ . $_SESSION[‘loggedInName’] . ‘’’;
[/php]

To delete a report, I tried a few different ways, none of which work:

When I used:

[php]
$resultsSQL = “DELETE FROM Results WHERE ID=” . $_POST[‘delete’][$i];
[/php]

the webpage said:

Invalid Query: DELETE FROM Results WHERE ID= - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1

When I used:

[php]
$resultsSQL = ‘DELETE FROM Results LEFT JOIN Tests ON Results.TestID=Tests.ID WHERE Tests.Creator =’’ . $_SESSION[‘loggedInName’] . ‘’’;
[/php]

the webpage said:

Invalid Query: DELETE FROM Results LEFT JOIN Tests ON Results.TestID=Tests.ID WHERE Tests.Creator =‘jsherman’ - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘LEFT JOIN Tests ON Results.TestID=Tests.ID WHERE Tests.Creator =‘jsherman’’ at line 1

And I tried:

[php]
$resultsSQL = ‘DELETE FROM Results LEFT JOIN Tests ON Results.TestID=Tests.ID WHERE ID=’ . $_POST[‘delete’][$i];
[/php]

and again the webpage said:

Invalid Query: DELETE FROM Results LEFT JOIN Tests ON Results.TestID=Tests.ID WHERE ID= - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘LEFT JOIN Tests ON Results.TestID=Tests.ID WHERE ID=’ at line 1

Any idea what I can do?
Do you need to see more code to help?

Thank you

I would personally change the first example to this:

[php]var_dump($_POST[‘delete’][$i]); //this will output the value - make sure it’s what you’re expecting!
//$resultsSQL = “DELETE FROM Results WHERE ID=’” . $_POST[‘delete’][$i] . “’”;[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service