vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Trying to delete a value in a table row from MYSQL database........ (https://vborg.vbsupport.ru/showthread.php?t=217662)

Denver Jackson 07-02-2009 08:33 AM

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.

MAORBARI 07-02-2009 09:12 AM

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.

Denver Jackson 07-02-2009 10:22 AM

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.

MAORBARI 07-02-2009 11:55 AM

the code that i bring dont work?

Denver Jackson 07-02-2009 12:45 PM

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.

Lynne 07-02-2009 02:11 PM

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?

Denver Jackson 07-02-2009 02:45 PM

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".

Lynne 07-02-2009 03:22 PM

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 


Denver Jackson 07-02-2009 03:25 PM

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

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?

Lynne 07-02-2009 10:14 PM

Quote:

Originally Posted by Denver Jackson (Post 1841470)
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


All times are GMT. The time now is 12:22 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.01046 seconds
  • Memory Usage 1,749KB
  • 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
  • (6)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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