1
cmagana
Help me, Problem with query DELETE FROM
  • 2003/12/29 8:21

  • cmagana

  • Not too shy to talk

  • Posts: 131

  • Since: 2003/11/8


Hello, I'm developing a module, but I have a problem, when I try to delete a record from certain table, my script doesn't delete the item, all the others work well: redirect and don't and it does not appear message of error.
The script is the next:

Quote:

<?php
require_once('../../../mainfile.php');
include_once(XOOPS_ROOT_PATH."/class/xoopsmodule.php");
include(XOOPS_ROOT_PATH."/include/cp_functions.php");
if ( $xoopsUser ) {
$xoopsModule = XoopsModule::getByDirname("cartelera");
if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
redirect_header(XOOPS_URL."/",3,_NOPERM);
exit();
}
} else {
redirect_header(XOOPS_URL."/",3,_NOPERM);
exit();
}
xoops_cp_header();

//Code to delete the item
$sql = sprintf("DELETE FROM %s WHERE id_horario = %s", $xoopsDB->prefix("cartelera_cat"), $_GET['horario']);
$xoopsDB->query($sql);
redirect_header("horarios.php",2,"Item deleted");

//Include the page footer
xoops_cp_footer();
?>


Please tell me where is my error, or what's bad??

2
tywick
Re: Help me, Problem with query DELETE FROM
  • 2003/12/29 8:41

  • tywick

  • Just popping in

  • Posts: 12

  • Since: 2002/9/17


It would probably work better if you actually did a mysql_query instead of sprintf. I'm sure there's other changes you'd need to do but that's a good place to start.

3
robekras
Re: Help me, Problem with query DELETE FROM
  • 2003/12/29 8:43

  • robekras

  • Documentation Writer

  • Posts: 187

  • Since: 2002/12/10


Maybe the following thread could help you

https://xoops.org/modules/newbb/viewtopic.php?topic_id=14723&forum=7#forumpost60438



4
cmagana
Re: Help me, Problem with query DELETE FROM
  • 2003/12/29 8:54

  • cmagana

  • Not too shy to talk

  • Posts: 131

  • Since: 2003/11/8


Thanks for your fast help, I only changed this
$xoopsDB->query($sql); for $xoopsDB->queryF($sql);

Thanks and happy new year 2004, greetings from Mexico

5
Mithrandir
Re: Help me, Problem with query DELETE FROM

As always when using queryF be aware how the parameter is treated and security checks before executing the code, e.g. a permissions check prior to the $xoopsDB->queryF($sql); so not just anybody can do it once they know the url for the page.

Login

Who's Online

180 user(s) are online (123 user(s) are browsing Support Forums)


Members: 0


Guests: 180


more...

Donat-O-Meter

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

Latest GitHub Commits