Jump to content

Millar

Members
  • Posts

    40
  • Joined

  • Last visited

Posts posted by Millar

  1. Hello,

     

    In my current development I want my main server to store main user account profiles along with other data. When a user wants to partake in an activity at another server related to the project, I want a copy of the user data to be sent to the main server for local reference.

     

    I have acheived this using fsockopen from the main server to tell the target server it has data for it, then the target server uses fsockopen to contact the main server for the data and then store it:

     

    Main Server fsock(Target Server) -> Target Server fsock(Main Server) -> Main Server outputs data -> Target Server saves the data.

     

    Now currently this is being performed on the same server, for testing purposes, and still takes over 5 seconds to route all the data and perform the actions, and so I dread to think of the delay between remote servers.

     

    So, my question is, is there a faster way to transfer this data between two remote servers (securley)?

     

    Thanks.

  2. <?php
    
    $png = imagecreatetruecolor(800, 600);
    imagesavealpha($png, true);
    
    $trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
    imagefill($png, 0, 0, $trans_colour);
       
    $red = imagecolorallocate($png, 255, 0, 0);
    imagettftext($png, 30, angle, width, height, $red, font, character);
       
    header("Content-type: image/png");
    imagepng($png);
    
    ?>
    

     

    That *should* work. :S

  3. Okay, here is a code example:

     

    class base
    {
    
    var $var;
    
    function __construct ( $var )
    {
    	$this->var = $var;
    }
    
    function func (  )
    {
    	print $this->var;
    }
    
    }
    
    class stend extends base
    {
    
    var $var; //Different var specific to the stend class.
    
    function need_var (  )
    {
    	return --THIS IS THE VALE--
    }
    
    }
    
    $class = new base ( "toenail" );
    $stended = new stend;
    
    print $stended->need_var();
    

    I know that for that example you could change it and remove the need for the other classes, but in my case I need the classes, so I have the problem presented there.

     

    So where it says "--THIS IS THE VALE--" how can I reference the $var var from the base class?

  4. Hello,

     

    Objects which are static in classes can be accessed with parent::$obj and thus $this cannot be used within the object.

     

    So what is the non-static equivilent I can use to access the classes parent in a non-static way? When I try to use the static method (i.e. parent::$obj) it errors out: "Fatal error: Access to undeclared static property: class::$obj in [...]".

     

    Thanks.

  5. Hello,

     

    I want class db (which extends class base) to be able to access class conf (which extends class base).

     

    When I print out the information of the base (parent class) class, I can access variables/functions defined in the base, db and conf classes.

     

    When I print the information of the db class (child of base) I can access variables/functions of only the base and db classes. So why can I not reference variables from my config class from within the sibling class?

     

    Thanks.

     

    Here is the print_r output:

    conf Object
    (
        [db_host] => localhost
        [db_user] => *
        [db_pass] => *
        [db_database] => *
        [db_prefix] => *
        [db_type] => *
        [version] => 1.0
    )
    
    db Object
    (
        [connection] => 
        [version] => 1.0
    )
    
    base Object
    (
        [version] => 1.0
        [conf] => conf Object
            (
                [db_host] => *
                [db_user] => *
                [db_pass] => *
                [db_database] => *
                [db_prefix] => *
                [db_type] => *
                [version] => 1.0
            )
    
        [db] => db Object
            (
                [connection] =>
                [version] => 1.0
            )
    
    )
    
    Why does db Object not look like this?:
    
    db Object
    (
        [connection] => 
        [version] => 1.0
        [conf] => conf Object
            (
                [db_host] => *
                [db_user] => *
                [db_pass] => *
                [db_database] => *
                [db_prefix] => *
                [db_type] => *
                [version] => 1.0
            )
    )
    

  6. Hello,

     

    I previously used addslashes on my POST and GET data, I have now changed this to mysql_real_escape_string, as a result, in messages on the site new lines are displayed as nr and do not start a new line.

     

    All I changed was the addslashes function and replaced it with MRES.

     

    Here is what happens to the data when it is parsed for message display.

     

    $text = htmlspecialchars ( $text );
    $text = stripslashes ( $text );
    
    [bB CODE PARSING]
    
    $text = nl2br ( $text );
    
    return addslashes ( $text );
    

     

    Also, when I view the data as it was sent to the table in phpMyAdmin, the newlines are displayed (I assume phpMyAdmin runs nl2br on the data it displays on Browse pages.

     

    Since I only swapped the addslashes function I do not know why the new lines are no longer parsed. Could it be because of the fact that MRES escapes \n and \r?

     

    Thanks in advanced,

    Sam Millar.

  7. Hello.

     

    I have been racking my brain, but can't think up a function to do this.

     

    I want to make a function to convert and ID into a coordinate.

     

    E.g.

     

    1 = 1,1

    2 = 2,1

    3 = 1,2

    4 = 2,2

    5 = 3,1

    6 = 3,2

    7 = 1,3

    8 = 2,3

    9 = 3,3

    10 = 4,1

    11 = 4,2

    12 = 4,3

    13 = 1,4

    14 = 2,4

    15 = 3,4

    16 = 4,4

     

    I realise that this most probably would be based on square roots.

     

    e.g 16 = 4,4 and 4 is the square root of 16. But I can't think of a way to find it for non square number ID's.

     

    Thanks in advanced,

    Millar.

  8. In my complete honesty that class seems a bit long winded. Why spend time doing multiple queries to set your connection data. Rather than send an array to the function with all the settings or send each bit of data in a new function parameter?

     

    Also MySQL classes can be useful if you want to have multiple connection instances.

  9. I have a string with a line of alpha-numeric values. I want a function to take the previous value u and then increment it by one, in order of the string.

     

    So, if the string was "1234567890abcdefghijklmnopqrstuvwxyz", 1 goes to 2, 0 goes to a, and z would go to 11.

    But endlessly so something like dw34fz would go to dw34g1.

     

    If anybody has anything that can do this or can write it I would be very thankful.

  10. I know quite a lot about MySQL but I have never needed to use an array as a mysql value.

    I need to do this so my personal messaging system will allow sending messages to multiple recipients.

    Now, really don't know how to go about using an array as a mysql field type. So if anyone could tell me what type of field I need and how to insert/retreive information using php, that would be really helpful.

    Thanks in advanced,
    Millar.
  11. Yes, it does, but PHP can't handle the Number when it is in Integer form, and I need to get it into maybe an equivilent of bigint in PHP to put it into the MySQL database, I can't use a float because that will return zero when you try and insert into database.
  12. I have a sum which ends up returning a float because basically it results in larger than 2 billion. I want to insert the value that is larger than 2 billion into a bigint field in a MySQL table, how can I insert it into the field because if you inser the float it simply returns 0 and if I inster it as an integer it just does the maximum of 2147483647?
  13. When cleaning any user inputted data, either via _GET or _POST, how should I clean it to make sure it's safe, what functions should it be put through to be 100% safe.

    Thanks in advanced.

    P.S, the data will be getting entered into a MySQL DB..
  14. At the moment I have made it so you can remotely connect to my MySQL server with the IP address, however, when you connect remotely, all the files and users are not there if you connect using hte IP, but when you connect via localhost everything is there. Like as if they are 2 separate servers ( And of course they are not ). How can I merge them together so connecting ip gives the data I get from connectinglocally with Localhost?
  15. Hello,

    I am writing a PHP script which involves a user being on a page for a certain amount of seconds, now, I was wondering how I can make it so when the user leaves the page, I can get a function to work. Is there anyway I can do this, maybe with sessions?

    Thanks, Millar.
×
×
  • 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.