Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
I can't answer that as that person wasn't me, but I would guess trying to provoke an error to see if he could get information about how the site works.
-
Right, you are actually calling it twice: $sql = "UPDATE postcode SET mailcount = mailcount + 1 WHERE postcodeID=$emailid"; mysql_query($sql) or trigger_error('<p>There seems to be a problem, please try again soon.</p>'); $result = mysql_query($sql); Of course it'll update twice when you call it twice.
-
It depends on what you are going to use the value for. If it's to be used as XML/HTML/XHTML/CSV/SQL/JSON/YAML/MySQL/Oracle/etc., the way you'll sanitize it differs. Even if you say it's MySQL, PHP has three different ways of doing it: the mysql extension, the mysqli (MySQL improved) extension, and the PDO extension. Then within MySQLi/PDO you may choose to use prepared statements or escape things manually. A hashing algorithm and a salt will usually suffice. You could use something like sha256 with hash; that'll be stronger than e.g. md5(). The longer the salt the better as well.
-
You're probably executing the query twice. Try posting the code.
-
I think something like this should do it: function wordwrap2($text, $maxLength, $separator = '-') { $lines = explode("\n", $text); $linesNew = array(); foreach ($lines as $line) { $length = strlen($line); if ($length > $maxLength) { $start = substr($line, 0, $maxLength); if (strlen($start) != strlen(rtrim($start))) { $linesNew[] = rtrim($start); } else { $linesNew[] = $start . $separator; } $linesNew[] = wordwrap2(trim(substr($line, $maxLength)), $maxLength, $separator); } else { $linesNew[] = $line; } } return join("\n", $linesNew); }
-
No, I didn't actually try to upload one. What kind of error do you get?
-
at is a unix command. Like this: daniel@daniel-laptop:~$ at -h Usage: at [-V] [-q x] [-f file] [-mldbv] timespec ... at [-V] [-q x] [-f file] [-mldbv] -t time at -c job ... atq [-V] [-q x] atrm [-V] job ... batch
-
Can somone donate me a few bucks? only need like 2-3$..
Daniel0 replied to Gayner's topic in Miscellaneous
Oh, I don't doubt you know how to spell your country's name. Just figured it was an unintentional typo or whatever. Not like it matters anyway. -
Can somone donate me a few bucks? only need like 2-3$..
Daniel0 replied to Gayner's topic in Miscellaneous
No, it says "austrailia" -
If you're going to use the command line, why not just use at like I already suggested?
-
Yeah I just tried setting it to 10G. No problem.
-
'Foo said \'hi bar\'' preg_match_all('#\'((?:[^\'\\\\]|\\\\.)*)\'#', $string, $matches);
-
Either $_GET, $_POST or $_COOKIE contains an array. Probably someone who tried to do stuff like ?foo[]=bar or whatever to see if he could generate an error. See this: php > var_dump(array_map('stripslashes', array(array()))); Notice: Array to string conversion in php shell code on line 1 Call Stack: 60.0963 115064 1. {main}() php shell code:0 60.0964 116000 2. array_map() php shell code:1 array(1) { [0]=> string(5) "Array" }
-
What does php.ini and phpinfo() say? Maybe you're changing the wrong php.ini file. I've tried that before.
-
[SOLVED] Count the number of RSS feed subscribers?
Daniel0 replied to random1's topic in PHP Coding Help
We just use feedburner and let them figure it out for us. According to them we've got about 5000 subscribers on our main feed. It gives you all sorts of statistics. -
Read from the LAST line of a CSV file (without knowing line number)
Daniel0 replied to schapel's topic in PHP Coding Help
Okay, I just tested. This will work: <?php $bufferSize = 10; $file = 'test.txt'; $size = filesize($file); $fp = fopen($file, 'r'); $buffer = ''; for ($pos = $size - $bufferSize;; $pos -= $bufferSize) { $pos = max(0, $pos); fseek($fp, $pos); $b = rtrim(fread($fp, $bufferSize)); $nlPos = strrpos($b, "\n"); if ($nlPos !== false) { $buffer = substr($b, $nlPos) . $buffer; break; } else { $buffer = $b . $buffer; } if ($pos == 0) { break; } } $lastLine = trim($buffer); -
Read from the LAST line of a CSV file (without knowing line number)
Daniel0 replied to schapel's topic in PHP Coding Help
I suppose you could do something like this. It will search backwards for a newline. It isn't tested. <?php $bufferSize = 10; $file = 'file.txt'; $size = filesize($file); $fp = fopen($file, 'a'); $buffer = ''; for ($pos = $size - $bufferSize;; $pos -= $bufferSize) { $pos = max(0, $pos); fseek($fp, $pos2); $b = fread($fp, $bufferSize); $nlPos = strrpos($b, "\n"); if ($nlPos !== false) { $buffer = substr($b, $nlPos) . $buffer; break; } else { $buffer = $b . $buffer; } if ($pos == 0) { break; } } $lastLine = trim($buffer); You don't know how many lines there are before you've read the entire string. -
Read from the LAST line of a CSV file (without knowing line number)
Daniel0 replied to schapel's topic in PHP Coding Help
You can't do that unless the exact line length is deterministic. -
It would seem so: http://www.phpfreaks.com/forums/index.php/topic,276596.0.html
-
I'd say it depends on what you're going to use it for. If it's for displaying on e.g. your website, I think it's perfectly legitimate making it span over many pages. If you're applying for a job that isn't listed anywhere, I don't think size matters so much either. Of course still while omitting irrelevant shit like "When I was 10 years old I mowed my neighbor's lawn every Saturday".
-
Yeah but as far as I remember, it only supports IE7 and IE8 rendering mode. No IE6.
-
Won't work if the user leaves the page before a minute has passed.
-
You can use at on Linux. It's essentially a one-time cronjob.
-
Remind me not to sign up on any web site you created.
-
I've noticed turning off JScript has some notable benefits.
Daniel0 replied to PugJr's topic in Miscellaneous
No, but you can on Linux/BSD. Simply don't start X when booting, so just remove it from /etc/init.d or wherever your boot scripts are.