![]() |
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']."'"; |
Ok here is what I have so far and it isn't working LOL
Code:
function gettabs() { |
Don't mix the old mysql_* functions with PDO. The two are very different.
PHP Code:
|
ok now I have this.. and still not working. Bear with me.
Code:
function gettabs() { |
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:
PHP Code:
|
Ok another thing. I'm suppose to add this...
Code:
AND ".constant("PREFIX")."owned_adoptables.tab = '{$tab}' Is this correct for functions.php? Code:
function gettabs() { |
Umm are you trying to select from multiple tables? If so, use the method join() before calling select().
|
I figured it out :D Thank you for the help!
|
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}'"); heh. Code:
$result = $GLOBALS['adopts']->select("tabs", array("username", "name"), "username = '".$GLOBALS['username']."'"); |
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.
|
I edited it before you posted... I fixed it. I'm learning slowly ;)
|
I see, still Id recommend you to pass $username as argument in function tab() instead of declaring it as superglobal variable. As you see, superglobals have security issues and I've been removing them from the core script since Mys v1.3.0 release.
|
I don't know how :(
|
All times are GMT -5. The time now is 05:32 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.