Search found 14 matches

by pinehead
Sat Feb 09, 2013 1:04 pm
Forum: PHP - Code
Topic: PHP script runs again on "view source"
Replies: 2
Views: 910

PHP script runs again on "view source"

OK,

My php code re-runs whenever i do a "view source" inside of chrome. Is this normal? I'm trying to create an access token that expires when the page loads. Problem is, when you do the viewsource it creates a new access token.

Thank,s
by pinehead
Fri Feb 08, 2013 10:46 pm
Forum: PHP - Code
Topic: Use static class here?
Replies: 3
Views: 1211

Re: Use static class here?

Yup your correct it's all working great now.
Thanks,
by pinehead
Fri Feb 08, 2013 8:16 pm
Forum: PHP - Code
Topic: Use static class here?
Replies: 3
Views: 1211

Use static class here?

I'm writing a class that allows me to send an email randomly throughout my app. basically administrator notifications to myself. I don't want to have to instantiate the class every time I want to do this so i'm using a static class. Question 1) Is this a good use of a static class? Question 2) Thoug...
by pinehead
Sun Dec 02, 2012 2:29 pm
Forum: PHP - Code
Topic: Passing SQL Object into new class
Replies: 23
Views: 5518

Re: Passing SQL Object into new class

Positive i've showed you the final code.
and the changes i made.
by pinehead
Sat Nov 10, 2012 5:49 pm
Forum: PHP - Code
Topic: Passing SQL Object into new class
Replies: 23
Views: 5518

Re: Passing SQL Object into new class

So i know it has a method 1.) because i use it throughout the other 400 lines of code i ahve 2.) here is a new instance of the db class "inside" the achievements class class Achievements { var $db; function __construct($host,$user,$password,$db) { $this->db = new MySQL($host,$user,$passwor...
by pinehead
Sat Nov 10, 2012 5:04 pm
Forum: PHP - Code
Topic: Passing SQL Object into new class
Replies: 23
Views: 5518

Re: Passing SQL Object into new class

It is an object with a query() method. In fact in a line of code just above the new achievement instance i use $db->query("select name from users"); and it works just fine.
by pinehead
Fri Nov 09, 2012 11:18 pm
Forum: PHP - Code
Topic: Passing SQL Object into new class
Replies: 23
Views: 5518

Re: Passing SQL Object into new class

Again, here is the exact code with the error message. Errors out on $sql = $this->db->query("SELECT * FROM points"); error : Call to a member function query() on a non-object class Achievements { var $db; function __construct($db) { $this->db = $db; } public function achievement($action) {...
by pinehead
Thu Nov 08, 2012 7:55 pm
Forum: PHP - Code
Topic: Passing SQL Object into new class
Replies: 23
Views: 5518

Re: Passing SQL Object into new class

Call to a member function query() on a non-object in /content/disk/sites/linuxacademy/a/classes/achievements.class.php on line 23 Added the _ on the constructor but am still receiving this error message. Line 23 is $sql = $db->query("SELECT * FROM points"); query is a method in the mysql o...
by pinehead
Wed Nov 07, 2012 8:01 pm
Forum: PHP - Code
Topic: Passing SQL Object into new class
Replies: 23
Views: 5518

Re: Passing SQL Object into new class

Exact code.. $achievements = new achievements($db); $achievements->getPointValue("1"); class Achievements { var $dbase; function _construct($db) { $this->db = $db; } function getPointValue($action) { $sql = $this->db->query("SELECT * FROM points"); while($this->db->fetcharray($sq...
by pinehead
Mon Nov 05, 2012 8:32 pm
Forum: PHP - Code
Topic: Passing SQL Object into new class
Replies: 23
Views: 5518

Re: Passing SQL Object into new class

Well, i thought but it get the following error:] PHP Fatal error: Call to a member function query() on a non-object in /content/disk/sites/linuxacademy/a/classes/achievements.class.php on line 15 Now here is the deal $db is what I pass into the following class.. Now i know db is my class because it'...
by pinehead
Sun Nov 04, 2012 7:13 pm
Forum: PHP - Code
Topic: Passing SQL Object into new class
Replies: 23
Views: 5518

Passing SQL Object into new class

I have an active mysql object that contains my conections etc.. $db->query(my query). I want to pass this object into a new class so i don't have to create the object again How would i go about passing it into the new class so it's still active? class NewClass { var $db; function __construct($db) { ...
by pinehead
Sun Nov 04, 2012 5:58 pm
Forum: PHP - Theory and Design
Topic: Point system class and db
Replies: 2
Views: 6569

Point system class and db

I'm designgin a point system for my app. Basically whenever an "action" takes place I'd like to call the class that adds points to their db. such as $achievement->completed_task('task_name') and have points added based off task_name. So two questions, how would you suggest handling this in...
by pinehead
Thu Oct 25, 2012 10:15 pm
Forum: PHP - Theory and Design
Topic: Coaching on this code
Replies: 5
Views: 9930

Coaching on this code

I wrote some code which applies a db class I wrote. This feel all sorts of wrong and was hoping I could get some guidance on layout and method of writing this better I appreciate all you highly experienced coders and thanks for taking the time to look at mine. $db = new MySQL($config['mysql_host'],$...
by pinehead
Sat Oct 13, 2012 11:56 am
Forum: PHP - Code
Topic: Call to undefined method
Replies: 1
Views: 734

Call to undefined method

I have two classes, one is my db.class.php which contains all of my sql functions. When i instaniate the class with $db instead doing it over and over and over i want to pass the object into the new class. $db = new mysql() $account = new account($db) So i pass $db into the class account which looks...