![]() |
Damn Classes /; (the php type)
ok, im working on a vb free site and im setting up a code so that inorder to write/read a query i need to only type
PHP Code:
PHP Code:
PHP Code:
why isent this working? ill give you my current error: Quote:
Quote:
Ty in advance ~Cody Woolaver |
$this should only be used inside methods AFAIK...
*I'm still very new to OOP* |
Im new aswell ^^
umm, so, where what should i put it inside of? |
Well that function isn't even in your class, you're defining a class with no methods in it. I don't know if the below will work as I haven't tested it....nor am I an OOP guru, as I am still learning myself.
PHP Code:
|
Update of code:
PHP Code:
Quote:
Quote:
|
Your closing the class before defining any methods, you have to wrap the closing bracket "}" at the end of all you methods.
|
yeah, i had a feeling that was an answer
Updated Script PHP Code:
Quote:
Quote:
|
you can not run a function or set a var when initialzing it, except for setting it as an array. if you want to set that var as mysql_connect create a constructor function at the beginning of your class.
|
Just to build on AN-nets excellent pointer:
PHP Code:
|
so, after that, is there anyhting else i need to do? or did i have a whole bunch of shit in mine that wsent neded?
---- ok, scrap what i just said i am completely lost, can you guys amke me an example? that fully works! i want to type PHP Code:
you should see all the backup files ive made for this project.. lol.. ig to about 20... and none of em work! i just need this made, idc how much space it takes! i really need this ;) it will save me a lot of time! |
i dont know what version you are running but why not just call another instance of what ever class file vbulletin uses for mysql communication. no need to rewrite that redundant code.
|
im making another site for somone else, who dosent have vbulletin ^^
im using php version 5.0.4 |
Something along the lines of the following should (untested) work:
PHP Code:
|
your not susposed to do var $link= 0;
you are susposed to set this in a constructor function, the first function of a class just used for setting variables. I.E.: PHP Code:
|
Don't you mean
PHP Code:
And I thought all variables have to be declared(not set) outside the class? |
Here is my DB class for one of my sites.
PHP Code:
[edit]Usage being: PHP Code:
|
well yes all variables are delcared such as var $foobar; but setting them to anything other than an empty array is not allowed when not in the constructor function.
|
All times are GMT. The time now is 03:37 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|