Jump to content

kenrbnsn

Staff Alumni
  • Posts

    8,234
  • Joined

  • Last visited

Everything posted by kenrbnsn

  1. The problem with using MD5 is that it returns a hexadecimal number (characters 0 - F) and not the full alphabet like the OP was using. BTW, the code you posted is missing two ")"... It could have been written as <?php function gr($size=4) { return (strtoupper(substr(md5(rand()*rand()/rand()), rand(1, 20), $size) . '-' . substr(md5(rand()*rand()/rand()), rand(1, 20),$size))); } echo gr(); ?> Ken
  2. If the "*" characters are separators, then you could use the fgetcsv function to read the data, then you can just process. Ken
  3. Or you can use: <?php header("Location: http://www.liutilities.com/affcb/?id=RBgendtd&aff=14231&xat=WU-{$_GET['tid']}"); exit(); ?> Always use the exit function after a "location" header to stop the script from executing further. Ken
  4. Without knowing what that standard looks like, how can we give a meaningful answer? Ken
  5. You can also use the shuffle and array_slice functions: <?php function getReference($size = 4) { $pool = array_merge(range(0, 9), range('a', 'z')); // // if you want to include uppercase letters, change the above line to // $pool = array_merge(range(0,9),range('a','z'),range('A','Z')); $size = $size > count($pool) ? 30 : $size; // base it on the size of the array of possible values, so if you add more this doesn't have to change shuffle($pool); return (implode('',array_slice($pool,0,$size))); } echo getReference(4).'-'.getReference(4); ?> Ken
  6. The easiest way to add attachments to PHP mail is to use a class like PHPMailer Ken
  7. This <?php if($rsbuildings[".$_GET['t']."] == 'leader_id' ) ?> is not correct syntax, it should be <?php if($rsbuildings[$_GET['t']] == 'leader_id' ) ?> Ken
  8. Here you have: <?php if($_SESSION['id']){ mysql_query("UPDATE users SET status=unix_timestamp() WHERE id='{$_SESSION['suserid']}'"); } ?> You should be checking whether $_SESSION['id'] exists before using it. You should also be checking whether $_SESSION['suserid'] exists. <?php if (isset($_SESSION['id']) && isset($_SESSION['suserid'])) { mysql_query("UPDATE users SET status=unix_timestamp() WHERE id='{$_SESSION['suserid']}'"); } ?> Similar is other areas. Ken
  9. We need to see the code that's causing the errors, not just the error messages. That's what I asked you to post. Ken
  10. Please post your code between tags. Ken
  11. "desc" is a reserved word in MySQL. Either rename your column or surround it with backticks: <?php $q = "INSERT INTO applications (aid,cid,name,charactername,gender,race,`desc`,mg,pg) VALUES ('".$_COOKIE['ID']."','$insertid','".$_COOKIE['Username']."','$name','$sex','$race','$description','$mg','$pg')"; $appquery = mysql_query($q) or die('Could not insert using the query, $q:<br> ' . mysql_error()); ?> Ken
  12. Please post the form that is being used by this script. Ken
  13. This code works: <?php session_start(); $urna=array_merge(range(0,9),range('a','f')); $_SESSION['hit'] = (!isset($_SESSION['hit']))?0:$_SESSION['hit']+1; if(($_SESSION['hit'] % 4) == 0) { shuffle($urna); $_SESSION['culoare'] = '#' . implode('',array_slice($urna,0,6)); } ?> <html> <head> <title>Random Background</title> </head> <body style="background-color:<?php echo $_SESSION['culoare']; ?>"> <?php echo '<pre>' . print_r($_SESSION,true) . '</pre>'; ?> <form method=post> <input type="submit" name="submit" value="Schimba culoarea" /> </form> </html> Ken
  14. Use a combination of parse_url and basename <?php $x = parse_url($_SERVER['HTTP_REFERER']); echo basename($x['path']); ?> Ken
  15. See this section in the manual about how to turn them off. If you can't do it, ask your host to turn them off. As it says in this section Ken
  16. What do you mean by Magic quotes on or off shouldn't matter to this script. Ken P.S. Learn how to spell "length".
  17. Do some debugging on your own. Put echo statements in to show what values are being used: <?php $has_voted = mysql_query("SELECT date FROM votes WHERE ip = '". $_SERVER['REMOTE_ADDR'] ."'"); $grab = mysql_fetch_assoc($has_voted); $cur = $time(); echo "Current time: $cur<br>\n"; $saved = $grab['date']; echo "Saved time: $saved<br>\n"; $diff = $cur - $saved; echo "Diff: $diff<br>\n"; ?> This should show where the problem lies. Ken
  18. Are you displaying the value after processing it with the [m]mysql_real_escape_string[\m] function? If so, that is probably the cause of your problem. Ken
  19. Again, what does $grab['date'] contain. Also, you want to subtract the old value ($grab['date']) from the current time. When you do it your way, you will get a negative number which will always be less than 3600. :-) Ken
  20. What is the format of $grab['date']? To get the current date in seconds, all you need is time. Ken
  21. Using ob_start only hides the problem, it doesn't solve it. It sounds like you were getting a header error which you didn't tell us about which is caused by sending output to the browser before using the header function. Ken
  22. You can also do this with a foreach loop: <?php $ex = explode(",", $favorite_food); foreach ($ex as $food) { echo "$food<br/>"; } ?> Ken
  23. Can you explain what that does for those of us who are reg-expression challenged? Ken
×
×
  • 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.