Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2009, 08:33 AM
Denver Jackson Denver Jackson is offline
 
Join Date: Sep 2008
Location: gsdfgdsf
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Trying to delete a value in a table row from MYSQL database........

Hi Guys,

I'm attemping to delete a value from a certain row in my database (MYSQL). I have a delete.php file which should delete the league table's on my vBulletin forum. Here is the code I have in my delete.php file:

PHP Code:
$leagueid $vbulletin->input->clean_gpc('g''id'TYPE_UINT);

 

$leagueid $db->query_write("

        DELETE FROM denver_leagues

        WHERE leagueid = 
$leagueid

"
);

$db->query_read("

SELECT * FROM `denver_results` WHERE 1

"
); 
I also have the link to delete the league's which works but doesn't delete the actual league you can still see it afterwards.

Any help is appreciated.
Reply With Quote
  #2  
Old 07-02-2009, 09:12 AM
MAORBARI MAORBARI is offline
 
Join Date: Sep 2008
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$leagueid $vbulletin->input->clean_gpc('g''id'TYPE_UINT); 

  

$leagueid $db->query_write(

        DELETE FROM denver_leagues 

        WHERE leagueid = '
$leagueid'

"
); 

$db->query_read(

SELECT * FROM `denver_results` WHERE 1 

"
); 
enjoy.
Reply With Quote
  #3  
Old 07-02-2009, 10:22 AM
Denver Jackson Denver Jackson is offline
 
Join Date: Sep 2008
Location: gsdfgdsf
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cheers for that. Just my link now I think in the template. Here it is:

<td><if condition="$leagueid"><br /><a href="http://www.MYFORUM.com/MYFORUM/delete.php?leagueid=$leagueid">Delete</a></if>

*Myforum is just an example. That is how my link is though and it don't work like delete the league after I have entered that code above in my delete.php file.
Reply With Quote
  #4  
Old 07-02-2009, 11:55 AM
MAORBARI MAORBARI is offline
 
Join Date: Sep 2008
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the code that i bring dont work?
Reply With Quote
  #5  
Old 07-02-2009, 12:45 PM
Denver Jackson Denver Jackson is offline
 
Join Date: Sep 2008
Location: gsdfgdsf
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not sure don't think so.

When I type in my template for the link - <td><if condition="$leagueid"><br /><a href="http://www.MYFORUM.com/MYFORUM/delete.php?leagueid=$leagueid">Delete</a></if>

It says (EG) http://www.MYFORUM.co.uk/MYFORUM/del...?do=leagueid=1 on the final link before you choose to delete the league.

If I entered into the delete.php file:
PHP Code:
$leagueid $vbulletin->input->clean_gpc('g''id'TYPE_UINT); 

  

$leagueid $db->query_write(

        DELETE FROM denver_leagues 

        WHERE leagueid = 1

"
); 

$db->query_read(

SELECT * FROM `denver_results` WHERE 1 

"
); 
It would then delete league 1 when I clicked delete. This means I would have to change the code everytime the leagueid changes.

There must be a way to do this so you don't have to keep changing it.
Reply With Quote
  #6  
Old 07-02-2009, 02:11 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your cleaner statement is cleaning a GET variable called 'id', not 'leagueid'. Change one or the other. Also, it isn't really good practice to call both your variable $leagueid and your query $leagueid. And, your select statement makes no sense... WHERE 1? Where *what* is 1?
Reply With Quote
  #7  
Old 07-02-2009, 02:45 PM
Denver Jackson Denver Jackson is offline
 
Join Date: Sep 2008
Location: gsdfgdsf
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can now successfully delete the leagues with this PHP Code:

PHP Code:
$leagueid $vbulletin->input->clean_gpc('g''leagueid'TYPE_UINT); 

  

$league $db->query_write(

        DELETE FROM denver_leagues 

        WHERE leagueid = 1 = 
$leagueid

"
); 

$db->query_read(

SELECT * FROM `denver_results` WHERE 1 

"
); 
The only problem is I wanted a confirmation page when you click the delete button. At the moment it just appears "You have successfully deleted this league".
Reply With Quote
  #8  
Old 07-02-2009, 03:22 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know what you mean by confirmation page. If you want it so they have to first be told something like "You are trying to delete xxx from the database, are you sure you want to?" then you should have another do=whatever in your page to do that.

Also, this makes no sense:
PHP Code:
WHERE leagueid $leagueid 
And, I still don't know what you think you are doing here:
PHP Code:
SELECT FROM `denver_resultsWHERE 1 
Reply With Quote
  #9  
Old 07-02-2009, 03:25 PM
Denver Jackson Denver Jackson is offline
 
Join Date: Sep 2008
Location: gsdfgdsf
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It makes no sense but somehow it works. I don't know how but it just does

The second code I don't know what that is for but I think it makes it work.

Yes I mean they have to be first be told. In which page the delete template?
Reply With Quote
  #10  
Old 07-02-2009, 10:14 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Denver Jackson View Post
Yes I mean they have to be first be told. In which page the delete template?
You need to have a new do in that page. When they first click the link, they would click it to do=confirm and then the action for the form on that page would be do=delete
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:25 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07654 seconds
  • Memory Usage 2,269KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete