Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2012, 03:45 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,460
SilverDragonTears is on a distinguished road
Default Delete query deletes from all usesrs

Why does this
Code:
function getdeltabs() {
$formcontent = "";

$result = $GLOBALS['adopts']->select("tabs", array("username", "name"), "username = '".$GLOBALS['username']."'");

	while ($row = $result->fetchObject()) {
		$tabname=$row->name; 
		$formcontent = $formcontent."<option value='".$tabname."'>".$tabname."</option>";
		$i++;
	}
	return $formcontent;
}
delete all the users tabs when one person deletes a single tab?
__________________

Check out SilvaTales
Reply With Quote
  #2  
Old 05-11-2012, 11:56 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,460
SilverDragonTears is on a distinguished road
Default

bump. Ideas, friends?
__________________

Check out SilvaTales
Reply With Quote
  #3  
Old 05-14-2012, 06:36 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,460
SilverDragonTears is on a distinguished road
Default

The problem is in this code not the above code:
Code:
elseif (isset($_POST['deltab'])) {
$name = $_POST['name'];
$query = "SELECT * FROM ".constant("PREFIX")."tabs WHERE username='".$loggedinname."' AND name='".$name."'";
		$stmt = $adopts->query($query);
$num = $stmt->fetch(PDO::FETCH_ASSOC);

if($num == 0){
$article_content='This cage does not exist.';
}else{


$adopts->update("owned_adoptables", array("tab" => ''), "owner='{$loggedinname}' and tab='{$name}'");
$adopts->delete("tabs", array(), "username='{$loggedinname}' and name='{$name}'");
$article_content='You successfully deleted the tab. Your hamster was automatically moved to your default cage at the <a href="myadopts.php">My Hamsters</a> page.';
}
__________________

Check out SilvaTales
Reply With Quote
  #4  
Old 05-14-2012, 07:32 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 335,281
Hall of Famer is on a distinguished road
Default

First of all your script has a problem with the usage of $num. It is an array fetched using a PDO method, and you are checking if its value equals to 0? An array cannot equal to 0 unless it contains only one element(which is considered a string instead), the statement will always evaluate to be false...

On the other hand, you are using the delete() method incorrectly. It does not accept an empty array as its second argument, so get rid of it. I am surprised that you do not receive an error message for the way you use delete().
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #5  
Old 05-14-2012, 07:33 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,460
SilverDragonTears is on a distinguished road
Default

So what would that look like?
__________________

Check out SilvaTales
Reply With Quote
  #6  
Old 05-14-2012, 07:34 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 335,281
Hall of Famer is on a distinguished road
Default

This should suffice:

PHP Code:
$adopts->delete("tabs""username='{$loggedinname}' and name='{$name}'"); 
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #7  
Old 05-14-2012, 07:40 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,460
SilverDragonTears is on a distinguished road
Default

Ahhh works like a dream. Thought it would look like that but I didn't realize you didn't have to have the array() there.
__________________

Check out SilvaTales
Reply With Quote
  #8  
Old 05-14-2012, 07:47 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 335,281
Hall of Famer is on a distinguished road
Default

Well you can always browse through the existing script files, including those in admincp, classes and functions directories. There should be plenty of examples that tell you how to use a database method such as update() and delete().
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #9  
Old 05-14-2012, 07:49 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,460
SilverDragonTears is on a distinguished road
Default

I do.... must not have come across those O.o
__________________

Check out SilvaTales
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Query: COUNT(*) Kyttias Questions and Supports 5 01-19-2015 03:57 AM
CSS Query .-. ChibiMaestro Templates and Themes 2 12-08-2012 05:51 AM
Having a problem running a query !Alive Questions and Supports 8 03-11-2012 02:39 PM
MySQL Query Empty on default install? (i.e. No edits.) Flametail Questions and Supports 3 10-18-2011 12:30 PM
Join query for optimization? Arianna Questions and Supports 2 04-09-2010 12:32 PM


All times are GMT -5. The time now is 06:07 PM.

Currently Active Users: 9383 (0 members and 9383 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636