Jump to content

radalin

Members
  • Posts

    179
  • Joined

  • Last visited

    Never

Posts posted by radalin

  1. That notice is shown because of your error_reporting() check the manaul for it's values. That's not an error. So it will not cause any problem, it will just show an annoying notice message at top.

     

    you may try to use null (lowercase) which might work.

  2. You can take a look at PostgreSQL which has an array type (this array type maybe of different types. like char[], numeric[],...). Maybe that may help too. I have never tried that anyway, still use the old and good new table solution. But take a look it might be helpful and may give you another solution :)

  3. Well I did not clearly understood the problem. When you click the refresh of course it will insert newly to the database as the whole page is running again. And I don't think there is a way to stop it. Browsers mostly notify you when you click on refresh that post data will be send again. Maybe HTTP_REFERRER can be used. If the referring page is the form page then insert or if the referrer is itself, I'm not sure if you click on refresh that referrer will change, do not insert.

    I assume that it inserts a data with duplicate user like two 'john' which will cause a possible password conflict. A solution is that you could put a unique key to your username. By this way there is no way to insert two 'john's as it will violate the unique key constraint. Another way is to check this via php or another programming lanugage manually. First "select * from users where username='jhon'" and if the result rows are higher then zero, then show an error that this name is already inserted and the user should choose another name.

  4. Factory is something that creates generally same type of things but let's say different instances, right?

    A factory may create nike shoes but also adidas shoes. Every shoe implements the same interface. They wrap our feet and things like that.

     

    Let's sat you have a database object which connects to the database. You create it by:

     

    $db = new Datatabase();

     

    Thing is when you pass from mysql to mssql, you should change all your syntax right? mysql_query must be replaced with mssql_query and it's a really annoying bussiness anyway. Let's say that you have used the factory method.

    When creating Database() you send it a database type to your Database object. It has a driver which executes your sql queries. So your database creates another object to execute your sql queries. This newly created drivers are specified to the database type, mysql has different  syntax mssql has different types but they have the same method names as they implement the same interface. So whatever be your database driver you can call query() function.

     

    So you factory creates another object that object may create another objects and this goes like that. That's why it's called 'factory', it creates instances of different object with nearly the same functionality.

     

    I hope I was able to explain that clearly and without mistakes.

  5. What hostfreak is recommended is the best solution you can make with the database. But if you're so obsessed with not creating another table and use a single coloumn, You should use somehing like xml or json notation to encode your data, not space seperated values (use at least commas!!). You may give an array to js_encode() and it will return a string which you can put to the db. While getting it back, you can use js_decode. But I do not recommend it, another table is the right and proper solution.

  6. He's not trying to insert something in the table, he's trying to alter table and add another coloumn.

     

    Mysql has feature that you can add a coloumn after another coloumn. Something like this:

    ALTER TABLE mytable ADD new_col VARCHAR( 50 ) NULL AFTER `old_col` ;
    

     

    But I think that you want to automate this solution using a programming language. Use somthing like mysql_field_names() which will return an array. Then add you new col to the result array. Sort it, find your new coloumns name's index and while altering the database use something like:

    mysql_query("ALTER TABLE mytable ADD {$fields[$i]} VARCHAR( 50 ) NULL AFTER {$fields[($i-1)]}") ;
    

     

    Anyway if I get wrong what you said. And that you don't want to add fields but rows in the database no matter what order you have inserted them, while showing the data you can sort them with any field you want.

    SELECT * FROM mytable ORDER BY ordercol ASC
    

     

    Hope that helps.

  7. Well something like this may be useful:

     

    You have a user table like:

    userid, username,...

    A group table like:

    groupid, groupname,...

    and a usergroups table which will hold which user will belong to which group and user may join to more then one groups so my user_groups table is like:

    ugid, userid, groupid

    Now that I have the groups and users and relation between groups and users I can create my permissions table:

    permissionid, userid, groupid, folderid, documentid

     

    Here is the thing. You may set the user and folderid or group and folderid or user and documentid or group and documentid in this table. You may seperate them, but you may not too as it wont change a lot. So from this permissions table you can get the permission list which user can reach which document or folder or other things. I hope it was helpful for you.

  8. Well DW is good however, I think that it's not a php editor. It's just a WYSIWYG editor with php syntax highlighting. You might argue with that but I have used nearly all (I didn't used Maguma, Komodo and BBEdit) the php editors listed here (even the ones that are still beta:). I can honestly say that if you want to go lazy and do the less writing and more sleeping, you should really choose DW. Which has great features like writing code and others. However if you really look to do everything in your project as yourself and you want full control of what's happening, you should try something "better". DW has only support for pure php functions. It does not complete your own classes, which is something really disturbing if you're used to use code completing like me.

     

    PHPed, PHPEclipse, PDT ZDE (my favorite) or even VIM (my "new" favorite) are real php editors. It was sad to not see Emacs here, they are really life changers if you have the patience and the power to keep pushing on meta and ctrl keys. While Emacs and VIM are not IDE's just "editors" they have great features too.

     

    Anyway I suggest everyone to give a try to Zend Studio or PDT (again Zend's eclipse based php developement tool). If you have the patience or bored using windows as you os like me try vim or emacs. They can really change your life (You will love to cut and paste rectangular block with vim, I'm sure:)

  9. I forgot to mention. (Can't edit my own post)

    while sending variables to an sql query use mysql_real_escape_string() to protect your database and you application from sql injection.

     

    your query should be like:

    <?php
    $dbl1      = "SELECT * FROM PHPAUCTIONXL_swopboards 
             WHERE posterid= '".mysql_real_escape_string($_SESSION["PHPAUCTION_LOGGED_IN"])."'
             AND auction= '".mysql_real_escape_string($_SESSION["CURRENT_ITEM"])."'
             AND enddate>='".mysql_real_escape_string($NOW)."'
             AND status!='i'
             ";
    ?>
    

  10. A different way to solve this may be to use another database: PostgreSQL. Rules may be better for such a circumstance. You could create one table with thousand "little tables" in it. While querying only that table will be used and not the rest. And also it will cause any problem with joins I suppose. But I'm not sure about exact properties of rules. Maybe thousand is a big number which will slow down your app. Anyway you could try to google around a bit for more information I think.

  11. something like:

    SELECT v.*,t.* FROM verifiertimeoff v, timeoff t
    

    may work. But it will create too much result rows, as this is a huge query....

     

    Anyway you could try something like:

    <?php
    $my_table_name = ( $_GET["t"] ? "timeoff" : "verifiertimeoff" );
    
    $query = "SELECT * FROM $my_table_name";
    //Here comes additional code
    ?>
    

    which is a bit better. But for the first thing you could try putting a where clause like:

    SELECT v.*,t.* FROM verifiertimeoff v, timeoff t WHERE t.id = v.id;
    

    It will reduce the result row count, however I do not know if it's usefull or not...

  12. Well ok. Perhaps I should change the explanation type.

     

    Let's say we have a class with some attribute: x,y,z,k. I have to write get and set method for them  if I define them private. Let's say that I did so. Now I have to do something like this:

    <?php
    get_k() { return $this->k;}
    get_x() { return $this->x;}
    get_y() { return $this->y;}
    get_z() { return $this->z;}
    set_k($val) { $this->k = $val;}
    set_x($val) { $this->z = $val;}
    set_y($val) { $this->y = $val;}
    set_z($val) { $this->z = $val;}
    ?>
    

    As you see these methods are doig approximately the same thing. I can something like this instead:

    <?php
    get($key) { return $this->$key; }
    set($key,$val) { return $this->$key = $val; }
    ?>
    

    This may be written wrong if you think the syntax but you get the idea I think.

    But in this type of writing get_x() is not defined. I want that when I call get_x() it returns the value of get($key).

    Yes of course I may use this:

    <?php
    get_x() { return $this->get("x"); }
    set_x($val) {  $this->set("x",$val); }
    ?>
    

    It's ok but I have to write and define them. It's not about begin lazy to define them. It's about easy management. In this case inside of the function may not change a lot but with something a little complex things get boring with finding which functions are changed or not and which one must be changed. Instead of this kind of using.

    <?php
    $getfunctionlist = array("get_x","get_y","get_z","get_k");
    $setfunctionlist = array("set_x","set_y","set_k","set_z");
    //Something comes here to check if the above functions are called...
    //and which that functions will call the below functions
    get($key) { return $this->$key; }
    set($key,$val) { $this->$key = $val; }
    ?>
    

     

    Why do I need this? Well it's about being a little lazy too of course but mostly, I was curious if such a thing can happen.

     

    Thanks again for your time.

  13. you may want to take a look at pear too. It's not a framework as others I guess but you may download and use only the objects you need. Check it out.

    pear.php.net

     

    (btw for zend's framework link should framework.zend.com I think and not zend.framework.com, it's not going anywhere when I had checked.)

  14. well, it's ok but you may try to use

     

    SELECT * FROM config WHERE config_name = 'bandname' OR config_name = 'copyright'

     

    Instead of two queries which will increase your performance a little bit.

     

    By the way you should had tried mysql section of this forum not php help section because this topic fits better there.

  15. Well juast add a unique key to the coloumn that you want it to be a unique value. Then you don't need to check it. PgSQL will not insert anything because of violation of keys and it will return false.

     

    Also see the postgresql select statement syntax for further information.

  16. well I assume that id is the pk. So

     

    SELECT * FROM foo WHERE id = 1 AND id = 2

     

    will not return anything, because primary keys can only be unique values. And there is no way that id can be both 1 and 2

     

    Try this one:

     

    select * from main_db where id="143" OR id ="144"

     

    This should do the trick.

     

    But I recommend:

     

    select * from main_db where id IN (143,144,145)

  17. Hi,

     

    I'm curious if anyone knows such thing is possible or if this is possible how it can be done. I mean that you call a function, which is not defined using "function xxx" but by someother way, then when we recognize that the function we have called is in our function list array, then it calls a generic function which takes as argument some part of the function that exists in the function list. What I mean is something like this:

    <?php
    $functionList = array("myfunction1","myfunction2","myfunction3");
    
    function myfunctionX($id,$X) {
      echo $id*$X . "<br />";
    }
    
    //....Code that check if the function name exists int the functionlist array...
    
    myfunction1(10);  //Output: 10
    myfunction2(10);  //Output: 20
    myfunction3(10);  //Output: 30
    ?>
    

     

    When myfunction1 is called, we check that if it exists in the functionlist array. Then if it exists we call the generic myfunctionX() and send the number (myfunction1 => 1, myfunction2 => 2) as an argument of myfunctionX()

     

    Well I hope it was clear for you to understand. I'm not sure how it's possible, it seems to me as a php hack but I'm not quite very sure. I appreciate if you show me some clues.

     

    Thanks for your time.

     

    Note: It's not only about begin lazy to write functions :)

  18. It really helped a lot!

     

    I have even modified your code a bit. Now there is a chance to autofade. Div's are fading over time and showing next divs. Anyone who requires some help about this may want to check it.

     

    Thank you for everything :)

     

    [attachment deleted by admin]

  19. to logout user must have to click on a logout button or link I suppose. If link's href is like that, a confirmation message will show. You are not stopping your php code and you will not be able combine both I think. You can only ask for cofirmation at the moment where user clicks on logout button. I do not know any function in php which will pause the script and ask for user's confirmation.

  20. Well I finally got the time to work on this thing. Your idea was great and I tried to implement it. I encountered some problems thought. I was unable to get the time when the fading finished (to change the content of the div) and also I was unable to put divs over each other. It was fine with position:absolute thing but I couldn't put them over each other when I deleted position:absolute. I know it's not a js problem but it's the followup of this problem.

     

    Thank you for your time

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