Jump to content

citricsquid

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Everything posted by citricsquid

  1. Let's say I have the following strings: dsfdfsfdd/48977856+FE_F)E_E/dfhjdjhsd/sdffdsfsd/dsfsdfsdfp dsfdfsfdd/123p dsfdfsfdd/41234/1234324/3243223/324234 and I want to match the very final value after /, so It'd match: dsfdfsfdd/48977856+FE_F)E_E/dfhjdjhsd/sdffdsfsd/dsfsdfsdfp dsfdfsfdd/123p dsfdfsfdd/41234/1234324/3243223/324234 I know how to find the first, but not the last! Thanks!
  2. Just wondering, is there any reason you're not doing it the obvious way by having a default file (eg: view.php) and passing an ID then showing the information? Do you need to create files?
  3. Line 317/318, the input box. So you want: echo "<td><input id='referral' type='text' name='6' value=\""; if(isset($_GET['href']) && $_GET['href']!=''){ echo $_GET['href']; } echo "\" class='input'></td>"; Try that instead, it's easier to read and modify.
  4. If I had to guess; register_globals? You'll need to start using $_POST['variable']; Instead of $variable for things passed via the form.
  5. You probably shouldn't be having an ID that isn't non-unique and auto_increment. If someone wants to link to a post the ID is normally what would use, but if that can be changed... Instead have a unique ID and an order value; order can simply reflect the ID until it's changed.
  6. You need to change all the variables taken from the previous page to $_GET['name'] or $_POST['name'] depending on the method they're passed with. For example in your script you have "if($create)" but $create isn't defined anywhere, so I assume the form passes it, correct? If so above this line you should have "$create = $_GET['create']" (or $_POST).
  7. My method is slightly more complicated, but a lot more secure. You'll need a script for generating the dump, a script for activating the backup and a script for receiving the backup (listen). 1. user loads up the form page and clicks submit (or whatever you want them to do to trigger it) 2. The live server starts to generate a backup 3. once the backup is generated the live server sends the backup to the "listen" script on your backup server 4. The listen script then runs the query. For example: website1.com/form.php -> user clicks "generate backup" -> request sent to "website2.com/dump.php" -> website2.com/dump.php generates a sql dump -> website2.com/dump.php sends the dump to website1.com/listen.php -> website1.com/listen.php runs the query. This means the user will never see the data, it'll all be transfered behind the scenes. Apologies if I explained it poorly, this is a graphic created by Paypal that shows how I mean: https://cms.paypal.com/cms_content/US/en_US/images/developer/IPNOverview.gif
  8. Your problem is that your old server had global variables enabled (which is bad) and your new doesn't. How is $menusel defined? From $_GET? if so: $menusel = $_GET['menusel']; at the top of your page.
  9. So I've been thinking about it and I think it'd be possible to just do "where eggs = '$number' AND eggs ='$number+1' AND eggs ='$number+2'" (in proper query syntax). However let's say I need to do it for 100 different numbers, will this be a big hit on the database (performance wise)?
  10. I have a database of values and I want to work out how to display them if the values match a consecutive pattern. For example, I might have the table "eggs" with the values "1", "2", "3", "4", "6", "7", "8", "9", "10". Now if I were to count these up I'd have 9 total values, this is good. What I want to do is ONLY count the values where they have another 2 consecutive values after them. So for example if the above pattern is what I'm using and I want to check for 2 consecutive values, the following would happen: 1 -> correct, it is followed by "2" and "3". 2 -> correct, it is followed by "3" and "4". 3 -> false, it is followed by "4" but no "5" 4 -> false, it is followed by "6", no"5". 6 -> correct, followed by "7" and "8". 7 -> correct, followed by "8" and "9". 8 -> correct, followed by "9" and "10". 9 -> false, followed by "10" but no "11". and this would return the total of 7, because 7 of these values are followed by 2 consecutive numbers, therefore are correct. So my question: How would I go about this? Would it be a matter of a single (albeit complex) mysql query or will I have to do some more advanced stuff after fetching the array? If it's the second I can do that myself, but I'd like to (hopefully) do it in a query! So, any ideas?
  11. The simplest solution is to have the login page (one with the input form) add the referrer to their session, you don't need to store the referrer on every page, only the login. You'd have to add exceptions for no login and external sites though.
  12. If the server supports it then <?=... is a workable replacement for <?php echo... albeit bad practice.
  13. <?php //Söker funktionär med namn if(isset($sok)){ $query = "SELECT * FROM funktionarer WHERE namn LIKE '%$namn%'"; $result = mysql_query($query); if(!$result){ echo "<div class=tabell4><table><tr><td>Funktionären kunde inte hittas. MySQL rapporterar: " . mysql_error() ."</td></tr>"; echo "</table></div>"; } else { $line = mysql_fetch_assoc($result); $s_namn = $line['namn']; $s_adress = $line['adress']; $s_postnr = $line['postnr']; $s_ort = $line['ort']; $s_tel = $line['tel']; $s_email = $line['email']; ?> <form method="post" action="<?=$PHP_SELF?>"> <table><tr> td width="128" class="text_12">Namn</td><td width="131"><input type="text" name="namn" size="22" value="<?=$s_namn?>" /></td></tr> <tr><td class="text_12">Adress</td><td><input type="text" name="adress" size="22" value="<?=$s_adress?>" /></td></tr> <tr><td class="text_12">Postnr</td><td><input type="text" name="postnr" size="20" value="<?=$s_postnr?>" /></td></tr> <tr><td class="text_12">Ort</td><td><input type="text" name="ort" size="20" value="<?=$s_ort?>" /></td></tr> <tr><td class="text_12">Telnr</td><td><input type="text" name="tel" size="20" value="<?=$s_tel?>" /></td></tr> <tr><td class="text_12">E-mail</td><td><input type="text" name="email" size="20" value="<?=$s_email?>" /></td></tr> <tr><td class="text_12"> </td><td> </td></tr> <tr><td class="text_12"><input class="skicka_knapp3" type="submit" name="sok" value="Sök funktionär" /></td><td> </td> </tr> </table> </form> <?php } } // Stänger anslutningen till vår databas mysql_close($connection); ?>
  14. Apologies, I'm not the best at explaining. I have some data, an example of the data is as follows: ID | Type | Age | Name 01 | CAT | 12 | JOHN 02 | DOG | 13 | EDWARD 03 | HORSE | 02 | MARY 01 | CAT | 12 | JOHN I want to stick this data into an array and then I want to strip out the duplicates by ID, so if the ID is the same as another I want to remove it from the array. However the key (?) cannot be the same as another and I only *think* array_unique supports removing by duplicate key. Does this make sense?
  15. I have some data that I'm putting into an array, the data is as follows: non unique ID (can occur multiple times), name, description and colour. Now, once I've compiled all the data I want to strip out the duplicates by ID, so if I have 3 with the ID of 8, I only want to display 1 of these. $id = 1; $name = "name"; $description = "description"; $color = "colour"; $array[$id]["name"] = $name; $array[$id]["description"] = $description; $array[$id]["color"] = $color; However if I try and do array_unique (assuming I have multiple $id) it doesn't work. Is there anything I should know? Must an array key be unique? If so; how can I use the id as the thing for array_unique to try against? I've read the manual multiple times and I can't work it out. Thanks :3
  16. Hello, regex makes my head hurt. If I have: <div id="this">HELLO!</div> and I want to find out what's between <div id="this"></div> I'd just do: preg_match('%<div id="this">(.*?)</div>%sm', $string, $result); and it works fine, but if I have: <div id="this"> <div id="subthis"> hello </div> </div> and I want to get the contents of the div "this", it doesn't work. I'm assuming this is because of newlines and any whitespace. How would I avoid this?
  17. I'll try that then, thanks I was considering looping, but I assumed it was simple enough to just add ['extralarge'] or an image size somewhere
  18. <sizes> − <size name="original" width="300" height="300"> http://userserve-ak.last.fm/serve/_/2457865/Basshunter+126073.jpg </size> <size name="large" width="126" height="126">http://userserve-ak.last.fm/serve/126/2457865.jpg</size> <size name="largesquare" width="126" height="126">http://userserve-ak.last.fm/serve/126s/2457865.jpg</size> <size name="medium" width="64" height="64">http://userserve-ak.last.fm/serve/64/2457865.jpg</size> <size name="small" width="34" height="34">http://userserve-ak.last.fm/serve/34/2457865.jpg</size> <size name="extralarge" width="252" height="252">http://userserve-ak.last.fm/serve/252/2457865.jpg</size> </sizes> How would I get each size by their name? So if I wanted to call "small" or "extralarge"? $xmlData->images->image->sizes->size what comes after that? adding ['extralarge'] after size doesn't work.
  19. I do a similar thing on a forum I run; a user can mark a topic as fixed, however I also have a "is this topic a bug?" flag when posting. Is that not possible here? Have a drop down that defaults to nothing that the user must select; Yes it is a problem or No I'm not asking for help, if not then it's removed from any "not solved" searches and if they mark it as Yes it is a problem and it's not marked as solved you include it in the searches? I guess you'd also need to allow users to vote a topic as solved though, so that we don't end up with solved topics as unsolved etc. having a "show all unsolved" would be great, definitely worth considering and the extra work would be worthwhile...
  20. It's impossible to be 100% accurate in knowing if a user closes the page. If you're building a chat application you'll be constantly polling the server, correct? So have the server check if the user is still polling, you can assume if after xx seconds the user hasn't polled that they're no longer connected. You shouldn't rely on the client to provide disconnection/connection messages, user the serverside to do that.
  21. heh, yeah, I'm a sort of "hmm, that does look very hard but I guess it'll save me time..." then end up quitting because it's too complicated for my non-programmer brain to handle on that note, can't get adding new lines to work now. by default . ignores new lines, but mine has new lines and adding /s (the modifier) doesn't seem to work. Damn you regex!
  22. works beautifully, thanks! I was missing out the ? before, regex is confusing. Thanks ever so much for the help, solved and appreciated!
  23. I have to agree with presentation, if you present your problem clearly you're much more likely to get an answer. The best approach I've found is to first explain what you're trying to achieve, show your current code, show your current results and explain how they differ and include as much information as possible. If you just say "This is my code it doesn't work" nobody is going to know what you're trying to achieve. 1. Explain what you're trying to achieve, include an example that is as descriptive as possible 2. Explain what methods you're using now and any methods you think might be appropriate, whether or not you understand them 3. Show your current results and how they differ from the desired results, make sure you show the difference clearly 4. Post as much code as possible, make sure EVERYTHING that you're using is included, so if you're calling an external function make sure you show how it's define 5. Be willing to re-explain and be as polite as possible, everyone is here on their own time and they're doing you the favour, not the other way around. That's what I "follow" and I don't think I've ever gone away without an answer, I do find myself sometimes re-explaining, but when being polite and patient that's never a problem
  24. This works perfectly, however if I want to go "more advanced" I'm sort of lost: If I wanted to find EVERYTHING between <div class="something">{HERE}</div> how would I do it? Let's say, for example, I have: <div class="something"><div id="rofl">dfssdffds</div><img src="lol.jpg"><a href="#">dfsffs</a></div> and I want to match between <div class="something"></div> So I want it to return: <div id="rofl">dfssdffds</div><img src="lol.jpg"><a href="#">dfsffs</a> How would I match that? I tried playing around with it but I'm lost, any ideas? Thanks for the help so far
  25. Hi, I've been using explode to split the contents of a page for a while now, if I wanted to find "<span class="hello">hey there!</span>" on a page I'd just do "explode('<span class="hello">hey there!</span>', $page);" however now I'm in a position where "<span class="hello">hey there!</span>" appears multiple times on a page and I need to retrieve each one. How would I go about doing this for multiple things? I'll give an example of the output I want to check: <div class="something">Hi there!</div> <div class="something">Hello!</div> <div class="something">hi i am</div> <div class="something">rofl</div> <div class="something">dsfssdf</div> and I want to get the contents of each <div class="something">. I assume this will require more than just using explode, regex maybe? I know how to get a single one using explode, but not multiple. So the final result would be an array like: $somethings[0] = "Hi there!"; $somethings[1] = "Hello!; $somethings[2] = "hi i am"; any ideas?
×
×
  • 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.