Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. Hmm. I tried that guys original function and it was a good idea. I was worried about performance. Thanks for that modified function.
  2. This is the only key for now. I am trying to change the array structure to see if it will work then I am going to try foodigi's function as well and see how that goes in just a bit.
  3. I have an array. $array[1]['primary_domain'] = 'value1'; $array[2]['primary_domain'] = 'value2'; $array[3]['primary_domain'] = 'value3'; $array[4]['primary_domain'] = 'value4'; $array[5]['primary_domain'] = 'value5'; $array[6]['primary_domain'] = 'value6'; $array[7]['primary_domain'] = 'value7'; $array[8]['primary_domain'] = 'value8'; $array[9]['primary_domain'] = 'value9'; $array[10]['primary_domain'] = 'value10'; Then I have a standard string...might be... variable = 'value5'; I need to simply do if (!in_array($variable, $array)) { // add variable into array if it's not there. } So far this has been working perfectly. But recently there is one "item" that isn't working property...and I am wondering why. Is this standard behavior suppose to work or is there something wrong in my implementation?
  4. Very similiar. I ended up working up something simple to avoid the problem, so I got that situated. The next question I have is how to sort an array based on the number of values that array has. So let's say I have a big array. bigarray['a']['a'] = 'test' bigarray['a']['b'] = 'test' bigarray['a']['c'] = 'test' bigarray['b']['a'] = 'test' bigarray['b']['b'] = 'test' bigarray['c']['a'] = 'test' I don't know what order that array would be in so I want to sort it so I can see the ones with the "most" values first. bigarray['a'] would be first then bigarray['b'] then bigarray['c'] I have a huge array and they are similiar, I just want to order the primary array based off the amount of each values. So if bigarray[c] had more values than a it would appear first. Then I will be listing them out based off how many values were in each array. Does that make sense? Any advice?
  5. I have an array with 10 items. Each one fo those items contains a master item and a subarray of subitems. I need to loop through EACH of the 10 arrays through all of the sub items and find out how many matches there are alike. So if sub item abc appears in array 1, and array 4 then I need to list out they were found 2 times. It's wierd. i am guessing I need to create a matching algorithm for the arrays. Where should I start?
  6. I found the following code example based off of the windows API. i already know a good bit about the windows API and already can make windows, windows inside of windows, dialogs, modeless dialogs, and quite a few controls. Right now I was trying to get together some of the information from the users computer, but this is throwing a lot of C++ compiler errors. #include <string> #include <iostream.h> string GetLocalComputerName() { TCHAR chrComputerName[MAX_COMPUTERNAME_LENGTH + 1]; string strRetVal; DWORD dwBufferSize = MAX_COMPUTERNAME_LENGTH + 1; if(GetComputerName(chrComputerName,&dwBufferSize)) { // We got the name, set the return value. strRetVal = chrComputerName; } else { // Failed to get the name, call GetLastError here to get // the error code. strRetVal = ""; } return(strRetVal); } [compilererrors] C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\backward\backward_warning.h|32|warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.| C:\xampp\htdocs\cpp projects\Personal Multi-Tool\main.cpp|7|error: `string' does not name a type| C:\xampp\htdocs\cpp projects\Personal Multi-Tool\main.cpp||In function `LRESULT WndProc(HWND__*, UINT, WPARAM, LPARAM)':| C:\xampp\htdocs\cpp projects\Personal Multi-Tool\main.cpp|44|error: `string' was not declared in this scope| C:\xampp\htdocs\cpp projects\Personal Multi-Tool\main.cpp|44|error: expected `;' before "tmp"| C:\xampp\htdocs\cpp projects\Personal Multi-Tool\main.cpp|44|warning: unused variable 'string'| ||=== Build finished: 3 errors, 2 warnings ===| [/compilererrors] That was what happened when I used his code directly. I already knew enough about to change over from the deprecated headers so I fixed that by changing the header to reflect the undeprecated version, rebuilt, and got this. I also fixed a few othre errors I knew had to fix but I was left with: [compilererrors] C:\xampp\htdocs\cpp projects\Personal Multi-Tool\main.cpp|7|error: `string' does not name a type| ||=== Build finished: 1 errors, 0 warnings ===| [/compilerrrors] My new function is [function] string GetLocalComputerName() { TCHAR chrComputerName[MAX_COMPUTERNAME_LENGTH + 1]; string strRetVal; DWORD dwBufferSize = MAX_COMPUTERNAME_LENGTH + 1; if(GetComputerName(chrComputerName,&dwBufferSize)) { // We got the name, set the return value. strRetVal = chrComputerName; } else { // Failed to get the name, call GetLastError here to get // the error code. strRetVal = ""; } return(strRetVal); } [/function] Any advice?
  7. Bah, nevermind. I found out the IDC_STATIC is something built into VS++ which is automatically rewritten with a processor internally..since I am using another compiler I have to strictly create the definition in my resource.h file. When I did that then it did not throw a syntax error anymore.
  8. You also need to close up the ="" for the form. That can break it in certain browsers. So instead of whatever = "whatever" you might want to try whatever="whatever".
  9. If that doesn't work, try CodeBlocks and Ming. That seems to be a good combination for me. I used VS2008 for awhile but it just wasn't working for me due to various reasons.
  10. It's telling me there is a Syntax Error at the line with Groupbox. Does anyone see what kind of syntax error that might be? I am compiling this out of a tutorial about how to create dialog boxes just to test it out, and syntax wise the code looks alright to me? /* This builds the Dialog */ DIALOG_MAINMENU_ABOUT DIALOG 0, 0, 239, 66 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "My About Box" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "&OK",IDOK, 174, 18, 50, 14 PUSHBUTTON "&Cancel",IDCANCEL, 174, 35, 50, 14 GROUPBOX "About this program...",IDC_STATIC, 7, 7, 225, 52 CTEXT "An example program showing how to use Dialog Boxes\r\n\r\n", IDC_STATIC, 16, 18, 144, 33 END
  11. Also, are you able to name the .rc file anything you want. Like what is better. Creating a resource file for everything, or creating a resource file for different things? My thoughts would be creating one .rc file for everything I need (dialogs, menus (however many), icons, anything else). Or should I create a different rc file for each item... like menu_one.rc, icon_one.rc, dialog_one.rc. I was thinking it would be a lot cleaner to have 1 .rc file for everything. I might have more questions but I will keep them all here in this one post, as to not cause clutter in the forums.
  12. I have been practicing doing C++ Console (Command Line) applications for quite awhile. When I got my hands around the basics, I started dealing in the Win32 API. I have been using the: http://winprog.org/tutorial/menus.html I have some questions about these tutorials. First off on the resource file he uses stuff like: #define IDR_MYMENU 101 #define IDI_MYICON 201 #define ID_FILE_EXIT 9001 #define ID_STUFF_GO 9002 What I was wondering is....he mentioned that it was ID_whatever If I changed the word "ID" to something else would it work? Is that what it's suppose to be, or is that simply showing that you can use any word for the id? Also what are the numbers beside it? I don't get it. Those numbers listed beside each one.
  13. Someone from the drupal community gave me a quick tip. I solved the problem utilizing db_rewrite_sql
  14. I thought I had a solution just now but it didn't work. I was looking up the hook_nodeapi. I read all about it and it sounded promising but I set it up and print_r'd everything in it I was able to see them and then I was even able to do something based on type (like story type, or blog type). But I could not stop them from showing. I tried returning false when the node was story and I also tried unsetting node when it was of that type but neither of those worked either. I am still looking and doing research but if anyone has any advice it would be greatly appreciated. I am using Drupal 6 by the way.
  15. I basically want to do something seemingly pretty simple. When a "user" (not admin but user) goes to the homepage of the site the module goes and get's a list of everything in the "node_type" table. Basically it uses that to generate a multi-select box with all of the possible node_types (content types) that are in the system. Basically the select box is for them to select there favorites. They select there favorites and it get's saved into a table called "selected_content_types" which stores the user id and the content type. It basically looks through all of the ones they selected and adds it to the table. THat way I can easily generate a list of there favorite content types later. Also before it saves it clears anything already in the table for that user so they get a new list of favorites. All of that is done and completely working. I have that code below. I also have he install file which does install/uninstall and it all works. The following code completely works as expected. <?php // $Id$ /** * Implementation of the hook_help(). */ function selectctype_help($path, $arg) { $output = ''; //declare your output variable // Setup help information for this module switch ($path) { case "admin/help#selectctype": $output = '<p>'. t("Allows use to choose one or more content types. Those content types will then be the only options available when they select a content type. They also have the option of editing there favorites after they are chosen.") .'</p>'; break; } return $output; } /** * Implementation of hook_block(); */ function selectctype_block($op = 'list', $delta = 0, $edit = array()) { // This is the admin list. This allows them to setup the block in the admin panel if ($op == 'list') { $block[0] = array('info' => t('Content Type Selection Block ...')); return $block; } else if ($op == 'view') { // This is what shows the form on the add/content page. $block = array('subject' => t('Content Type Selector'), 'content' => drupal_get_form('selectctype_typelistform')); return $block; } } function selectctype_typelistform() { // Build form using select list from database $form = array(); $result = db_query('SELECT * FROM node_type'); $list = array('Choose'=>'Choose'); while ($row = db_fetch_object($result)) { $list[$row->type] = $row->type; } $form['select_list'] = array( '#type' => 'select', '#options' => $list, '#multiple' => true, '#title' => t('Please select your favorite content types.'), ); $form['submit'] = array( '#type' => 'submit', '#title' => t('Save Settings'), '#value' => t('Save Settings'), ); return $form; } /** * Implementation of Validate hook. */ function selectctype_typelistform_validate($form, &$form_state) { // If "Choose" was selected they can't submit. if (isset($form_state['values']['select_list']['Choose'])) { form_set_error('', t('You must choose an option or a series of options before submitting.')); } // If they selected nothing then they can't submit if (empty($form_state['values']['select_list'])) { form_set_error('', t('No option(s) were selected.')); } } /** * Implementation of submit hook. */ function selectctype_typelistform_submit($form, &$form_state) { // Activate user global. global $user; // Clear out the content types selected by that user previously (if any). db_query("DELETE FROM {selected_content_types} WHERE user_id = %d", $user->uid); // Loop through options and add them into Database. foreach($form['select_list']['#post']['select_list'] as $k=>$v) { db_query("INSERT INTO {selected_content_types} (user_id, content_type) VALUES (%d, '%s')", $user->uid, $v); } // Form was ok. drupal_set_message(t('Your form has been saved.')); } ?> Ok so there we are. Now here is my problem. When they select there list of favorites I want to then make it to where those are the only content types they can see. So basically only there favorite content types will be viewable and accessible to the. Pretty simple in theory I thought. but not easy to implement. I have treid everything I can think of to make this work but nothing is working. I don't want to make this dependent on another module. I want to make it work on it's on and so far it was going great until I tried to get this part working. I just need now is when they save the favorites it filters out somehow and only shows those node types then if they change there favorites again sometime ti just re-filters. I need it to be persistent even when they come back to the site that's why I also went ahead and databased it. I have tried messing with the perm and access hooks, and node hooks and multiple other ways but nothing is working. Can someone please point me in the right direction. Google was not my friend here either I have spent two days involved in extensive searches and nothing has gotten me closer to this goal.
  16. 1) I have been studying/playing with C++ for awhile. However I have always been curious how to go above and beyond command line applications (which is all I can write currently) and start developing windows applications (and eventually making them compatible with MAC, Unix, and Linux). Basically this is the general code below i have seen in a variety of places. However this code throws a variety of errors..is there a way to make this code work. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); [errors] 1>c:\users\businessman332211\documents\visual studio 2008\projects\windows application start\windows application start\windows application start\index.cpp(1) : error C2146: syntax error : missing ';' before identifier 'WinMain' 1>c:\users\businessman332211\documents\visual studio 2008\projects\windows application start\windows application start\windows application start\index.cpp(1) : error C2065: 'HINSTANCE' : undeclared identifier 1>c:\users\businessman332211\documents\visual studio 2008\projects\windows application start\windows application start\windows application start\index.cpp(1) : error C2146: syntax error : missing ')' before identifier 'hInstance' 1>c:\users\businessman332211\documents\visual studio 2008\projects\windows application start\windows application start\windows application start\index.cpp(1) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\businessman332211\documents\visual studio 2008\projects\windows application start\windows application start\windows application start\index.cpp(4) : error C2059: syntax error : ')' [/errors] 2) What is the difference between a "Struct" and a "Function" in C++. I have seen a few examples where Struct is used instead of Function?
  17. Nevermind about this post. I just read the post at the top stating not to ask for helping finding a specific application. I don't have a delete option on this post so just ignore it..apologies.
  18. I am thinking about building one for this situation because I am not sure if it's out there. There are hundreds of different forums but there aren't any that I have found that kind of..sit inside a website. Like say you have a fully functional website and you just wanted the site itself to load the forum into it's content areas and build the links. I am kind of looking for a...forum class or something. Perhaps a set of functions that perform each task (like build forum list, build post list, build links, build user link) then I could use those functions inside my pages Are there are "Lite" forums that function similiar to that?
  19. You can do that. Or you can echo out whatever you want. It'll still echo something out as needed if you are calling the function directly. You can also throw a return true in there if you want. What I would do is if you want it to echo then echo it but also return it. That way if you use the function "with" a variable it'll still return the variable. Better yet do both. Add a parameter and set it to true by default..that way if it's true it echo's if it's false then stop the echo and perform a normal return.
  20. You can save the file as a PDF and output the PDF itself right there on that page. You can either grab it and just output a PDF using FPDF or you can save the file as a PDF and output it there as a PDF using FPDF.
  21. Copy/paste the entire page please with all it's code. The one page that is causing errors.
  22. You have to understand the purpose of joins. When you have a deep application (for example on built in cakephp that are thousands of lines of code) standard queries can reach hundreds of lines potentially. Joins are a very good way to help get data together from multiple tables under special conditions. Look up: http://www.google.com/search?hl=en&rlz=1G1GGLQ_ENUS289&q=advanced+uses+for+sql+joins To find out more details (the first few should be enough).
×
×
  • 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.