Jump to content

biohazardep

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

biohazardep's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. But it works when i take out the ORDER BY part, like this: SELECT username, COUNT(item_id) FROM (phpbb_lms_items LEFT JOIN phpbb_lms_mochilas ON item_moch=moch_id) LEFT JOIN phpbb_users ON moch_dueno=user_id GROUP BY moch_dueno
  2. Use the time function: int time ( void ) Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
  3. You can search for partial postcodes even if you combine the start and end columns. For example, to search for postcodes that start with SW1 you can do this query: SELECT * FROM postcodes WHERE postcode LIKE 'SW1%' You can use % as a wildcard, so %4EN means postcodes that end with 4EN. Or SW%EN means postcodes that start with SW and end with EN. Hope this helps.
  4. Make a column in your threads table that stores the last time a reply was posted for that thread and ORDER BY that column.
  5. I'm trying to run the next query: SELECT username, COUNT(item_id) FROM (phpbb_lms_items LEFT JOIN phpbb_lms_mochilas ON item_moch=moch_id) LEFT JOIN phpbb_users ON moch_dueno=user_id GROUP BY moch_dueno ORDER BY COUNT(item_id) DESC It works as i want it to in my windows server, but not in my linux server. In the linux box i get the message: "SQL Error : 1111 Invalid use of group function" The windows server has the following versions: Apache Web Server Version 2.2.3 PHP Version 5.1.6 MySQL Database Version 5.0.24a The linux one has: Apache Web Server Version 1.3.33 PHP Version 4.3.11 MySQL Database Version 5.0.18 Can anyone help me get it to work in the linux server please? Note: The linux box is from paid hosting, so i can't do much about what versions or features it has. My windows server is only for testing and development before i move my code to the live server (the linux one).
  6. Maybe you can do it like this: <?php for ($i=1; $i<5; $i++) { include('dumb_coworkers_edit_this_file.php'); } ?> Then you can have the "markup with a few php variables echoed inside" in the dumb_coworkers_edit_this_file.php file, and have your coworkers edit that file without messing the php code.
  7. It works like this: - The user has a text file, which lists items and the name of the backpack they're in. This file could be huge (more than a thousand items listed), it comes from the inventory system of a game (a different program, not a browser game). - The class records the list of backpacks in a table and the items in another table, the items table has a field for the ID of the backpack which it belongs to. - I want to make it easy for the users to upload their text file again (which could be different from last time) to update their online inventory. So each time it reads a backpack from an uploaded text file and a backpack with the same name exists in the db, it deletes every item from said backpack in the db and records the new items from the text file in the db. This is why I end up with the index numbers for the items table raising pretty fast.
  8. Sorry for the confusion, what I meant was that the first 600 rows don't exist, they aren't there with empty fields, they just aren't there. For example, if the database consists of the rows with the next IDs: 1 5 6 7 13 (the others don't exist) I want to insert the next data into 2, 3, 4, 8, 9, 10, 11, 12, 14, ...
  9. Won't "while($result = $db->sql_query($sql))" run as long as the query "SELECT item_id FROM phpbb_lms_items ORDER BY `id`" is succesful? (meaning as long as my table is not empty?) AFAIK, "$db->sql_fetchrow($result)" is the one used to check that it finds rows from the database. If i'm not missing anything, your code will just check the first row untill it's empty and then it will insert the data into the $i row. Of course, i could be wrong, please tell me if i am.
  10. kathas, I'm trying this because just running the script myself twice i end up with a table with the first 600 rows empty and the data in the next 600 rows, with ids from 601-1201. With a few users using the script several times a day it would get out of hand fast. taith, I don't understand your code, especially the line: while($result = $db->sql_query($sql)) how many times will that loop run? Thanks for your concern
  11. Hi everyone, My script inserts a huge amount of rows to a mysql table and just as easy it deletes them, so to optimize the index numbers i'm trying to make it so that when i'm adding new rows it searches for an empty one to add the new one in. It's a phpbb mod i'm writting. This is the code i'm trying: for ($i=1; true ;$i++) { $sql = "SELECT item_id FROM phpbb_lms_items WHERE item_id='". $i ."'"; $result = $db->sql_query($sql); if (!$db->sql_fetchrow($result)) { $sql = "INSERT INTO phpbb_lms_items (item_id, ...) VALUES ('". $i ."', ...")"; if ( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, $lang['no_game_data'], "", __LINE__, __FILE__, $sql); } break; } } The error i'm getting is this: Fatal error: Maximum execution time of 30 seconds exceeded in C:\AppServ\www\forum\db\mysql4.php on line 118 I know the search logic works because I tested it just echoing $i instead of inserting the data and it printed the first available row from the database, and I know the part that inserts the data is working because without searching for empty rows it inserts the data correctly. They're just not working together for some reason. Anyone have some advice?
  12. Thanks for your replies everyone. I ended up going around the problem, I deleted the "class1" and just worked with an array of class2 type objects and it worked. I have a new problem now thought, but i'll make a new topic for it.
  13. Hello, i'm new here, I could use some help with this error i'm getting: Fatal error: Call to a member function class2_return_name_method() on a non-object This is with the next code: class Class1 { var $array_of_class2_objects = array(); function search ($xclass2_object_name) { for ($i = 0; $i < count($this->array_of_class2_objects); $i++) { if ($this->array_of_class2_objects[$i]->class2_return_name_method() === $xclass2_object_name) { // THE ERROR IS HERE ??? return $i; } } return false; } function add_class2_object_to_array ($xclass2_object) { array_push($this->arreglomochilas, $xobjetomochila); } } Can anyone help me with this please? The objects inside the array are of the class2, so i don't know why it says I can't use that method. (PS: I posted this first in OOP help, but it doesn't seem to be read as much, can some moderator help and delete that one please? Sorry if this is against the rules.)
  14. Hello, i'm new here, I could use some help with this error i'm getting: Fatal error: Call to a member function class2_return_name_method() on a non-object This is with the next code: class Class1 { var $array_of_class2_objects = array(); function search ($xclass2_object_name) { for ($i = 0; $i < count($this->array_of_class2_objects); $i++) { if ($this->array_of_class2_objects[$i]->class2_return_name_method() === $xclass2_object_name) { // THE ERROR IS HERE ??? return $i; } } return false; } function add_class2_object_to_array ($xclass2_object) { array_push($this->arreglomochilas, $xobjetomochila); } } Can anyone help me with this please? The objects inside the array are of the class2, so i don't know why it says I can't use that method.
×
×
  • 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.