Jump to content

Mr_CHISOL

Members
  • Posts

    404
  • Joined

  • Last visited

Everything posted by Mr_CHISOL

  1. You took that out of context... that code is ok, but this isn't (first post)$nav = '<div id="div"><a href="#"><img src="<?php echo"$site"; ?>img/pic1.png" alt="pic1" /></a><a href="#"><img src="<?php echo"$site"; ?>img/pic2.png" alt="pic2" /></a></div>'; The code I had (in the quote) is what that the script would output on echo $nav;... well, it's easier with file_get_contents() (just one row)Oh, well with ob you get yhe output of that code, but that could be accomplished via file_get_contents to, but then you run that script seppearately..
  2. Do you want to put the contents of the file in a variable?If so, take a look at file_get_contents().
  3. Ehum, Just a note to justsomeguy... ;?)http://w3schools.invisionzone.com/index.ph...amp;#entry67870
  4. It doesn't matter, unless your planing to use it for calculating, "123" is still 123 but s a string... but I think that that's not important here as it looks as temporary "testing data".
  5. It's that when we get total_pages we divide total posts with how many posts you want on a page which give you a float, and I (as stupid as I am right now, apparentely) forget about that and happily taught that you get a nice integer... :?|
  6. First, Previous and 1 shouldn't be links as you are on the first page (use the CSS-class disabled_page to make this more "visible").What is the file called (I thought it was called viewtopic.php or mmabjj_viewtopic.php) You need to have the right filename in the link (or remove the filename and just use ?id=...), make sure you have it (do you have this site live?)What bothers me is that you can't see the second page, but you can see the first, prev etc. Oh I think I know ht the problem is... (Stupid mistake...)Ok, to fix this add ceil() around $total_pages here (EDIT):$total_pages = ceil($total_count / $per_page); Again, sorry for my mistakes, I have alot to think about right now.. :?|ps Hope you look at the code I learn (from my mistakes...) ;?) ds
  7. Sorry if there was some ' missing, my browser doesn't show ' and " good together in the textarea (guess I need to change the settings...).Sorry for the total_count, I tought that we had used it before (maybe another post), but you can use the same code as in the 2nd code-block to set the total_count:$cnt_res = mysql_query( "SELECT COUNT(*) FROM $tbl_name2 WHERE question_id=$id" ); $total_count = intval(mysql_result( $cnt_res, 0 )); The first/last, next/prev links should be shown if $total_count has the right value...
  8. Ok, first:Here's how to handle previous/next, first and last (including the code I postd before...) $total_pages = $total_count / $per_page;if ($total_pages > 1) { $tags = array(); if ($page == 1) { $tags[] = array( '<span class="disabled_page">', '</span>' ); $tags[] = array( '<span class="disabled_page">', '</span>' ); } else { $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=1">', '</a>' ); // First $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=' . ($page - 1) . ">', '</a>' ); // Previous } echo $tags[0][0] . '<< First' . $tags[0][1] . ' '; echo $tags[1][0] . '< Previous' . $tags[1][1] . ' ';}for ($i=1; $i <= $total_pages; $i++) { if ($i == $page) echo '<span class="disabled_page">'; // changed the class else echo '<a href="viewtopic.php?id=' . $id . '&page=' . $i .'">'; echo $i; if ($i == $page) echo '</span>'; else echo '</a>'; echo ' ';}if ($total_pages > 1) { $tags = array(); if ($page >= $total_pages) { $tags[] = array( '<span class="disabled_page">', '</span>' ); $tags[] = array( '<span class="disabled_page">', '</span>' ); } else { $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=' . $total_pages . '">', '</a>' ); // Last $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=' . ($page + 1) . ">', '</a>' ); // Next } echo $tags[1][0] . 'Next >' . $tags[1][1] . ' '; echo $tags[0][0] . 'Last >> . $tags[0][1] . ' ';} That's not perhaps the perfect example/code (from a visitors p.o.v.), but it works fine...
  9. Well, I don't think you did like that, cause tha's not valid, but it could look like this: $total_pages = $total_count / $per_page;for ($i=1; $i <= $total_pages; $i++) { if ($i == $page) echo '<span class="bold">'; else echo '<a href="viewtopic.php?id=' . $id . '&page=' . $i .'">'; echo $i; if ($i == $page) echo '</span>'; else echo '</a>'; echo ' ';} That would work ok!ps Sorry if I misunderstood you, but you can also see how to create the link from the code... dsEDIT (as you posted a new one when I was writing this ), this is gonna be short as I'm going to bed soon, but why do you get the max id from the db and then give the post an id yourself, why don't you leave that to MySQL, its much mor esimplier, just set auto_increase on the field (and prmary key... but I guess that's already done)Good Luck and Don't Panic!
  10. Hi!Try this: if (isset($_GET['page'])) $page = intval( $_GET['page'] );else $page = 1;$per_page = 15;$start = (($page - 1) * $per_page); // The "+ 1" shouldn't be there.. And then just $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id' LIMIT $start, $per_page"; As long as all the variables is set and the values is right, then it should workThe + 1 tells MySQL to skip the first post...You wouldn't need the { } around the variables in the string.
  11. First the problem with intval:It doesn't mather where you put it, but I would put it by $id = $_GET...: $id = intval( $_GET['id'] ); To put it in the query use this: $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id=" . intval($id); To add a value to the querystring you need to use a ampersand (&): index.php?id=1&page=2When you didn't use a ampersand nor intval yot get an error because the SQL would look like this INSERT INTO the_table(view) VALUES('view') WHERE id=1page=2 (Not sure on what you want to do with this query, it doesn't look good to me...)(Not sure what hapends if there's two q-marks in the querystring)Good Luck and Don't Panic! ;?)
  12. I know I'd by at least three ;?) It has, and now we have Ubuntu, it's very easy to use and most "standard components" (ex. most wifi-card use the same base) work.It's a realy good idea.We need to join together and make the companies do that, together we are strong. ;?)
  13. Mr_CHISOL

    Reading raw XML

    :?)The reason for that is prob. that Lynx doesn't have support for XSL, where IE, FF etc does. Then the server generates the source so it can work with lynx too..
  14. A little note: You could a link that says "Hear this text" (on CAPTCHA etc) (I've seen it on some sites). The problem would be to generate the soundfile.
  15. Mr_CHISOL

    Reading raw XML

    Add the user agent to the header again: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Discovered while using wget with default UA that I got it as HTML, but when I used that UA-string in the headers I got it has XML.
  16. Don't forget to use md5() or sha1() on the password if you did that when inserting the user-data into the table...
  17. Mr_CHISOL

    Reading raw XML

    Hi!Try to change this: while (!$end) { $line = fgets($fp, 2048); if (trim($line) == "") $end = true; else echo $line; }{/code]to[code] while (!feof($fp)) { $line = fgets($fp, 2048); echo $line; } Your code will stop ath the first empty line(s)/return, this isn't good as it can be empty lines in XML.It's better to check for eof instead..You could also use file_get_contents() to get get file: $text = file_get_contents( "armory.wow-europe.com" ); It could, but shouldn't make a difference if it's the default UserAgent or Mozilla...Other than that I can't see why you would get just a part of the xml-file..Note, visited the site, and it wasn't until some clicks and a url like this: http://armory.wow-europe.com/#search.xml?s...Type=characters that you got a character-list and that one you can't thru sources (as it uses ajax) but if you know which file that generates the list you should be able to go to that one to get the xml...Good Luck and Don't Panic!
  18. First: I know this is getting off-topicThere's a-holes in every part of the community/society (eaven where you least expect it).It's sad to see that there's alot of them in both Linux- and programmin-forums. Every timeI see a post like RTFM (or alike) I feel like jumping thru the routers on the internet and strangle the poster (I'm not violent..)I can't see the reason to why those peoples hangs on the forums when they are not willing to helo. I'm always willing to help those who need help, eaven if I go too advanced some times.Sadly is that those peoples scare people away, there's no logic in theire behaviour)I'm also sad to say that you've right when it's comes to installing new hardware.There's many reason to why it's this way, one is that MS have ALOT bigger budget and can handle default drivers that maches many different cards etc. And because windows is the most popular OS (much thanks to IBM [in the beginning], but also most other PC-makers) most companies only make drivers and/or softwares that work with windows (and in some cases Mac) and leave the *nix-community behind (Nivida is one of the more "kinder"). This will become more true when Vista beginns to hit the customers. Vista will force most developers/makers to only make software and components that works with Vista (it will cost too much to develop for other systems), which will make it harder for Linux users to use new components and developers to make drivers that work with the new components.It's sad that there's not more producers that make drivers for *nix, and it's sad that it should be so hard (in some cases) to get hardware to work with *nix, most work thanks to developers that makes "half-good" drivers on theirs spare-time (they should get much more credit then they get, they're doing a great work, but's not enough). The later versions of the hotplug-system is real good.I would never recommend anyone to use windows (espacially not Vista) (I know it's often easy to install, besides headaches from saving old userdata and files, partitions [mostely what I've heard] etc. ), for the desktop I recommend either Mac OS or Ubuntu, for servers I recommend Ubuntu/Debian or *BSD. (as I said earlier I use XP in VmWare for Photoshop)When it comes to installing new software it's (again) sad that some software needs compilation (in my experience it's about 1 on 25, more or less [often less ... 1 on 50 perhaps]). One great reason to why I preffer Debian/Ubuntu is that there's almost no compilation.I reinstalled ubuntu last week here's how it went:1. download and burn iso-file.2. boot (it's an live cd) (It finds my both network cards, ethernet and wifi and let me configure the wlan with no problem,it chooses DHCP by default)3. choose he install-icon4. A wizard starts that guides you thru the installation (yes, graphical)5. I choosed a more advanced installation way to keep my home-dir and "data-dir" (both seperate partitions), partioned the disk and choosed mount-points (this wouldn't be needed in a less advanced or fresh install) Sadly the installation-script had bug, but a search in the ubuntu-forum fixed that (I hope they fix that bug soon)5. The installation goes for a while, installing everything you need (It finds my both network cards, ethernet and wifi and let me configure the wlan with no problem,it chooses DHCP by default)6. Reboot7. Login8. You have (almost) complete system (browser, word-processors, editors, games, gimp, mail-client, IM etc.)9. As I needed a some more software: VLC, Apache, MySQL, PHP, Bluefish (editor with a file-tree in the UI), KDevelop etc. I started synaptic (or Package handler), it asks for my password for security. Synaptic shows you a list of categories of different apps (all searchable) (you can add repositories to expand the list to contain the apps you need) I choose the apps (you can also choose to reinstall and uninstall), click on apply, it checks dependencies and then download the packages, installs them and it's all done.10. DoneNow that wasn't too hard ;?)Synaptic runs checks in regular intervals and will tell you if there's an update (both for all software installed via apt/synaptic and the OS) and ask you (it's not in your face...) if you want to download and install the updates, no problem (where win only checks for OS components, the rest is up to the different apps).There's no need to compile anything, it's all done by automatic, just push the button, wait for the downloads and then it will start installing (somw software may need configuration, if so the program tells you and you get some fields to fill in...)No choosing where to install the files etc.The root comes "inactive" by default (the password is a random string),but you can user sudo to do things as root, it will ask you for your password.Hotplugging works great, insert your memory-stick, cd or camera, it finds it an mounts it by automatic (just as in win).the CD is mounted in /media/cdrom by default, memory-stick in ex: /media/name (/media/H300 for my mp3-player and /media/CORSAIR for my memory-stick). There's also no problem mounting a NAS.I must agree on that the developers should stop fiting about which Window-/Desktop-manager that's best (it's GNOME, Xfce and Fluxbox btw).They should try to work together to make a better system and apps, we know they can they just need to put their ego away.Didn't get that thing about unable to boot the CD-ROM device....
  19. astralaaron: Sure i know of Magnus Samuelson ;?)NOTE: Ego warningjustsomeguy: I guess you and I have had different experience when it comes to Linux and Win. I can't say that I ever had a plessant or enjoyable time when using Win (and it almost hurts to call win ""userfriendly""). But when i used Linux (mandrake, but still it's linux ) it felt like home. I have never had a problem in Linux that I couldn't handle and I can customize it almost how ever I want whithout much fuzz.But win is harder to customize (in the same way), it's often harder to get a reasonable help, a call to helpdesk can sound like this (if you baught a PC from HP, with win pre-installed):HP: Well, I'm can't help you with that problem I don't know how to fix it. Call Microsoft helpdeskMS: So you baught it from HP, with a OEM-license, then we can't help you, it's either HP or the store where you baught it that would help you.YOU: Ok, HP told me to call you, so why can't you help me??MS: We don't offer support on OEM-licenses, it's the retailers job to give your support on our products (Ok, they don't say that last straight to you, but that's what they mean..)I have heard of many calls that went that way (it's a bit simplifiied, but you get the idea).(I know the "professional support" for Linux isn't that big, but they're more helpfull plus there's a big community that gladly help others in most cases)Besides GNU/Linux is free (as in freedom, but also [in many cases] free as in free beer) and comes in many shapes and tastes, the only thing I'm missing is age of Empires and Photoshop... :?)I'll never go back to windows (I have installed XP using vmware...) and absolutely not Vista
  20. It feels like I've heard that nam before, but can't say that I know who he am.I live in a villgae about 20km outside th city called Lidköping (mid-sized town), called Söne, in the west of Sweden.Here'a a link to Google Maps ;?)
  21. Haven't tried it, it may work.Spambots behave in different ways, some scans the whole form, and then post depending on what the fields is called and some just scan the action-argument on the form-tag and use default (or pre-scanned) fieldnames.I had a problem with the latter, I use captcha, but forgot to check if the code-field (and the saved code) was empty (or eaven set), so the bot(s) kept posting as usual (ignoring the new code-field), so it could keep posting...But it should work on both type of bots
  22. It was just to clarify things...
  23. They use different algorithms to get the "hash" (I linked the function names to the manual pages...).A hash is a long number (often in hex) that only (should) match one string (so 'a', 'b' and 'aa' will give different hases), it's often use as a checksum to check that, i.e., the file you downloaded is the same as the one that was put on the webpage originally...md5 use a algorithm called "RSA Data Security, Inc. MD5 Message-Digest Algorithm" (RSA is often used in beginning of secure connections)sha1 use a algorithm called "US Secure Hash Algorithm 1" (sounds like it's US specific... )Don't know if there's a big difference between them, but md5 returns 32 chars and sha1 returns 40 chars...
  24. First: Anders, I don't expect him to understand swedish (I could left out the link to shellkonto, but I didn't), then I would like to here what things you have heard, so far it worked fine for one of the sites i'm working on (only problem is that's a bit slow sometimes), and it is about as cheap as you can get it.Yes Linux (to be strict, it's called GNU/Linux, as Linux only are the kernel) is an (superior... [that goes for the whole *nix group]) OS (it's abit similar to Mac OS, as both are "versions of unix").What you have on your own computer doesn't matter in this case, as it's what the host is running that's interesting. Most hosts does use GNU/Linux (or *BSD) and apache (can't remember the %), but some don't.GNU/Linux (or *nix) is always to preffer (espacially when it comes to servers), it's abit more secure (mainly because there's a lot less viruses and such written for *nix). It also tends to be more stable, and cheaper. In my opinion it has a superior file-system layout too.If we would be more specific, the preffered distributions would be (again, my opinion) Debian or Ubuntu (same, same but different..), but that is something that you (as a normal customer to a host) don't need to be concerned with.Hope that cleraed things up for you. I would gladly answer any questions you have on *nix and/or webhosting..EDIT::Note on Anders reply: You can run both ASP and ASP.net on GNU/Linux (as one.com among others) and you can also run PHP (with IIS or Apache) on M$ Win.The thing is that PHP is almost "native on *nix" (Couldn't come up with a better world) as VB and ASP is "native on win". It's often much easier to get PHP working in *nix than win (was along time ago I used PHP on win, so i may have changed...).
  25. Most webhosts don't allow shell access and just have phpMyAdmin and/or theire own adminpanel.I know there's a host here in sweden (123.shellkonto.se) that have shell-access, also found those: www.prchecker.info/web-hosting-ssh.php.As I have my own server I have both shell access and phpMyAdmin (for free... ) and I almost never use ssh/commandprompt to admin MySQL (I used it for other things like apache, mailserver, torrents, etc), I use phpMyAdmin as it's much easier to work with then with commands when it comes to MySQL.The main things you should look for when choosing host is: PHP (5 +), MySQL (Linux is an advantage), ftp-access, enough space and low cost. One of my favorite hosts are one.com which gives you all that to a very low cost... (Didn't mean to sound like a seller, the fact is that it's a good host...):?)
×
×
  • Create New...