-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
You could always have a field in a database, that basically lets YOU know if the user has collected their gained money within the pass 24 hours. Then use time() and check the difference between the time last collected.
So we can do something like this:
<?php $sql = "SELECT * FROM `phpbb_dseusers` WHERE `user_id` = " . $user->date['user_id']; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($res)){ # do other things we'll do time $time = time(); $last = $row['last_collected']; # you might have to add this into your database $day = 3600*24; $total = $time-$last; $collection = $row['collected']; if($collection == '0'){ # give points for first time # update last_collected field with time(); # update collected with the number 1 }else { if($total >= $day){ # give points # update last_collected field with time(); } } } ?>
-
Do:
$title = mysql_real_escape_string($_POST['title']); $cust = mysql_real_escape_string($_POST['cust_id']); $query = "INSERT INTO `upload2` (`name`,`size`,`typr`,`path`,`title`,`cust_id`) VALUES('$fileName','$fileSize','$fileType','$filePath','$title','$cust');"; mysql_query($query) or die("Error, query failed: " . mysql_error());
You had an extra comma after cust_id
-
function randomPassword($length){ $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $pass = ""; $i = 0; while($i <= $length){ $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } echo randomPassword(10); # 10 letters/numbers in length;
-
Here's an idea.
CHMOD all the folders to 777, will make them both readable AND writable, which is what you need.
-
Worked like a charm, tyvm.
-
Should that matter?
$post = "[user=matt]";
-
I have:
$post = preg_replace ("/\[user=(.*?)\]/is",uname2("$1"),$post);
and the function
function uname2($value){ $sql = "SELECT * FROM `users` WHERE `username`='$value'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); return "<a href=\"/profiles.php?user={$row['username']}\" style=\"text-decoration:none;\"><img src=\"/images/users/ui_{$row['level']}.png\" alt=\"\" border=\"0\"> {$row['username']}</a>\n"; }
My result: �
Basically I suppose the actually value inside the uname2 function isn't necessarily being passed.
-
Heh.
You could easily simplify that to a much smaller page, and easier to work with.
/* create a page form.php which can hold just the form itselfs use an array based error system */ if(!$_POST['submit']){ include "./form.php"; }else { # your variables $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); //etc... $errors = array(); if(!$username){ $errors[] = "You did not supply a username"; } if(!$password){ $errors[] = "You did not supply a password"; } #etc if(count($errors) > 0){ foreach($errors AS $error){ echo $error . "<br>\n"; } include "./form.php"; }else { # register } }
-
$_SERVER['HTTP_REFERRER'];
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
-
<?php ob_start(); # your code ob_end_flush(); ?>
-
Put this at the top of your page:
<?php ob_start();
Put this at the bottom:
ob_end_flush(); ?>
-
header('content-type: image.png');
should be
header('content-type: image/png');
-
Ah, you're calling it inside a function.
after you open the function add this:
global $errors;
-
The username input name is "Username" not "Check"
-
Do something like:
$errors = array(); //for each error you have name it $errors[] $errors[] = "first error"; $errors[] = "second error"; $errors[] = "third error"; foreach($errors AS $error){ echo $error . "<br>\n"; }
-
By appropriateness of a function, the variable $con is obviously defined OUTSIDE the function. So you need to globalize the variable.
$con = "connection to db"; function whatever($this){ global $con; // other stuff }
-
You could just put curly braces around the variables.
-
That won't work silly.
$codes = array('your','bbcode','here'); foreach($codes AS $code){ $_POST['message'] = preg_replace($code, NULL, $_POST['message']); }
-
I have 100 webpages, and increasing
30 !== 100
-
...
or die(mysql_error());
Use that instead of saying it failed.
-
You can just store every value in either session, or cookies.
-
It's not usually the best to use session and cookies at the same time. Also, the only real way to end a cookie is to set the expiration time back from where it started.
-
I don't see you including the files on your add user page.
-
What's wrong with Notepad? Notepad is pure original, I can code just fine in it
Ctrl + H.
Or you could just use rename and move the files there.
Obtain MAC Address Using PHP
in PHP Coding Help
Posted
Is it possible to obtain somebodies MAC address using PHP. I am only doing this because I need to up some security on my website.