Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Everything posted by DeanWhitehouse

  1. Not working, i tried this if(preg_match('/\[user=(.*?)\]/s', $code, $regs)) { $sql = mysql_query("SELECT id FROM user_details WHERE username = '".mysql_real_escape_string($regs[1])."'"); if(mysql_num_rows($sql) == 0) $code = preg_replace("/\[user=(.*?)\]/s","\\1",$code); else { $code = preg_replace("/\[user=(.*?)\]/s",CreateUserLink("\\1"),$code); } } The bit where the link should be is empty
  2. Have you tried the phpfreaks tutorial on it?
  3. No that code is fine, the fact is that after debugging i found out that the sql query is returning 0 rows although if i do it myself it doesn't, this is because i believe all the other text in the $code var is being sent as well, not just the bit i need
  4. Never mind, but i have got this now $code = preg_replace("/\[user=(.*?)\]/s","\\1",$code); $sql = mysql_query("SELECT id FROM user_details WHERE username = '".mysql_real_escape_string($code)."'") or die(mysql_error()); if(mysql_num_rows($sql) == 0) $code = $code; else { $code = CreateUserLink($code); } But it isn't creating the link :s
  5. Ok, so i am going to use a user tag e.g. [user = ] but what do i do to find the user? Cus i have $code = preg_replace("/\[user=(.*?)\]","<a href=\"profile.php?user=\\1\" target=\"_blank\">\\1</a>",$code);
  6. Thats the solution i thought off but i am worried about speed issues as there could be a lot of users in the db. I was thinking that it would loop through each user name and check the text for that username and replace it, but i assume this can be very slow?
  7. Hi again i have a little coding problem, regarding regex, i want to write a code that is like bbcode but searches for user names in the content and replaces them with profile links, any idea how i can do this using regex?? Is it possible with regex, or shall i use something like a loop with str replace
  8. Still not working, and "Straight variable comparison would be easier; " not possible as i need a list of unaval steals, which a var can't have (not simply) Jons thanks, clever way to do it wouldn't of ever thought of that, topic solved (as far as i can tell)
  9. The sql would be better, i will change that and Mark, no i am not, please show me an example in my code where i am
  10. Hiya, Long time since i have posted a coding problem, but here it goes. I have created this code to work out what a user can steal from another user, but it seems to allow the user to try and steal anything even if it is on the list of unstealable items, any ideas as to why? Does in_array return a different value than i thought? Code Snippet function StealType($extort) { $car = mysql_query("SELECT id FROM user_cars WHERE user_id = '".$extort['id']."' AND up_for_sale = '0' ORDER BY RAND() LIMIT 1"); $cash = mysql_query("SELECT money FROM user_stats WHERE user_id = '".$extort['id']."' LIMIT 1"); $c_check = mysql_fetch_assoc($cash); $bullets = mysql_query("SELECT bullets FROM user_stats WHERE user_id = '".$extort['id']."' LIMIT 1"); $b_check = mysql_fetch_assoc($bullets); $Not = array(); if(mysql_num_rows($car) == 0) { $Not[] = 1; } if($c_check['money'] < 100) { $Not[] = 2; } if($b_check['bullets'] == 0) { $Not[] = 3; } print_r($Not); if(in_array(array(1,2,3),$Not)) { echo "S1"; return false; } elseif(!in_array(array(1,2,3),$Not)) { echo "S2"; return rand(1,3); } elseif(!in_array(array(1),$Not) && in_array(array(2,3),$Not)) { echo "S3"; return 1; } elseif(!in_array(array(2),$Not) && in_array(array(1,3),$Not)) { echo "S4"; return 2; } elseif(!in_array(array(3),$Not) && in_array(array(1,2),$Not)) { echo "S5"; return 3; } elseif(!in_array(array(1,2),$Not) && in_array(array(3),$Not)) { echo "S6"; return rand(1,2); } elseif(!in_array(array(1,3),$Not) && in_array(array(2),$Not)) { echo "S7"; return 1; } elseif(!in_array(array(2,3),$Not) && in_array(array(1),$Not)) { echo "S8"; return rand(2,3); } } $steal = StealType($extort); if($steal == false) { echo "Failed! This user has nothing!"; } elseif($steal == 1) { echo "To come car"; } elseif($steal == 2) { echo "To come cash"; } elseif($steal == 3) { echo "To come bullets"; } else echo "Error! What the fuck?";
  11. Ok, i will look over it when i get back, it is using php mailer
  12. @Malevolence Except it is considered bad practice to use PHP short tags
  13. @redarrow, whitespace problems occur with HTML whitespace not PHP whitespace. Also Are you serious ?? Try it, using if(isset($_POST['submit_button'])) works if you press the button or if you press the enter key.
  14. lol You might want to try code before asking for help with it
  15. No one here will want to copy your code, if we can help fix it we can most likely create it ourselves. Here is what the code might be like mail($_POST['email'],"Thanks","Thank you for signing up","From: myemail@mysite.com");
  16. you don't need to do that for all variables, but if you have messy code and/or cannot tell if the variable has been set then do that.
  17. Make sure both use utf-8 charset encoding
  18. Read through the security tutorial on this site, it covers that i believe.
  19. It is bad practice to ignore or suppress errors (although some must be suppressed), and bad practice to turn error reporting off while developing, if the site is developed you should develop your own error reporter.
  20. Do not ignore the errors, or turn them off (while developing), fix them, it will make you a better coder and make the code better. All you need to do is make sure that all the variables are defined before using them. E.g. if(!isset($Var)) $Var = "";
  21. What bit? The saving the image bit? If so then i think this will either need to be done manually or using file_get_contents maybe, with some php image functions to create an image from the image. I am just throwing some ideas around
×
×
  • 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.