vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Coding Problems (https://vborg.vbsupport.ru/showthread.php?t=117091)

Kirk Y 05-30-2006 12:50 AM

Coding Problems
 
I've got messages being pulled from a database and I'm trying to create an option for the other administrators to remove the messages by clicking an image. I'm using the following code:

PHP Code:

$blast_msg $db->query_read(
    SELECT * 
    FROM blastmsg
"
);
while (
$blast $db->fetch_array($blast_msg)) 
    { 
        
$user $blast['user']; 
        
$date $blast['date']; 
        
$message $blast['message']; 
        
$id $blast['blastid'];
    }
if (
$_GET['do'] == 'delete')
{
 if (!
$blast $db->query_first("SELECT blastid FROM blastmsg WHERE blastid = " intval($_GET['id'])))
 {
  eval(
standard_error(fetch_error('non_existant')));
 }
 
 
$db->query("DELETE FROM blastmsg WHERE blastid = '$id'");
 eval(
print_standard_redirect('blast_del'));  


The problem is that upon clicking the image, the wrong message is being erased.

I'm using this as the URL:
PHP Code:

<a href='blast.php?{$vbulletin->session->vars['sessionurl']}do=delete&amp;id=$id'

Thanks in advance for any ideas.

calorie 05-30-2006 01:03 AM

Your delete query is using the last ID set from the while loop instead of something like the following:
Code:

$db->query("DELETE FROM blastmsg WHERE blastid = " . intval($blast['blastid']));

Kirk Y 05-30-2006 05:02 AM

D'oh! Can't believe I missed that -- thanks Calorie.


All times are GMT. The time now is 04:23 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01439 seconds
  • Memory Usage 1,719KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete