Jump to content

ngreenwood6

Members
  • Posts

    1,356
  • Joined

  • Last visited

Everything posted by ngreenwood6

  1. Well this first problem I see is this: $query = "select * from iesnews"; $rows = $result->num_rows; Where is result coming from? It is not defined anywhere in the code you provided and maybe that is your first problem. Also if you have alot of rows or data in that table that query is going to take a long time to complete. I would recommend updating that to query to "SELECT COUNT(*) FROM iesnews" and then getting the result of that as the count (will be much much faster). Now the next problem i see is that your query is doing a range of -10,10. Running that in a query tells it to fail itself because there is no -10. Which is why your query is failing. Which is also stemming from the problem above i believe because it is not actually getting the number of rows. The last part is the query : $query = "SELECT * from iesnews ORDER BY 'posted' DESC $max"; I don't think that you meant to have the single quotes around posted. I would remove those unless they are ticks that got converted here somehow. If you fix the issue above with the rows being the incorrect number i believe that your query will start working with the exception off the "posted" issue maybe not sorting properly.
  2. Hello all, I need to be able to create file backups on different types of servers running php (windows or linux). I was hoping that there was a good php class out there that would already handle this for me but I have not come across anything as of yet. I can do it perfectly fine in the linux environment but was hoping to find something that would work on a variety of servers running php. I was hoping that it would support php 4 for older sites. If anyone has any good resources for this please let me know. Thanks
  3. That is what you wanted correct?
  4. try this then : $newPay = number_format($oldPay + $distance * .40, 2); $newPay = sprintf("%01.2f", $newPay);
  5. He is correct in saying number_format doesn't quite do what youre expecting. It will only keep the decimal points if there are more than two it will limit them to two places. A solution for you would be: $newPay = round($oldPay + $distance * .40, 2);
  6. Maybe you can take a look at this to see if it will work for you or if there is something you can build off of it : //the original string $string = 'PostInfo,color-main,Newman,not-collapsed;Friends,color-main2,Top Friends,not-collapsed||Twitter,color-main2,Twitter,not-collapsed;Signature,color-main2,Signature,not-collapsed;AboutMe,color-transparent,About Me,not-collapsed'; //could be wrong but seems like this should just be a semi-colon $string = str_replace('||',';',$string); //explode them by the ; as it seems that is the separator of the content $ex_string = explode(';',$string); //count them (faster than doing it in the loop) $ex_count = count($ex_string); //loop through each of the sets for($i=0;$i<$ex_count;$i++){ //now you can explode them on the comma to get there data $ex_string[$i] = explode(',',$ex_string[$i]); //you can either check the data here if($ex_string[$i][0] == 'PostInfo' && $ex_string[$i][3] == 'not-collapsed'){ //it is not collapsed so do something } } //print it out so you can see the data print_r($ex_string);
  7. Ok so here is my opinion on it with a quick review of it without really looking too deeply into it. First of all I would add more normalization to the tables. For instance in the stories table you have two fields in there for totalThumbUp and totalThumbDown. I would probably separate them out into another table storing the user id that gave it a thumbs up/down. This will allow them to change there vote in the future and you will still be able to find those values when you need them which you may not always need them. Another thing that I would do is separate out the actual content for the stories. Because that field is storing a large amount of data it will make your queries slower and most of the time you will not need all of that information unless you are viewing the actual story (depending on your scenario). It also seems as if you have some fields in there that dont really need to be. For example in the stories table you have a field for totalViews but there is a table for StoryViews which seems to just be storing the views which you should just be able to count the views from that table if needed. One last thing is it seems as if you are storing the dates as timestamps since you are using int fields. Why not just store them as dates? It is alot easier to look through the data in the table and find articles within a specific date range. Also in the future if you decide to do horizontal partitioning (which dates work perfectly for, especially with "stories") you will be able to do them by the year that they were posted which will greatly improve the speed of your queries with alot of entries in the database.
  8. Thanks for the response Pikachu2000. Never thought about doing a calculation to see how long it would take to reach that value. That pretty much eliminates that from being a problem.
  9. I dont think that really answers my question. I understand the replication process of storing it across multiple servers so that access to the data is faster but it still uses the same id's in all of those tables so the id would still hit the max number at some point.
  10. I am trying to find out what the maximum number of entries in a mysql database would be. I read online at multiple sources saying that there is no limit on the size of the information or the number of entries in the database. However, that is kind of confusing to me as integer fields obviously have a maximum number that they can store. For example in the mysql documentation it states that the maximum value for an unsigned bigint field is 18446744073709551615. In most cases you will have an auto-increment field with an int or bigint type. So wouldnt the maximum number of entries be this value since eventually you could hit that number. If so then what would you do at that point, would you have to delete some data from the table or split the table into now two tables and start the indexes over. I just want some clarification on what you would do if you were say facebook/twitter/google and stored that amount of information and could potentially reach that number. Any help is appreciated.
  11. Looking at the data that you posted it seems to me that this will accomplish what you are trying to do giving you all of the information: //get the data $data = file_get_contents('http://www.datafeed.com/data.txt'); //first of all explode them on new lines to get all of the info $lines = explode("\r\n",$data); // you must use double quotes and it might just need to be \r or just \n test it until you get a full array of all the lines as there own entry //setup a holder for the type of data you are getting - (general, clients, prefile, servers) $type = ''; //setup a holder for all of the data $content = array(); //go through each line and explode the data if(is_array($lines)){ foreach($lines as $line){ //setup holder for line data $line_data = explode(':',$line); //check to make sure there is data if(is_array($line_data)){ //if there is only one item it is a type so change the type and continue if(count($line_data) == 1){ $type = $line_data[0]; } else { $content[$type][] = $line_data; } } else { continue; } } } //now you can print out the data to make sure that you have it in the way you need print_r($content); When you run this code it should give you back a multi-dimensional array with the type of data as the key for the array and all of the fields with numeric indexes based on there position. Here is an ex. [!GENERAL] [0] => [some data] [!CLIENTS] [0] => array() [0] => username [1] => memberID [2] => John Smith [3] => PILOT [2] => array() [0] => username [1] => memberID [2] => Harry Potter [3] => ATC So you can then just do a loop on the data that you need and check its type if(is_array($content['!CLIENTS'])){ foreach($content['!CLIENTS'] as $client){ if($client[3] == 'PILOT'){ //do something here } } } Hopefully that is not too confusing and will solve your problem.
  12. I am not sure what you mean by it is giving you a whole page of errors. This should work exactly the same but remove the warning about split: list($ptno,$ptname,$num,$price) = explode(':', $inline);
  13. No that is a warning because your error reporting is turned on. The split function is deprecated in php (see here http://http://us2.php.net/split. You should use explode() instead of split().
  14. You do not want to use * because you will have column name conflicts. In your case you will want to use l.*, li.imagepath which will give you all of the listings information and the image associated. Also I think that you are not getting the last row because there are no images associated with it. To fix this problem you should be able to change JOIN to LEFT JOIN and it should work.
  15. Maybe its this line: $this->round_cr = ceil($this->count_query) / $this->page_limit; Should be this: $this->round_cr = ceil($this->count_query / $this->page_limit);
  16. I want to thank you again for the resource. I actually really like the closure table method. There is also alot of other good resources in that article as well. The only part that it doesn't show is how to get a full tree view in a single query which I am working on figuring out now so if you have a solution feel free to post it.
  17. Sorry about that the 5 was the value of the $num variable. Looking at what you posted if you change $id to $_POST['id'] your code might work fine.
  18. Reply to king, I believe that you are mistaking if I understood what you said correctly. The following code does what he needs to do and only returns one of each row instead of all of the rows. So if there are 5 listings it will return 5 rows and if each row has 5 images then the 5 images will be comma separated in the images key. SELECT l.id, l.name, GROUP_CONCAT(li.imagepath SEPARATOR ',') AS images FROM listing l LEFT JOIN listimages li ON l.id=li.listingid GROUP BY l.id ORDER BY l.id DESC;
  19. Thank you very much. I am going to read it now and will post back with my thoughts. If there are any other suggestions please keep them coming as I think this is one of the most challenging things to handle and keep efficient.
  20. It seems to me that you would have a radio button that would look like this: <input type="radio" name="part_number" value="5" /> When you submit the form that this part number is on you will get a value either in post or get depending on how you are submitting the form. This will then be the id that you are searching for in the file. So if you are using get it would look like this: $id = $_GET['part_number']; That would need to be put before the while statement allowing you to search for the value in the text file.
  21. You could also use a group_concat for this allowing you to get all of the images for a listing in one query comma separated. Example off the top of my head: SELECT GROUP_CONCAT(imagepath SEPARATOR ',') FROM listimages GROUP BY listingid
  22. Maybe I am missing something but I dont see where you have given $id a value before this line: if ($ptno == $id) {
  23. I have been going in circles about how to handle the issue that I have come up with and was hoping that someone could provide a different method. Basically I want to be able to create an infinite number of categories and allow them to be assigned to other categories then making them subcategories/sub sub categories if you will. My initial plan was to use a method I have used before by just saving the parent id of the subcategories and recursively going through the data. However, I am not to fond of this because of the inefficiency that it provides. I did some research and found that method is called the "Adjacency List". I also found another way to do it called "Nested Sets" which seems to be much more efficient but its a little harder to understand / maintain. I was hoping that someone here could offer alternatives to both of these methods that will allow me to keep the efficiency of "Nested Sets" but providing the ease of use / maintenance of the "Adjacency List". Thanks in advance for any help.
  24. When you post the page like you said your date is coming back as 07/20/2011, it needs to come back as 2011-07-20 but that does not look nice for the user. So thankfully we are using php and there are built in date functions. You can do the following: //get the correct format $new_date = date('Y-m-d',strtotime($_POST['date'])); //then you can insert that date $insert = 'INSERT INTO some_table (field1) VALUES("'.mysql_real_escape_string($new_date).'")'; Just as a note in case you dont know the strtotime function will take a date and return you a timestamp. Using the date function the first argument is format the date should be in and the second argument is a timestamp that you want formatted to the first argument. Hopefully this helps.
  25. I have a question. I do alot of mysql work on a daily basis and I have heard about triggers before but never really used them. So I decided today to teach myself about them and see if I could find a practical use of them. One thing I thought they could really be useful for is deleting information from the database and keeping a backup. For instance if there are 5 articles in a database and user decides he wants to delete the 5th article it could then run a trigger to backup the data that would allow him to restore it in case he removed it accidently. Now my idea was to create one table that could store all of the deleted items whether it be articles,users,pages, etc. In that table it would just store the table name, maybe primary keys and other pertinent information to restore the data. One thing I was thinking of was having one field in the backup database that would be something like "data" that would have all of the information for the item serialized or something similar. Anyone know if this is possible and maybe have a link to an article with an example I could build off of.
×
×
  • 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.