Jump to content

Mr_CHISOL

Members
  • Posts

    404
  • Joined

  • Last visited

Everything posted by Mr_CHISOL

  1. Make sure that xampp is running, not sure on how (maybe the "task list" Ctrl+Alt+Del, look for xampp or apache)Do you have Google Dekstop toolbar (or what it's called)? It may have taken port 80 so that xampp can't listen on it.Kill google desktop (or uninstall it...) and restart xampp.Can't think of anymore right now (also check your firewall...)
  2. First move the function outside the while-loop (above it or in a include-file where you store all your functions that's needed in more than one script...)Second: Tried the following: ....print_r( $patterns );echo preg_replace( $patterns[0], $patterns[1], "[b]aa[/b]\n[i]ddd[/i]"); and it looks Ok...This feels wrong: $_message = preg_replace( $patterns[0], $patterns[1], $rows['a_answer']);?>?><table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"><tr> did you remove something before posting or does it look like this? Any way that shouldnt be the problem, I will tak a closer look..This is also wrong: while($rows=mysql_fetch_array($result2)){<?php... // Here comes the function (The function should be moved, but this is still wrong...)Also noted that you end and start the php-code block many times (and most of them for no good reason). Ex: <?php } else { ?><?php include("../log_in.php") ?><?php } ?> this is better and is easier to debug: <?php } else { include("../log_in.php"); } ?> And also try to be concistent in your use of <?php and <? (use one of then, the first is recommended, all the time...)Do you have this site live to the web? or can you post the output...
  3. Yes it's better to have the "formatting" done when displaying instead of posting, here's one advantage:You write your text, post it and then discoveres that you did something wrong, misspelled or just want to add more text.Then when you open the post for edit (as you can do in in this and most forums for example) you will see the HTML-code, which make's it harder to read and understand, for all of us, but mostely those who doesn't understand HTML...You are almost right; will not be replaced with <b>, as it's not valid XHTML, it would be replaced with <span class="bold">, so you need to add a class named bold to your CSS (if you don't have one, aswell add an italic class etc.Why not use <b>, <i> and <font>? It's simply not valid "anymore" (XHTML-standards), and why write "unvalid code" when there's no big difficulty in writing valid code.First, the thing with flexible codes is that's there (often) not a ""serious"" use of them (there is in some applications), as I said.Some examples of flexible code: // code => use => result[date] => Current date is [date] => Current date is 2007-04-06[time] => Current time is [time] => Current time is 13:37[user] => Hello [user], Greetings! => Hello morrisjohnny[daysleft 2007-04-13] => There's [daysleft 2007-04-13] days left to friday the 13th => There's 7 days left to friday the 13th EDIT:Did you included the function that I posted together with that code?Tested the function on my computer and worked as intended
  4. The linebreak code is included in the examples, but yes, put it where you put the linebreak code.Just taught of something, when do you run this code, when you add the post to the db or when you display it.The best would be the 2nd; when you display it, this also means that you can add more flexible "codes" if you would like (as counting days to a surtain date), but that's more for fun then real use (often at least...) ;?)Yes, it should come out as html, unless you have something that removes html-tags or something like that.
  5. the easiest way to use bb-/format-code is tou use preg_replace and arrays: $patterns = array();$replaces = array();// Add codes$patterns[] = '/\[b\](.*)\[\/b\]/'; // Matches [b]TEXT[/b]$replaces[] = '<span class="bold">$1</span>';$patterns[] = '@\[i\](.*)\[/i\]@'; // Matches [i]TEXT[/i] , The @'s let us skip the escaping of / in [/i] (see the one above for refference)$replaces[] = '<span class="italic">$1</span>';$patterns[] = '@\[url\](.*)\[/url\]@'; // Matches [url]URL[/url]$replaces[] = '<a href="$1" target="_blank">$1</a>';$patterns[] = '@\[url=(.*)\](.*)\[/url\]@'; // Matches [url=URL]TEXT[/url]$replaces[] = '<a href="$1" target="_blank">$2</a>';$patterns[] = '@\[color=(.*)\](.*)\[/color\]@'; // Matches [color=COLOR]TEXT[/color]$replaces[] = '<span style="color: $1">$2</span>';// Adding the newline replace here, then you don't need multiple call to a replace function...$patterns[] = "/\n/";$replaces[] = "<br />\n";$_message = preg_replace( $patterns, $replaces, $_POST['a_answer']); Then you can expand the list of patterns with anything you need, you could also add some sort of syntax check for the url's and maybe some pattern that "auto-detects" web- and mail-adresses which doesn't have </a> or <a href="http://" target="_blank">.EDIT:You can use this function if you feel that the way to add patterns above is abit complicated: /** * AddPattern * @param list The array/list to add the pattern to * @param pattern The (perl) regular expression pattern to add * @param string The string that the pattern should be replaced with * @param escape Should we "escape" the pattern (escapes /, [ and ] ) and adds * "delitimers" ( /pattern/ ) and any defined "rule" * @param modifs Any modifiers that should be added to the pattern (ignored if escape is false) * could be i (case-insensitive) etc. (see manual) * @author Christopher Hindefjord - Mr_CHISOL - Kachtus.net 2007 **/function AddPattern( &$list, $pattern, $string, $escape = false, $modifs = '' ) { // Just in case... if (!isset($list[0])) { $list[0] = array(); $list[1] = array(); } // If we should "escape" the string and treat it... (default: No) if ($escape) { // Escape... $pattern = str_replace( '/', '\/', $pattern ); $pattern = str_replace( '[', '\[', $pattern ); $pattern = str_replace( ']', '\]', $pattern ); // add / $pattern = '/'.$pattern.'/'.$modifs; } $list[0][] = $pattern; $list[1][] = $string;} Here's how you could use it (see http://www.php.net/manual/en/ref.pcre.php for more info about reg.exp and modifiers): $patterns = array( array(), array() );AddPattern( $patterns, '[b](.*)[/b]', '<span class="bold">$1</span>', true, 'i' ); // ignore case and escape itAddPattern( $patterns, '[i](.*)[/i]', '<span class="italic">$1</span>', true, 'i' ); // ignore case and escape itAddPattern( $patterns, '[url](.*)[/url]', '<a href="$1">$1</span>', true, 'i' ); // ignore case and escape it// You can add the rest yourself...// Adding the newline replace here, then you don't need multiple call to a replace function...AddPattern( $patterns, "/\n/", "<br />\n" );$_message = preg_replace( $patterns[0], $patterns[1], $_POST['a_answer']); Please NOTE: the function is currently untested, but it should work just fine...
  6. Then you have a problem with your system, it's an exe and should be saved as an exe, either rename the file with a correct .exe extension or downoad it again and make sure you save it as an .exe.A php-file IS a textfile, but with a .php extension, the default is for notepad (or your default text-editor) to open it, if you don't install a software (editor) that opens the php-file (UltraEdit would be a good choice for example, any-one with a good syntax-highlighting should work ok)To upload the file to a host can be an idea, but it usally not recommended when you are developing. Unless you can edit it via FTP (UltraEdit among others have support for this), one problem with that is also the speed of your connection (right now I have 0.5Mb/s, and I feel some frustration when editing files via ftp...)Good Luck and Don't Panic!
  7. If your using str_replace as this: $_message = str_replace('/\n/', '<br>', $_POST['a_answer']); you need to change it to: $_message = str_replace("\n", '<br />', $_POST['a_answer']); I removed the slashes (/) as they are a part of the reg.exp. (Perl-style) which str_replace() doesn't use.I also replaced the sinqle-quotes (') with double-quotes (") as escapes (\n) aren't treatet in "sinqle-quote-strings".Also replaced the break-tag with a "corrct" XHTML-syntax... :?)All this also means that if you want use preg_replace it would look like this: $_message = preg_replace("/\n/", '<br />', $_POST['a_answer']); NOT: $_message = preg_replace('/\n/', '<br />', $_POST['a_answer']); Hope that helped. Good Luck and Don't Panic!
  8. Did you forget the ending semi-colon ( at the line above that line?I think that's something like that, that generates the error, as there's no apparent problem with that line.Check your syntax.. :?)
  9. You could also use Joomla!, it's a nice, easy-to-use CMS with member-logins etc.There's a lot of different extensions for Joomla!, for example forums and "downloading" components (take a look under extensions). There's also a component called CommunityBuilder, it makes building a community a bit easier than doing the installing of the different parts yourself (I think it have a forum that comes with it).I really like Joomla! it easy to use, one downside is the lack of "custom gruops" (you have three levels on the frontend and three levels on the backend..)Good Luck and Don't Panic!
  10. What FirefoxRocks says is true. But both issues could be solved with one solution: a firewall.When you use a firewall you can stop any traffic in to your (I know that most users have a firewall, at least in their router or modem). I would recommend ZoneAlarm (DON'T use windows internal firewall). A firewall stops all incomming traffic so your ISP shouldn't find out that you have a server ;?) and it shouldn't mather if you have sserver, just don't have it "public"...
  11. Can you please describe what problems you're having? Such as any error messages or logs that is displayed for you.Note that it can be a bit tricky to get IIS to work with PHP....
  12. That's one way to do it. But with XAMPP you get it all in one package, everything is configured to work with eachother from the beginning, no need to instal multiple packages and headakes when trying to configure them to work together...And then you ofcourse get a superior server-software ;?)I'm not a big fan of M$ work (can you tell??), much bugs and such (read about a new bug Vista today...) and what I can remember from IIS (a few years ago) is that I simply didn't like it and that there wasn't to much "good help" (forums and such) to find, Who knows, this may have changed.But one thing I'm sure of is that apache is one of the best (the best??) server softwares outhere, it's free, it's well written (as all softwares it has it's bugs, but there's almost allways someone that has expiierenced the same and are willing to help), a good (and big) community etc Oh did I say this? It's FREE... What more do you need ;?)Ok, one bad thing whith Apache may be that it can be tricky to configure as you want it, it's not impossible, just a bit tricky (I'm having some conf troubles whith my serve, but it should be fine after my next xhange..)Well, alot of "propaganda", and remembe this is my own personal thoughts.... :?)I hope we can welcome a new member to the Apache and/"or" the OpenSource community... :?) :)
  13. Hi!You need a server-software to run the script, either you have a host where you can put your work and test it, or you need a server on your computer.One of the best server-softwares is Apache it works on many platforms and does it well.The easiest way to get apache and PHP to work in Win (it's helpfull in other OSs too..) is to use XAMPP. With XAMPP you get both apache, PHP and MySQL, and it shouldn't be to hard to install.Good Luck and Don't Panic!
  14. Hi!You need to add slashes (/) to the start and end of the pattern (using PERL-style reg.exp): $rule= '/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/'; Hope that Heped...Good Luck and Don't Panic!
  15. Mr_CHISOL

    thumbnail

    The text should not appear.You first output the image-data to the browser and then some text-data, there's a difference between those two.The browser get the image-data (and I guess it's ended with EOF or something like that) and the "ignores" the text...To write a string onto the image you can use imagestring().
  16. Hi!PHP doesn't parse PHP-tags in strings, what you'll get (as output) with that code is <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> to include values of variables in a string there's two ways, use doubl-quotes and use the var. name directly in the string or use single quotes and concat the string.Double-quotes ("): $nav = "<div id=\"div\"><a href=\"#\"><img src=\"$site/img/pic1.png\" alt=\"pic1\" /></a><a href=\"#\"><img src=\"$site/img/pic2.png\" alt=\"pic2\" /></a></div>"; You actually did this, in your echo: <?php echo"$site"; ?>, why I don't know, as you don't need it...And with single-wuotes ('): $nav = '<div id="div"><a href="#"><img src="'.$site.'img/pic1.png" alt="pic1" /></a><a href="#"><img src="'.$site.'img/pic2.png" alt="pic2" /></a></div>'; psI would give the div a better Id than div ;?)dsHope that helped...Good Luck and Don't Panic!
  17. Hi!First, how you do that depends on howw you "store" the xml-structure in your script.I would think that the easiest way to accomplish that is to "transform" (using foreach or whatever) the structure (may it be DOM or SimpleXML etc.) to a "pure hieracal hashmap/array" (you could use the name as the key) and then use uksort() or uasort() to sort the array using a function that compares the name-values.OR, you could write your own sorting-function, but that would be real complicated...Hope that helped...Good Luck and Don't Panic!
  18. Mr_CHISOL

    Year counter

    With "functionallity" you, in most cases, mean how "it function": The result, not the way to get the result.And nomather which you use the result will be same (number of years between 1999 and today).
  19. Mr_CHISOL

    PHP and AJAX

    Don't know if you have removed theline or not, but:Yes the xml worked fine in the file, that's because the table wasn't in the file (you just echoed it to the output/browser, as you also did with the XML) but the JS doesn't read the XML-file, it reads the output from the script and then you had a table-tag before the XML, which isn't valid...Good Luck and Don't Panic! ;?)
  20. Mr_CHISOL

    PHP and AJAX

    OkI think it's this line that messdes it up (I also don't get what it's doing there): echo "<table><tr><th>Count:</th></tr><tr><td>" . $num . "</td></tr></table>"; Remove it from the PHP and try again.Just curius: Why do you save it to a file?
  21. Mr_CHISOL

    mail() function

    Hi!If you use localhost as SMTP you need to have a SMTP-server installed on your system.If you don't know how to install (I'm not sure which server to use for Win) it or don't want to you can use either the one provided (if any) by your ISP, or perhaps gmail or similar...
  22. That's a good question.I can't see another reason to why it does like that (unless you have a problem with the "personal firewall" and/or the browser).It could block a IP from the network but not loclahost for example, but this would perhaps not be the case if you see the page, but not the images...
  23. First:I have no problem viewing the images (wokrs both on the site and direct).Second:From your description it sounds like youre having problems with your server and it's configurations (which do you use?).What the problem is is hrad to tell (as it worked for me), but check the configuration so you don't deny/ban any range of IPs
  24. Here's how you could do it (in theory, no code, sorry)1. Use a query to select the categories which have the id (from _GET) as a parent: 1.a If the query returns empty, then save the id (from _GET) in an array: $cats= array( $_GET['cid'] ); 1.b If the query returns other categories, store them in an array (same name as you would use on 1.a) 2. Loop thru the array and either create a SQL-query with the loop, or run one query for each post/loop to get the products that matches the categoriesThis will work fine in both cases (a "parent cat." or as "sub cat.")Hope that helped..Good Luck and Don't Panic!
×
×
  • Create New...