Jump to content

DocSeuss

Members
  • Posts

    73
  • Joined

  • Last visited

    Never

Posts posted by DocSeuss

  1. You can use mysql in an OO way, based on your error message it's sounds like to me it problem is in the code that uses this class rather than the class itself. Maybe something like

    $mydbobject = new mysql();
    

     

    which should be fine(I don't think that mysql by it's self is reserved), but it would be a problem since the class is actually named "db".

  2. I simply used a bit of code to demonstrate the use of the split function. I just assigned the variable to a static string value, you of course would have to derive the value as needed for your specific application.

     

    As you move forward in the learning process it will be rare to get someone to show you exactly the answer to your specific problem. More often than not they will point you to or give you the tools/info neccessary to accomplish the task.

  3. come on now, I'm not gonna make any bad comments here but your are trying to be at least a hobby programmer right?

    Both solutions above will work with any input string they simple break the string into parts via the split or the explode function. Though I have to admit the documentation does say that explode is a better choice than split if you do not need to use regular expressions.

  4. 1) I would create the database object once in my main code and pass a reference to it to any other classes they may need to use a db connection.

    2) I would move the actual connecting of the database out of the contruct and put into a child function.

    3) this would be a non issue.

     

    Code may look something like this.

    $mydbobject = new database($server,$user,$pass,$database,$prefix = ''); // create a database object.
    $mydbobject->connect(); // connection member funtion inside database class only called once. 
    $myuserobject = new user(); // create a user object.
    $login = $user->login($name, $pass, $mydbojbect); // call member function login of user class and do login logic. In this example it would return some message.
    

     

    There are many ways to go about it just try to think of a class as an object. There is nothing wrong with an object using another object. I'm sure you have read about the popular bicycle example when reading about OOP. Imagine if you also had a surface object, it could be a road, dirt trail, grass field, ect.. You wouldn't  have the bicycle extend the surface object in order to move on it.

  5. Whatever you PHP/Database/Ajax needs are from a little login script to an Enterprise application I would very much like to work with you. Email me your project details for a quick fair quote. A current example of my work is at www.fantasyrtv.com/demo. It's showcases my specialty of data driven websites with alot of cool Ajax functionality.

     

    Mike

    docseussman@hot.rr.com

     

     

  6. LOL chronister,

    Understand the frustration, everyone on this board has been there. It's alot like the new guy coming into your restaurant and looks at you will a blank stare when you use words and phrases like Back of House, happy campers, cowboy chef, shoemaker, and my favorite the Chinese Microwave. He has no clue what your talking about.

     

    Anyway when you use the 'at symbol' @ in php it will suppress(prevent reporting) any errors the expression following it may throw. It is a very rare circumstance that you would do this, especially when your developing code. Hard to fix errors if you suppressed them and don't know what they are. I would go so far as to say someone learning PHP should never use it. 

  7. Well sure that would work, but if the purpose of the method is to be called from an instance of the object why wouldn't you just want to make it public anyway? The whole purpose of making a function or variable protected or private is because you don't want them to be directly accessed. If the logic of your class is that you(or anyone using your class) should be able to call $obj->work() to print out the line then by design the method should be public.

    Just sounds like your creating a second public class to call a protected one for no reason. It's not necessary to protect a method just because you can. 
  8. By declaring your method definition as protected it is not usable outside the class(or it's children). If you want to implement the method in code that would need access then it needs to be declared public.

    Amendem: The abstract protected is fine in the Manager class.
  9. Sup everyone, need people to beta test my website. www.tvbettor.com. Don't let the bettor throw you off the site is 100% free. Just need some people to help find any errors in my php code, and maybe some feedback on the look and feel.


    Thanks in advance,
    Doc
  10. Well at the top of your page you are checking if the cookie is set and if it is the user gets sent to the page. No way to prevent this if the cookie is set. You can set a link on those pages that would allow the user to click it which would take them to a page to delete the cookie then redirect to the lang selection page..
  11. $_REQUEST is the superset of $_GET, $_POST, and $_COOKIE

    to expand on my answer when variables are send via a form you can't access them directly by just using $varname

    your have to use $_POST(assuming the method of your form was post) or you can use $_REQUEST which has access to all $_POST vars.

    ahh you posted while I was typing, just want to verify you would make those changes on the line the CALLS the function not in the function definition you can keep those the same.


    $_REQUEST['varname'] will yield the same result as $_POST['varname']

    Now I'm sure there is an argument somewhere on all sides of the debate to say you should use one or the other but when it really comes down to it, it is just preference.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.