kenrbnsn
Staff Alumni-
Posts
8,234 -
Joined
-
Last visited
Everything posted by kenrbnsn
-
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
-
Please post the form that is being used.
-
If the "*" characters are separators, then you could use the fgetcsv function to read the data, then you can just process. Ken
-
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
-
Without knowing what that standard looks like, how can we give a meaningful answer? Ken
-
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
-
The easiest way to add attachments to PHP mail is to use a class like PHPMailer Ken
-
How can I get this piece of code too work?
kenrbnsn replied to xwishmasterx's topic in PHP Coding Help
This <?php if($rsbuildings[".$_GET['t']."] == 'leader_id' ) ?> is not correct syntax, it should be <?php if($rsbuildings[$_GET['t']] == 'leader_id' ) ?> Ken -
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
-
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
-
Please post your code between tags. Ken
-
"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
-
UPDATE array isn't sending entire array to row
kenrbnsn replied to TCombs's topic in PHP Coding Help
Please post the form. Ken -
UPDATE array isn't sending entire array to row
kenrbnsn replied to TCombs's topic in PHP Coding Help
Please post the form that is being used by this script. Ken -
Count how many times the submit button has been hit
kenrbnsn replied to keepAway's topic in PHP Coding Help
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 -
Use a combination of parse_url and basename <?php $x = parse_url($_SERVER['HTTP_REFERER']); echo basename($x['path']); ?> Ken
-
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
-
What do you mean by Magic quotes on or off shouldn't matter to this script. Ken P.S. Learn how to spell "length".
-
strtotime to check if they voted within the last hour
kenrbnsn replied to 3raser's topic in PHP Coding Help
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 -
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
-
strtotime to check if they voted within the last hour
kenrbnsn replied to 3raser's topic in PHP Coding Help
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 -
strtotime to check if they voted within the last hour
kenrbnsn replied to 3raser's topic in PHP Coding Help
What is the format of $grab['date']? To get the current date in seconds, all you need is time. Ken -
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
-
You can also do this with a foreach loop: <?php $ex = explode(",", $favorite_food); foreach ($ex as $food) { echo "$food<br/>"; } ?> Ken
-
Can you explain what that does for those of us who are reg-expression challenged? Ken