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 04-29-2012, 02:04 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 81,206
SilverDragonTears is on a distinguished road
Default Script error

I don't know how to get this to work with the new script. I've been trying since last night.

Code:
        $query = "SELECT * FROM ".$GLOBALS['prefix']."tabs WHERE username = '".$GLOBALS['username']."'";
	$result = runquery($query);
	$num = mysql_numrows($result);
__________________

Check out SilvaTales
Reply With Quote
  #2  
Old 04-29-2012, 07:17 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 81,206
SilverDragonTears is on a distinguished road
Default

Ok here is what I have so far and it isn't working LOL

Code:
function gettabs() {
$formcontent = "";
$data = $adopts->select("tabs", array("username", "name"), "username = '{$username}'")->fetchObject();
$num = count($data);

	$i=0;
	while ($i < $num) {
		$tabname=@mysql_result($data, $i,"name");
		$formcontent = $formcontent."<option value='myadopts.php?tab=".$tabname."'>".$tabname."</option>";
		$i++;
	}
	return $formcontent;
}
__________________

Check out SilvaTales
Reply With Quote
  #3  
Old 04-30-2012, 01:32 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 32,499
fadillzzz is an unknown quantity at this point
Default

Don't mix the old mysql_* functions with PDO. The two are very different.

PHP Code:
$result $adopts->select(...);
while (
$row $result->fetchObject())
{
    echo 
$row->name;

Reply With Quote
  #4  
Old 04-30-2012, 01:56 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 81,206
SilverDragonTears is on a distinguished road
Default

ok now I have this.. and still not working. Bear with me.
Code:
function gettabs() {
$formcontent = "";
$result = $adopts->select("tabs", array("username", "name"), "username = '{$username}'")->fetchObject();

	$i=0;
	while ($row = $result->fetchObject()) {
		$tabname=@mysql_result($data, $i,"name");
		$formcontent = $formcontent."<option value='myadopts.php?tab=".$tabname."'>".$tabname."</option>";
		$i++;
	}
	return $formcontent;
}
__________________

Check out SilvaTales
Reply With Quote
  #5  
Old 04-30-2012, 02:28 AM
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: 327,360
Hall of Famer is on a distinguished road
Default

First of all, you are having an issue Id refer to as 'variable scope'. You are defining a function gettab() without passing any arguments, while the variable $username is undefined as a local variable inside your function. You either have to declare $username as global variable, or pass it as an argument to your function. Read this manual from PHP for reference:
http://php.net/manual/en/language.variables.scope.php

On the other hand, you still use mysql_result() which no longer works with this new script as we are incorporating PDO. I thought Fadillzzz already explained clearly to you not to use mysql functions anymore... Now change this line:

PHP Code:
$tabname=@mysql_result($data$i,"name"); 
to

PHP Code:
$tabname=$row->name
And now the $tabname will not be malfunctioning. However I strongly recommend you to remove all lines associated with $i since its totally unnecessary.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #6  
Old 04-30-2012, 02:33 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 81,206
SilverDragonTears is on a distinguished road
Default

Ok another thing. I'm suppose to add this...
Code:
 AND ".constant("PREFIX")."owned_adoptables.tab = '{$tab}'
to the myadopts.php query... but when I do it still doesn't list the tabs.

Is this correct for functions.php?
Code:
function gettabs() {
$formcontent = "";
$result = $GLOBALS['adopts']->select("tabs", array("username", "name"), "username = '{$username}'");

	while ($row = $result->fetchObject()) {
		$tabname=$row->name; 
		$formcontent = $formcontent."<option value='myadopts.php?tab=".$tabname."'>".$tabname."</option>";
	}
	return $formcontent;
}
__________________

Check out SilvaTales

Last edited by SilverDragonTears; 04-30-2012 at 02:44 AM.
Reply With Quote
  #7  
Old 04-30-2012, 04:37 AM
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: 327,360
Hall of Famer is on a distinguished road
Default

Umm are you trying to select from multiple tables? If so, use the method join() before calling select().
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #8  
Old 04-30-2012, 05:04 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 81,206
SilverDragonTears is on a distinguished road
Default

I figured it out :D Thank you for the help!
__________________

Check out SilvaTales
Reply With Quote
  #9  
Old 04-30-2012, 03:35 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 81,206
SilverDragonTears is on a distinguished road
Default

Hmm... this pulls up everyone's tabs instead of just the logged in user

Code:
$result = $GLOBALS['adopts']->select("tabs", array("username", "name"), "username = '{$username}'");
i see why but I don't know how to fix it.


heh.
Code:
$result = $GLOBALS['adopts']->select("tabs", array("username", "name"), "username = '".$GLOBALS['username']."'");
Seems to do the trick ;)
__________________

Check out SilvaTales

Last edited by SilverDragonTears; 04-30-2012 at 03:49 PM.
Reply With Quote
  #10  
Old 05-01-2012, 02:59 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: 327,360
Hall of Famer is on a distinguished road
Default

Of course the old script wont work, didnt I tell you before that you need to worry about the variable scope issue? What is $username in your function? If you neither pass it as an argument to your function tab(), nor declare it as global variable, it will be considered an undefined variable.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
Reply

Thread Tools
Display Modes

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
Parse error: syntax error, unexpected T_STRING MikiHeart Questions and Supports 29 10-31-2013 12:46 AM
ACP Error : Fatal error: Class 'AppController' not found in... Isura Questions and Supports 39 06-17-2013 02:26 AM
PHP Error on other script. Tequila Webmasters Area 4 09-19-2012 06:38 AM
Parse error: syntax error, unexpected T_ELSE in /home/.nyles/ Saphira Questions and Supports 11 05-26-2009 11:45 AM


All times are GMT -5. The time now is 06:59 AM.

Currently Active Users: 458 (0 members and 458 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