Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. well if you are willing to pay someone, there is a freelance forum for that. but without seeing any code I can't be much help. It sounds like you are trying to insert a field in your data base with an ID that is already set. Assuming ID is the primary key (which is must be if you are getting that error) and set to auto increment (it usually is, but its possible that the programmer before didn't set it to auto increment) then if you don't assign it a value in the insert statement, it will work perfectly fine. But again, I can't really help if I don't see any code.
  2. with the moveuploadedfile() function, you can use a custom name as the file path. I'm going to guess you use the filename of the uploaded file in it. Well, you could instead use whatever you wanted. just do something like $target_path = "path/to/directory/".$username.$_FILE['file']['name']; if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_path)){ echo "success"; } else { echo "fail"; }
  3. In the $_FILES superglobal array there is an index with the file size in bytes. you could do the following //get the size $size = $_FILES['size']; $size *= 1024;//now size is in kilobytes $size *= 1024;//now its in megabytes $max (1024)*(1024)*8;//1024 bytes in a kilobyte, 1024 kilobytes in a megabyte, then times 8 for 8 megabytes //you could do the following conditional to test if the file is too big if ($size < $max){ //upload the file } else { echo "File too large!"; exit(); } // other stuff
  4. dude... I don't even know where that object you are trying to use is coming from, but your first error explained everything. If you have a function, that you know for a fact is defined, and you are getting an undefined function error, then what could the most likely solution? maybe your using the wrong function name. Just forget about whatever object nonsense your trying to do make sure you are calling the function you defined.
  5. then you're textboxes don't have the right name or you are doing something else wrong, because i tested this and it works perfectly fine. post your code
  6. Its because the makers of PHP personally hate you and only you. they knew you would have a background in C/C++ and wanted to piss you off. But really, the specific "why" can be attained by asking the developers themselves. But , in addition to the added annoyance of making sure you don't use loop variables over again (I don't really run into this problem much, since I usually use $i for for loops, since $i isn't a good variable name for anything but loop iterators (except for maybe the character 'i'), it allows you the flexibility of being able to use the loop variable outside the loop, (for god knows what, but i'm sure there is a case this might be useful) Also, remember, PHP doesn't really have a main function, so all variables defined outside of a function have a scope that is accessible throughout the entire script. its kind of like python, javascript, and a few other languages in that respect for scope, as far as functions and classes go, its pretty much the same as C++. a tip I can give for you for loop variables, is to use names that you would only use for loops. For example, i, x, y, etc. this usually helps me.
  7. post the code you have? If you have the same exact variable names on both pages that MIGHT interfere, but i would have to see some code to make a judgement
  8. thats because you are doing print_r every loop iteration. do a print_r after the loop is done
  9. that would work, but if you want to make sure it is always less than 100 characters, you may want to change it up a bit. Someone could make a string with no periods whatsoever, or commas instead of periods, or something stupid. try this function first_sentence($content) { $pos = (strpos($content, '.') <= 100) ? strpos($content, '.') : 100; return substr($content, 0, $pos+1); }
  10. btw the var keyword in PHP 5 is acceptable but deprecated. You should use public/private/protected. but your code is all wrong $item_list = array("item1", "item2", "item3"); $user->setList($item_list); try that. beat me again. btw you may want to have a method that can append to the list public function append($d1) { $this->item_list[] = $d1; }
  11. try this $items = array(); foreach($_POST['item'] as $item){ if (isset($item) && !empty($item){ $items[] = $item; } }
  12. wouldn't work unless every single link also submitted the form holding the hidden field. Which IS possible, but can get pretty messy, and timing would probably be off
  13. well he has to use it for his input text box to dynamically add commas to what his user is typing, or this is what i could ascertain from his description of the problem he has Or maybe not. who knows any more
  14. oh, it seems we are arguing on the same side then
  15. $time = date("F jS, Y", mysql_result($result,$i,"timestamp")); for todays date will produce October 6th, 2009 (tested and works, assuming the data is correct) dam beat me too it
  16. this is a PHP forum, so if you want AJAX help you may have better luck in a different forum. you can try this tutorial
  17. this seems kind of pointless? It doesn't look like you need to use eval at all
  18. oh my reply wasn't directed at you.
  19. well since he's using javascript to dynamically add the commas, a PHP function won't really work in his case (i'm assuming, this whole post kind of confuses me) can you post some more code that the 3 lines you have? post the actual form processing code
  20. well obviously you have to include it on every page, thats exactly what we said, but we never said that is the end all be all of solutions. obviously if that solution wouldn't work well for you, than don't do it. its a suggestion, not a command. However, in most sites I develop, I use a template system (the index.php?id=thispage kind), so that every one of my pages always has a config page included, or something like that (because the index page is basically the page that holds everything). There are also some $_SERVER variables that you can use the get the file path. not to mention that having a magic string as an include in one place is a small sacrifice for not having to worry about your includes being wrong in my opinion. its not that much of a hassle to change one include. Oh and if you are using relative paths, all your includes are "magic" strings usually anyways. However, you are right, having a defined constant and using absolute paths are not always the best way. As with all programming languages, there are always different ways to solve problems with different pros and cons
  21. if i had to guess, it would be this line $get = mysql_query("SELECT * FROM guest LIMIT $start, $per_page"); if your start is anything but 0, it won't work. say start is now 6. since per page is 5, it will be LIMIT 6, 5 does that make any sense? You probably want to add 5 to per page, as well as start.
  22. have you tried ../data/data.txt ? and absolute paths are fine. You can just define a constant in an include file and use that as the beginning of the absolute path, for example define("MY_PATH", "path/to/root"); //to use include(MY_PATH."/cookies.php"); that way you don't have to change every single include call. just change one line in the main include file
  23. your query is failing. add an or die(mysql_error()); at the end of your query and see what message you get
  24. what do your checkboxes look like? they should be of the format <input type="checkbox" name="boxes[]" value="something" />clicky <input type="checkbox" name="boxes[]" value="somethingelse" />clicky1 <input type="checkbox" name="boxes[]" value="athirdvalue" />clicky2 when you submit a checkbox, on the values that were selected will be in the $_POST['boxes'] array.
  25. you can do this with javascript. You will have to create an event listener, and bind it to whatever key you want to. do a google search for javascript event listeners
×
×
  • 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.