Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About DarkElf

  • Rank
  1. Works a charm, thanks
  2. Nope, already tried that The str_replace function doesn't seem to like patterns which run across multiple lines. I can't understand why, the \n character seems to have some special rules applied to it that make it behave funny.
  3. I'm trying to write a code that takes a txt file and converts it to html whilst retaining formatting. It all works fine except for one little glitch - where there is a double return in the txt file I want to close the html paragraph element and then open a new one (so the paragraph is properly split using the <p></p> tags rather than double <br />'s). For some reason I can't get it to work properly.I've used nl2br() to convert new lines to breaks (<br />). I've then tried using str_replace() to search for instances where there are two <br /> tags immediately after each other, but it doesn't find them. I think the problem relates to the fact that the consecutive tags are on seperate lines, i.e. i'm not look for:<br /><br />I'm looking for:<br /><br />I would have assumed that to find and replace the latter I could use the following code: <?php$string = file_get_contents(filename.txt);$string = nl2br($string);$string = str_replace("<br />\n<br />","</p>\n<p>,$string);?> But this doesn't work. What's really confusing me is that if I try simply searching for and replacing the 2nd of the two <br /> tags it works fine: <?php$string = file_get_contents(filename.txt);$string = nl2br($string);$string = str_replace("\n<br />","</p>\n<p>,$string);?> The inverse is not true (i.e. it finds "\n<br />" but it doesn't find "<br />\n")On the plus side that last version of code very nearly delivers the desired effect, however it means that there is a redundant <br /> tag at the end of each paragraph that I'd quite like to eliminate.Can anyone explain to me why this happens and how to fix it?
  4. DarkElf

    partial transparency

    Forgive me if I'm wrong, but that looks like they are just shifting the contents of a paragraph not included in the div up the page using position relative so that it appears to be inside the div?It's a nice idea but doesn't quite work for my problem as my div is not of a fixed size.
  5. DarkElf

    partial transparency

    I've been having a lot of fun with this opacity stuff, however I've just noticed a problem on my pages and can't work out how to fix it.Basically I've got a div which contains text and images which has opacity of 75% so that the background image is partially visible through the div. But it turns out that not only is the div itself transparent, but all of its contents are as well. This is barely noticable with black text, in fact until now I hadn't spotted it at all, but once I started adding images its quite obvious and isn't the desired effect. What I want to do is make the background colour of the div only transparent, the contents should preserve their full opacity.Is this possible? I tried changing the opacity values of the images but that only changes their opacity in relation to the div, not the background image!
  6. It's possible to rewrite the php files everytime you update the variables, you just need to set the correct access permissions on the files.But you are creating hurdles you don't need to! What you are effectively talking about is flat files, these used to be all the rage before relational databases. The reason relational databases are now used so commonly is because they are much better at the job.If you really want to use a flat file system I would go back to your xml files. Just place them in a folder without public access, that way a public request for them will be denied but your php scripts (executed on the server) will still be able to access them and do what you want with them.
  7. DarkElf

    Makeing a Online Game!

    There are loads of things you can use to make a game, for your text based style game I would suggest the following:1. A good working knowledge of html/xhtml, css, and javascript (you are making a website after all).2. A good working knowledge on xml - I'm a bit of a hypocrit here as I've never used it much, but it goes with the above point.3. An extremely good knowledge of a server side script such as PHP or ASP, or possibly another more powerful scripting language that can be integrated with the web.4. An extremely good knowledge of a database system, MySQL is a good one for beginners.5. If you want to take this seriously you will really need to run this on your own server........ learn a lot about this.Basically you've got a lot to learn about a lot of things on the internet.
  8. DarkElf

    Transperancy in CSS

    Always check for other threads on your topic before posting, you will often find the answers you are looking for http://w3schools.invisionzone.com/index.php?showtopic=5409
  9. DarkElf

    Blank Field Check

    This is normally something you'd do with javascript before the form has been posted, but if you want to do it with php then you could use a simple if statement to test each field. The best way to do it would be an if with an is not (=!) clause to which will return true if the value isn't empty. Something like: if($_POST('fieldname') =! ''){code to be executed} This can be followed by an else clause if you want it to do something special if the field is empty.
  10. Which assumes you have that kind of control over your server (if you are renting webspace that is quite unlikely!)
  11. What do you mean by tools? as SFB says, php itself can be downloaded from php.net if that is what you mean.If you mean the tools for writing and working with php then you just need a simple text editor such as notepad, nothing more complicated is required.If you want to test php scripts on your pc then you also need to install a server and php, this can be done the easily by using a prebuilt package such as xampp.
  12. DarkElf

    Makeing a Online Game!

    Without wanting to dampen your enthusiasm (which is great).... The coding you need for those kind of games can get pretty complicated (I'm talking thousands and thousands of lines of code). As with a lot of things in life, you can't just dive straight in at the deep end, you need to start somewhere simple and learn the building blocks step by step.Build lots of websites and learn to use PHP to perform simple tasks for these sites. Once you're comfortable with that you can start using it for more complex things and eventually you will gain the knowledge and experience to build your game. You will probably also find you need to learn some other skills such as using a MySQL database.You have to understand that what you are asking for is not something you can write a tutorial on. Its not like there is a set piece of code for these things that you change a few values in and there you have it, if it were that easy everyone would do it. You're talking about something on par with writing your own piece of software. You need to master the basics first and then learn how to apply them to increasingly complex situations.
  13. Not sure where the slashes come in, but I think you can do it using query strings.The query string variable is added to the url: www.mywebsite.com/index.php?page1To retrieve the variable use this: $variable = $_SERVER['QUERY_STRING']; The you can then use variable in your code, this could for example be the name of a file that contains the content to be displayed on the page, therefore you can use your index.php file as a template and import the content using something like this: $content = file_get_contents($variable.'txt');echo '<p>'.$content.'</p>';
  14. You need to store the titles in an array, and then have a subarray under each title storing the subtitles. You can then use nested foreach loops to work through the main array and then each subarray to list the contents.
  15. Ok, I don't approve of just giving people the answer, on top of which I've not got time to try it all out and test it, but here are a few things you could try playing with.The first thing that leaps out is that you've got all those pictures floating left, floats can commonly cause problems in which things spill out of divs (exactly what you are seeing now). You have to have the float there so try and see if you can find another way to ensure the div stays the right size other than purely expecting it to resize to fit the content. If you are only ever going to use the same number a size of images then you can simply set the dimensions of the div. Otherwise you may need to use a script to resize the div based upon its contents, this can be achieved with both server and client side scripts depending upon your preference.The other thing I notice is that all those images are inside a <p> tag, I'm failing to see the neccesity and this may also be possibly causing problems. You can acheive exactly the same effect without the <p> tags be reassigning some of those values either to the div or to the images.Go away and have a play.
  • Create New...