-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
Well I'm assuming your session is storing it as a four digit number and not a max of 3 digits.
for($i = 1900; $i <= 2012; $i++){ // code }
-
You can't have multiple options selected at once...
-
for($i = 1; $i <= 12; $i++){ $sel = ($i == $_SESSION['frommonth']) ? " SELECTED" : ""; echo '<option value="'.$i.'"'.$sel.'>'.$months[$i].'</option>'; }
-
How about some
code
? -
Use stripslashes() to get rid of the
\/
and html_entity_decode to revert ASCII values into their applicable entities. -
Select the data
$data = mysql_query("SELECT * FROM table");
while($row = mysql_fetch_assoc($data){ // use $row as an array to access individual columns and their respective data }
-
If the form is going to be the same each time it's accessed just make it static.
-
for($i = $startNum; $i <= $endNum; $i += $increment){ echo "The square of " . $i . " is " . ($i*$i) . "<br/>\n"; } // alternatively $range = range($startNum, $endNum, $increment); foreach($range AS $value){ echo "The square of " . $value . " is " . ($value*$value) . "<br/>\n"; }
-
$string = "lemonade.is.awesome"; list($grandparent, $parent, $child) = explode('.',$string); // grandparent = lemonade // parent = is // child = awesome
-
In your if statement you need to assign $prev_row to $title or else your code will never reach that else statement.
-
Woops, you wanted first three
SELECT * FROM `rubric` AS r, `schedule` AS s WHERE s.name LIKE CONCAT(SUBSTR(r.code,0,3),'%')
-
Similar approach:
SELECT * FROM `rubric` AS r, `schedule` AS s WHERE s.name LIKE CONCAT(r.code,'%')
-
You don't need to use $this because it's within the scope of the function.
Also on your if statements, are you trying to check if the value of $k isn't equal to the value of $v? If so, then you would use $k != $v, because what you're saying now is $v is set to NOT $k which would become false regardless.
-
$input = 100; $array = array(50.5, 40.5, 35); $remainder = 0; foreach($array AS $num){ $remainder = ($remainder == 0) ? $input : $remainder; $out = $remainder - $num; if($out < 0){ break; } $remainder = $out; } echo $remainder;
Just a quick example of how I interpreted your code. I get the result of "9" when I use input=100 and the array=[50.5, 40.5, 35]
Give a try and implement my code into yours.
-
1. Password protect the admin page, or maybe move it to a folder that isn't as easily accessible with the name "admin"
2. What's wrong with showing the file name? You could mod_rewrite, or a dynamic index page, so it would be website.com/sells or website.com/index.php?p=sells respectively
-
I more valuable solution instead of using getsqlvaluestring is type casting.
$a = "57878.044cats"; var_dump((int)$a, (string)$a, (double)$a, (float)$a, (bool)$a);
int(57878) string(13) "57878.044cats" float(57878.044) float(57878.044) bool(true)
-
Why would you store a person's password in the directory name? That is just plain stupid. You could literally just store it under the username, why would you allow multiple users to have the same username?
-
How about some code?
-
Personally I would just store it as the seconds. But if you wanted to use either DATETIME or TIMESTAMP I would use TIMESTAMP.
It's easier to calculate the time differences using the actual seconds. Going from TIMESTAMP to seconds and then finding the time difference requires that conversion.
-
Since time is a method it can't just be called in the middle of a variable unless escaped. You could have assigned the time method to a variable ($time = time()) and used $time in your query if you wanted. You aren't restricted to using the UNIX_TIMESTAMP() and NOW() MySQL methods, you can use the PHP time() method, but you have to escape it or assign it to a variable for it to work in your query.
You could do the math in MySQL or PHP, it's really up to you.
SELECT (UNIX_TIMESTAMP(NOW()) - last_activity) as lastActive FROM member
Then loop through the results.
while($row = mysqli_fetch_assoc($query){ $indicator = ($row['lastActive'] < 50) ? "green" : ((in_array($row['lastActive'], range(50,100))) ? "idle" : "offline"); // 0-49 = green, 50-100 = idle, > 100 = offline, you can change those values to correspond with however you want it to be // maybe Online = last 15 minutes, idle = 15-30 minutes, offline = > 30 minutes // lastActive will return in seconds so 15 minutes = 900 seconds }
-
Well look at it this way. If you don't escape time() the query is going to treat it as
string(6) "time()"
instead of the Unix timestamp we were looking for. Using the MySQL methods UNIX_TIMESTAMP and NOW() we don't have to worry about them being parsed as strings because MySQL will recognize them and treat them as methods instead of strings.You could continue using time() if you wanted to, like:
$q2 = "UPDATE member SET logged_in = ?, last_activity = '".time()."', updated_on = NOW() WHERE id = ? LIMIT 1";
Hope that clears things up.
-
How am I supposed to help you when I don't know how your GetSQLValueString function works? Or even where it's implemented in your code.
You are posting ZERO information on how we can help you, provide usable code, give us something other than "meh it doesn't work."
-
The reason for your error is because the mysqli_prepare statement is returning false. It could either be because a) Your connection is invalid or b) The query is wrong.
Try making this change to your query:
$q2 = "UPDATE member SET logged_in = ?, last_activity = UNIX_TIMESTAMP(NOW()), updated_n = NOW() WHERE id = ? LIMIT 1";
-
It exists in your code, not mine, so I don't know how your's works.
Go ahead and test my function with any SQL injection, it will always return the empty string (or a float value if it begins with an integer)
show selected on form via session == true
in PHP Coding Help
Posted
Why would you use
$year[i$]
the year is just$i