1
abrizan
Need some MySQL help
  • 2007/2/22 4:51

  • abrizan

  • Just popping in

  • Posts: 82

  • Since: 2005/11/14


I'm finally doing my first module and ran into a SQL problem i just don't understand: The DELETE FROM command just don't seem to work.

if (isset($_GET['Del'])) {
    
//delete
    
$asID$_GET['Del'];
    
$query "DELETE FROM ".$xoopsDB->prefix("tutorial_myform")." WHERE asID='$asID' ";
    
$res=$xoopsDB->query($query);
    if(!
$res) {
        
$intro_text .= "error: $query";
    } else {
        
$intro_text .= "Record removed from DB!";
    }
}


INSERT and UPDATE queries work with very similar code blocks. I really need help with this one.

2
MadFish
Re: Need some MySQL help
  • 2007/2/22 6:02

  • MadFish

  • Friend of XOOPS

  • Posts: 1056

  • Since: 2003/9/27


Maybe ($_GET['Del']) has no value? That would prevent any of this code being executed.

3
Dave_L
Re: Need some MySQL help
  • 2007/2/22 12:02

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Quote:
The DELETE FROM command just don't seem to work


What's the symptom? Are you getting the "error: $query" message?

4
abrizan
Re: Need some MySQL help
  • 2007/2/22 13:12

  • abrizan

  • Just popping in

  • Posts: 82

  • Since: 2005/11/14


So sorry for not being clear.
$_GET['Del'] is holding the id of the record to be deleted but the SQL statement never gets executed. It just throws back stuff like this:

error: DELETE FROM xoops2016_tutorial_myform WHERE asID='5'

That statement seems fine to me.

5
Dave_L
Re: Need some MySQL help
  • 2007/2/22 13:37

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Are you executing this code in response to a GET or a POST request? If GET, you'd need to use queryF instead of query. But you said that INSERT and UPDATE queries using similar code work, so maybe that's not the problem.

Print out some more info:

if(!$res) {
   
$intro_text .= "error: $query";
$errno $xoopsDB->errno();
$error $xoopsDB->error();
var_dump('after DELETE query''REQUEST_METHOD'$_SERVER['REQUEST_METHOD'], 'query'$query'errno'$errno'error'$error);
} else {
   
$intro_text .= "Record removed from DB!";
}

6
abrizan
Re: Need some MySQL help
  • 2007/2/22 14:19

  • abrizan

  • Just popping in

  • Posts: 82

  • Since: 2005/11/14


It was the queryF.
Can you recommend a good reference?
dev.xoops just don't have enough of this kinda info.

Login

Who's Online

152 user(s) are online (101 user(s) are browsing Support Forums)


Members: 0


Guests: 152


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits