Jump to content

vicodin

Members
  • Posts

    279
  • Joined

  • Last visited

    Never

Posts posted by vicodin

  1. I would love to help you but I am having trouble understanding what your problem is. Also your code is not very readable. Can you please name your variables to something relevant so everyone knows exactly what that variable is... and also please tab your code correctly so its more readable.

  2. Here is an example of my DB connect class.

     

    
    Class DBConnect{
    var $user = 'username';
    var $pass = 'password';
    var $db = 'mydb'; 
    var $server = 'localhost';
    
    Private Function setServer($server){
    $this->server = $server;
    }
    
    Function setUser($user){
    $this->user = $user;    
    }
    
    Function setPass($pass){
    $this->pass = $pass;
    }
             
    Function setDb($db){
        $this->db = $db;
    }         
    
    Function openCon(){
    mysql_connect($this->server,$this->user,$this->pass);
    mysql_selectdb($this->db);
    }
             
      } #End Class
      ?>
    

     

    It would be used like this.

     

    $con = new DBConnect();
    $con->openCon();

     

    If I need to change any of the settings you can use the set Functions like this.

     

    $con = new DBConnect();
    $con->setServer("Host2")
    $con->setUser("User2");
    $con->setPass("Pass2");
    $con->setDb("DB2");
    $con->openCon();
    

     

     

  3. Your not way way off like this guy just said, but your off.... I haven't tested the other class's in your code but you def not utilizing your own method correctly.

     

    Change this:

    $login = new login();
        $login->loginAction = $_POST["username"];
                $login->loginAction = $_POST["password"]; 
                $login->loginAction = 1; 
    

     

    To this:

     

    $login = new login();
        $login->loginAction($_POST["username"],$_POST["password"],1);
    
    
    

     

    Also your DB Connection Class is way way over kill. Your jumping all around you class when you could get everything done on a few functions.

     

  4. First and foremost you need to be more careful when creating any type of form that will be inserting info into the DB. As your code stands right now I could sql inject into your database and do whatever I want.

     

    Change it to this...

    $upid = mysql_real_escape_string($_POST[idf]);
    $uptitle = mysql_real_escape_string($_POST[title]);
    $upnews = mysql_real_escape_string($_POST[news]);
    $upimage = mysql_real_escape_string($_FILES['userfile']['name']);
    

     

    We need to find out if theres an error going on in mysql. Change this: mysql_query($sql);

     

    To:

    mysql_query($sql) or die (mysql_error());
    

  5. I thought the same way as you when I had procedural programing down pat but was not very skilled in OOP. I put off mastering OOP for a long time and now I realize that was a mistake. I write anything that's gonna be over 30 lines in OOP now. In the end it becomes so much more manageable to update and I can stop working on it for months and when I come back to work on it im not spending hours of time wondering where i left off. The extra time it takes to code in OOP for you will be well worth the experience and headaches down the road.

  6. I really dont know of a good way to do this... what i would do is convert it to a unix time stamp and then find out how much each timezone is off from my current time zone. So like if my current time of my server is 1300103485 and i know the next timezone over is an hour less so 1 hour converted to seconds is 3600 seconds. 1300103485 - 3600 = 1300099885. That converts from unix time stamp to: Mon, 14 Mar 2011 10:51:25 GMT. There is probably a more effective way to do it but thats all I got.

  7. Hey, So what im trying to do is put my database variables into a session array. So this is what im trying to accomplish...

     

    $_SESSION['Name_of_Row'] = $value

     

    This is the script I wrote:

     

    Function setupSession(){
    session_start();
    $query = "SELECT * FROM users WHERE u_id ='{$this->u_id}'";
        $result = mysql_query($query);
            $row = mysql_fetch_array($result);
    
    foreach($row as $key => $value){
        if(!empty($value)){
            $_SESSION[$key] = $value;    
                }
                    }
    }
    

     

    When that runs I get the following warning. Can anyone tell me what this means and how to fix it?

     

    Error: Notice: Unknown: Skipping numeric key 0 in Unknown on line 0

  8. It all depends on how many people are going to be accessing it at once. There are online hosting services that are like $5-$10 a month that will probably only give you access to a couple hundered people at once. Then you have ones that are $20-$40 a month that will allow you to server a couple thousand people at once. If your gonna go with a hosting company and your own server than expect to pay $1000 for a decent server and than about $100 a month in hosting fees(If your gonna have the DB on the same server than increase the RAM). As for the speed of your site, that depends on how well you coded it. The more you can do in the least amount of instructions the faster it will be. From what it sounds like you wont be doing anything to crazy so i wouldn't worry about that. As for security just make sure you validate every input and output, I work in a school distict and kids love to google things and try them out on your site and see if they can break it. 

×
×
  • 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.