Jump to content

gizmola

Administrators
  • Posts

    5,882
  • Joined

  • Last visited

  • Days Won

    139

Posts posted by gizmola

  1. how do u do those stuff? can give mi a simple intructions? thank you  

    btw i am not using router but juz simple LAN network which consist of 2 network card and 1 lan cable connected 2 PCs together

     

    Whatever device connects you to the internet (cablemodem or DSL router) is doing NAT, because you are using a non-routable IP for your internal lan, ie 192.168.0.1.

     

    the 192.168.0.1 network can not be seen from the internet... it is non routable. Thus, you will need to configure your router to map it\'s port 80 traffic to the internal machine that has the webserver. How you would do that depends on how your router works, but usually you set up a rule that allows port 80 from source * to 192.168.0.1.

  2. Mysql\'s limit feature is one of the really nice things it offers. That\'s definately the way to go. Hopefully you have a key to the table using auto_increment, or have a timestamp column. Then you would not have to bother with trying to get the count(*) and do a limit count(*)-20, and would instead simply do:

     

    SELECT * FROM Table ORDER BY Table_id DESC LIMIT 20;

     

    This will display the rows most recent first. May be what you want, and saves an extra query.

  3. Mysql stores this type of information in the mysql user table, which is in the mysql data dictionary. Typically, a user will be created like so:

     

    someuser@localhost.

     

    This will indicate to mysql that the user can only connect from localhost. If the host has indicated that you can\'t make a remote connection, then they have probably setup your database user in this fashion, and mysql will not allow you to connect to it from any network address other than localhost.

  4. error message:

     

    \\\"Incorrect table definition; There can only be one auto column and it must be defined as a key\\\"

     

    what does that mean?

     

    It means that there can only be one auto_increment column per table, and that column must be a key for the table, usually the primary key.

  5. Seems like you are asking for a combination of declarative referential integrity and triggers for a subtyped table. There is no magical way of handling this type of design, especially with mysql. Mysql doesn\'t have triggers.

     

    I assume that there must be some substantial commonality in the set of columns between the tables that makes this type of code worthwhile, because you are guaranteed to need a case statement to determine which subtype table you will join to.

     

    The typical way of handling this is with 2 main tables, and 1..x subtables.

     

    Table1 (Your main table... you called it index, should have an auto_increment key called indexid.

     

    Table2 (The subtype table)

    This has a subtypeid key and description. The rows in the table will be: 1. Features 2.News 3.Previews 4.Reviews 5.Rants

     

    Tables 3-7 in your case are the feature, news, preview etc. tables.

     

    You set Table 2 to have a foreign key relationship to Table1. That is, there should be a subtypeid column in your index table.

     

    In each of your subtype tables, you will include the primary key from the index table in them. Here\'s an example:

     

    CREATE TABLE features (

    indexid INT UNSIGNED NOT NULL,

    othercolumns....,

    FOREIGN KEY (indexid) REFERENCES index (indexid),

    PRIMARY KEY (indexid));

     

    When you do an insert, you will insert your row into index first, setting the correct subtypeid for the subtable... ie 1 for an entry into the feature table.

     

    Immediately following the successful insert into the index table you:

     

    $indexid = mysql_insert_id($dbh); (where $dbh was the handle used in the insert query)

     

    Then have your case statement, and you examine the value of $subtypeid, which tells you which child table you should be doing your follow up insert.

     

    You then do an insert into that table, with the appropriate columns, and using the $indexid to set the indexid column value.

     

    When querying the results out later, you join index to subtypetable by the indexid column.

     

    Ideally you surround this process with a transaction, so that if at any point an insert fails, you can rollback the entire thing. The availabilty and syntax for a transaction-like capability really depends on the version of mysql you are using.

  6. I called \'df -h\' and it shows that dev/hda3/ is 100% full. Anyone know what this is? or how to empty it?

     

    Well that\'s a partition of your harddrive. Whatever filesystem is mounted there is full. Note the filesytem mount that\'s displayed as Mounted on.

     

    You\'d have to delete files from the filesystem to clear up space if you needed to write more data there. MySQL databases are a series of files, so if MySQL is configured to write it\'s data on that mount, you\'re going to get an error.

  7. I agree 100% with what Shivabharat advised. A few things I would add though:

     

    With the more current versions of php you suppossedly don\'t need to seed rand with srand.

     

    I would select min(quoteid), max(quoteid) from yourtable first, then use those values to pass to rand:

     

    $randid = rand($minval, $maxval);

     

    Then as Shiv suggested just do a select quote from yourtable where quoteid = $randid

     

    8)

  8. I\'m am getting this error...

     

    (13)Permission Denied:  make_sock:  cound not bind to address 0.0.0.0:80 no listening sockets availalbe, shutting down

    Unable to open logs

     

    Now, i am not root when i start the webserver, but when i become root and run it, everything works fine. So, my guess is that i don\'t have permission to open up port 80. Does anybody know how to fix this error? Someone told me that you can\'t open port 80 when you aren\'t root, so you have to run apache as root. This is really bad because i do not want to run apache as root, since that is a major security problem.

     

    Thanks for your help.

     

    Although you start Apache as root, it immediately forks children as the user you specify in the apache http.conf file. This is most typically set to be nobody.

  9. It sounds like postgresql support was not installed with your current version of php.

     

    create a file called: phpinf.php which contains this:

     

    [php:1:169120ff86]<?php

    phpinfo();

    ?>[/php:1:169120ff86]

     

    Point your browser to this file and examine the information it returns. I expect that this will provide verification that you will need to update your php installation to include postgresql support.

  10. Yes, I have windows.  What exactly do I have to do with the task manager (if it is the same thing that I have running my virus checker and whatnot every week)?  You are being very helpful, thanks!

     

    Basically go into the scheduler which is under the accessories|system menu and add a new entry there that calls php.exe directly like so:

     

    php -q yourscript.php > scriptstatus.html

     

    You need to make sure that the php.exe was installed and not just the module. Write and test yourscript.php, and make sure it works first, accessing it through your browser though.

  11. I know. I read about it but I can\'t figure out how to get it to apply using myPHP. I was wondering if there were any alternatives or if someone could help me get a CRON job working with myPHP.

     

    I\"m not familliar with myPHP, is it a stats package? Well at any rate, windows does have the Task scheduler that you can use in a similar manner to cron.

  12. Try changing this line:

     

    $sql_8 = \"INSERT INTO user (userid, password, fullname, email, userlevel, webspace) VALUES (\'$username\', \'$password\', \'$fullname\', \'$email\', \'admin\', \'0\');\";

     

    to:

     

    $sql_8 = \"INSERT INTO user (userid, password, fullname, email, userlevel, webspace) VALUES (\'$username\', \'$password\', \'$fullname\', \'$email\', \'admin\', \'0\')\";

  13. The other option is to not use a seperate data and seperate time column, but instead to use a Datetime column.

     

    It\'s also better not to use keywords as the names of your columns. I\'d suggest instead that you have a column called for example:

     

    created.

     

    When inserting a value it could be insert into yourtbl (col1, col2, created) values (\'blah\', \'blah\', now());

     

    It\'s easy enough via either MYSQL or php to seperate the date and time components from a date/time. The added advantage of using a datetime, is that *if* you need to do selects via date, it will be much more efficient. For example, you might have a query like:

     

    select * from yourtbl where created > now()-1;

  14. WHen you start a string with a single tic it\'s interpreted to be a string literal by php. Use a double quote around the assignment instead, and php will do the variable replacement you expect.

     

    [php:1:501ca3e94d]<?php

    $sql = \"INSERT INTO `stocks` (`Title`, `ID`, `Value`) VALUES (\'$title\', \'$id\', \'$value\');\";

    $query = mysql_query($sql);

    if ($query) {

    echo \"Success!\";

    } else {

    echo \"ERROR!\";

    }

    ?>[/php:1:501ca3e94d]

  15. this is driving me mad, been trying to formulate one SQL query for 2 days now, please someone put me out of my misery!

     

    Doing a query on 2 tables:-

     

    messages table.

    ID // key field, int

    threadID // key field of thread this message is in

    title, body, etc. // stuff

     

    unreadmessages table

    ID // key field

    msgID // corresponds to the ID of a message record

    threadID // key field of thread this message is in

    userID // userID - indicates the user hasnt yet read the associatde message record.

     

     

    Speaking of headaches, I have a huge one at the moment, and I must confess I\'m not up to the task of scrutinizing your code, but I do have a kneejerk reaction to this design.

     

    IMNSHO, I feel you should have a table called msgread. When a reader reads a message, insert a row into this table, as oppossed to your current design. The first and most obvious reason for this is:

     

    1. WHen you start you have let\'s say 10 users. There\'s let\'s assume 500 messages in the forum. Now user 11 signs up. Are you going to have the system go out and add Didnotread rows for all 500 messages? Ouch. Based on the way forums are used, I think it\'s a much better design, not to mention, one that spreads the transaction load, to simply add a row to a readmsg table when someone pulls up a message.

  16. If you mean lookup values, I\'m prejudiced towards keeping that type of stuff in the database. This is what is generally referred to as having a \"data driven\" design.

     

    In general small tables like these should be cached by the database, and retrieval is as close to instantaneous as the database can be. There are many different things that can become a bottleneck in an application, and I\'ve found it\'s best to create the system first, then tune around the bottlenecks, rather than to assume you know what the bottlenecks will be and start making design decisions based around those assumptions.

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