ManiacDan
Staff Alumni-
Posts
2,604 -
Joined
-
Last visited
-
Days Won
10
Everything posted by ManiacDan
-
WELL FINE
-
Make a gif with a transparent background and use that. You can never guarantee that everyone in the world will be able to view custom microsoft-only characters.
-
There's a reason all logs are written at the end: Writing to the end of a log file is much faster and easier than writing to the beginning. The best solution is to make all your log entries a single line, then use a unix command like tail to view only the bottom of the file. The best way to solve your problem is: why do you want your log file in reverse-chronological order? Also, you can't do what kicken suggested (hi kicken!) because (a) log files of significant size will overflow your memory and (b) more than one simultaneous write request will ruin this file.
-
how to destroy session automatically after defined time?
ManiacDan replied to rahulvicky00's topic in PHP Coding Help
that function is one line. Put that one line above session_start. The first argument is the number of seconds of inactivity. -
how to destroy session automatically after defined time?
ManiacDan replied to rahulvicky00's topic in PHP Coding Help
session_set_cookie_params allows you to set the timeout for the user's session cookie. kney's solution accomplishes roughly the same thing at the server level, but note that you need to die() after a header() call. -
Ok, there's a number of things wrong with this, I'm going to comment on every line: //this query is malformed and will throw a mysql error. You have to quote the email address. $query = "SELECT * FROM orders WHERE customeremail = joe@example.com"; //this runs the query and puts the results in $result $result = mysql_query($query); //this fetches the first row into $row. YOU NEVER USE THIS RESULT $row = mysql_fetch_array($result); //this runs the query a second time for no reason mysql_query ($query); //this loops through the result set starting at row #2, since you already fetched row #1 up there and discarded it. while ($row = mysql_fetch_array($result)) { $random = rand(10000000, 99999999); //If this field is a string password, the input really should still be quoted even though it's a number. $query = "UPDATE orders SET laybypassword = ".$random." WHERE id = ".$row['id'].""; //this line runs the above query. mysql_query ($query); } //All of this could be done in a single query without MySQL at all. -Dan
-
Once again sphinx, please don't bump threads that have been dead for 8+ years. This topic is now also locked.
-
how to destroy session automatically after defined time?
ManiacDan replied to rahulvicky00's topic in PHP Coding Help
You need to be more specific, do you want: 1) The session to expire after a certain amount of inactivity? For instance, if they get up and go to lunch, when they come back they'll be logged out? 2) The session to expire at a specific time after login regardless of their activity. For instance, they can only browse your site for 4 hours before they're automatically kicked out? -
basename
-
WOULDN'T YOU LIKE THAT!?
-
That link is in my sig ----v
-
how to get single vars from a mysql_fetch_array()
ManiacDan replied to son.of.the.morning's topic in PHP Coding Help
You're not reading what I wrote. You are looking at my code, which contains TWO VARIABLES: $row AND ANOTHER ONE CALLED $rows. See how they have two different names? You cannot print $row when I ask you to print $rows. See? Two different variables? You want to use multiple rows, right? Use $rows for that, not $row, because clearly $row is one row and $rows is ROWS. Go back. Copy my code. Paste my code. DO NOT CHANGE MY CODE. At the END of my code, AFTER my code, print_r($rows); Then, using that output, figure out what you need to do to get the data you want. You can alter the echo in my code to echo whatever you decide you need to echo. -
how to get single vars from a mysql_fetch_array()
ManiacDan replied to son.of.the.morning's topic in PHP Coding Help
Copy. Paste. Seriously, what you have is nowhere near what I put. Do you not realize that $row and $rows are separate variables? One is singular, because it's one row. The other is plural, for all rows. -
how to get single vars from a mysql_fetch_array()
ManiacDan replied to son.of.the.morning's topic in PHP Coding Help
That's impossible if you copied and pasted my code. -
how to get single vars from a mysql_fetch_array()
ManiacDan replied to son.of.the.morning's topic in PHP Coding Help
Do what I said and then print_r($rows); You'll see the structure of the array and be able to use it then. If you still can't use it, copy and paste the results of print_r($rows) here. -
how to get single vars from a mysql_fetch_array()
ManiacDan replied to son.of.the.morning's topic in PHP Coding Help
I know your religion prevents you from posting fully-formed questions, so here's a random code snippet that may or may not be what you're looking for: $query = "SELECT * FROM blog_posts ORDER BY id DESC LIMIT 5"; $results = mysql_query($query); $rows = array(); while($row = mysql_fetch_assoc($results)) { $rows[] = $row; } echo $rows[2][3]; -
Using PHP OOP concept connecting to MySQL database
ManiacDan replied to raaks's topic in PHP Coding Help
While this is true for very complex systems, don't worry about it right now. -Dan -
Using PHP OOP concept connecting to MySQL database
ManiacDan replied to raaks's topic in PHP Coding Help
public function fetch($sql) { $array = mysqli_fetch_array($this->query($sql)); return $array; } You're calling $this->query() in there as if $sql is a string, when in reality $sql is already a result object. -Dan -
Definitely need more information than that. If you really do mean variable scope, then the answer is "non, I'd write the function properly."
-
slide show fails when i change 'name' tag to 'id' so it is validated
ManiacDan replied to jasonc's topic in Javascript Help
I love how we keep changing the section marked "please do not change below." Also, why is the "give it an ID and a name" solution not working? That's valid markup. Just because the validator said "change" doesn't mean that's the only solution. -
slide show fails when i change 'name' tag to 'id' so it is validated
ManiacDan replied to jasonc's topic in Javascript Help
That's not what I wrote. Always copy and paste. -
slide show fails when i change 'name' tag to 'id' so it is validated
ManiacDan replied to jasonc's topic in Javascript Help
document['Intro_Image'] That line finds by name. You could just do: document.getElementByI('Introl_Image') -
Go view the source of the web host, I bet it's flash. That being said, legally online signatures only require that you collect identifying information and have the user type their name into a box labeled "digital signature." I am not a lawyer, obviously, but that's what happens when you buy insurance online.
-
Note that this won't be 100% accurate in some cases because of the problem of fractions and binary math. You might want to do a "close enough" disclaimer, or make use of the round() function.