Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
I s/he is referring to clean URLs.
-
Outputs: hello world
-
You could use AJAX, but I'd just set a cookie, it's much easier.
-
Is this a problem with all pages or that particular page?
-
There is no such thing as chmod on Windows.
-
The mysql_real_escape_string() function call is in that case redundant as md5() will always return an alphanumeric string of 32 characters thus not posing any risk of SQL injection. @yobo: You didn't check the email. You might want create to if (scheck_email($email) == -1) {$error = $error + 1; $error_mes .= "Invalid email\n";} below the other similar lines.
-
Just for the record, Javascript is not the same as Java. They are two entirely different languages. Seeing as you are using a select menu there is no other way than using Javascript. This cannot be accomplished with PHP code.
-
Well, the only thing that happens if the user enters an invalid email is that it tells him/her so. Nothing else. The rest of the script will always continue. I also have a couple of comments to your code: Instead of doing something like this: $error = $error + 1; $error_mes .= "Sorry, no name entered\n"; I would do this: $errors[] = 'Sorry, no name entered.'; Then you can check how many errors there are with count() and do join("\n", $errors);. This if statement: if ($_POST){ will always evaluate to true as $_POST will always be set. Thus the succeeding code block will always be run. Instead of checking if something is longer than one character: strlen($_POST['firstname']) < 1 it will probably be faster and more readable to check it is not empty: !empty($_POST['firstname']) In your form you might as well just echo $email - no point in checking the length. If it's to prevent E_NOTICEs then it won't work as you will already have used an undefined variable in strlen().
-
I do this: <?php function __autoload($class_name) { require str_replace('_', DIRECTORY_SEPARATOR, $class_name) . '.php'; } ?>
-
I don't know if it's based on post count or if it's because I'm in the "PHPFreaks Recommended" group, but currently there are 27 PMs in my inbox. Does it give you any error?
-
What do you mean?
-
No. You might be able to do things faster and therefore more efficiently, but you do not have any sort of power. Which CLI are you referring to? I suppose you mean Linux. You cannot open a file using the CLI, but you can run a program which will open the file. E.g. $ vim some_file.txt $ nano some_file.txt To delete a file/folder you'll use rm. This takes various flags which you can see by running $ man rm (you can most likely see a manual page for something by typing man <whatever>, e.g. man ls, man mkdir etc.) There are various things you should take care of to not wreck your computer. E.g. don't be root when you don't need to, watch out when using the -r (recursive) and -f (force) flags with rm. You can take a look at this. I haven't read it, but it was the first result for "bash scripting" on Google.
-
[SOLVED] Programming Challenge #1 (Numbered in case there's more)
Daniel0 replied to roopurt18's topic in Miscellaneous
Huh? roopurt's post is one long explanation. -
[SOLVED] Programming Challenge #1 (Numbered in case there's more)
Daniel0 replied to roopurt18's topic in Miscellaneous
Ah, used the wrong operator :-\ Second post was based on first so I didn't catch it there either. So roopurt, yes, I did introduce a bug -
[SOLVED] Programming Challenge #1 (Numbered in case there's more)
Daniel0 replied to roopurt18's topic in Miscellaneous
I was thinking he wanted to move very_expensive_operation() somewhere so it would only be run if needed and not always. I figured that was why he named the function as he did. -
[SOLVED] Programming Challenge #1 (Numbered in case there's more)
Daniel0 replied to roopurt18's topic in Miscellaneous
No, I can't prove that I didn't make any bugs. I actually thought about that and it kind of bugs me that I couldn't. I suppose that is partially because I don't know what the function is indented to do and what it's intended output is and partially because very_expensive_function() is not defined in the above snippet. Also, $asdf is not used so it's just redundant but I don't see any way of removing it from the argument list without breaking code that is dependent on the function. -
[SOLVED] Programming Challenge #1 (Numbered in case there's more)
Daniel0 replied to roopurt18's topic in Miscellaneous
:\ <?php function doThis($foo, $bar, $asdf, $x, $y, $z, $m, $n, $o) { if(empty($m)) { return 1 / $bar; } else if(($n == 'one' && ($x < $y && $x > $z)) || ($o == 'two' && (($x < $y && $x < $z && ($y + $z <= 10)) || !($x >= $y || $x >= $z || ($y + $z <= 10))))) // <-- wtf? { return ($y * $z + $x) * $bar; } else if($n == 'one' || $o == 'two') { return ($bar + very_expensive_operation($m, $n, $o)) / $foo; } else if($n == 'one' && ($x >= $y || $x <= $z)) { return ($y / $z - $x) * $bar; } else { return $foo / $bar; } } ?> -
[SOLVED] Programming Challenge #1 (Numbered in case there's more)
Daniel0 replied to roopurt18's topic in Miscellaneous
Like this? <?php function doThis($foo, $bar, $asdf, $x, $y, $z, $m, $n, $o) { if(empty($m)) { return 1 / $bar; } else if($n == 'one') { if($x < $y && $x > $z) { return ($y * $z + $x) * $bar; } else if($x >= $y || $x <= $z) { return ($y / $z - $x) * $bar; } else { return ($bar + very_expensive_operation($m, $n, $o)) * $foo; } } else if($o == 'two') { if($x < $y && $x < $z && ($y + $z <= 10) || !($x >= $y || $x >= $z || ($y + $z <= 10))) { return ($y * $z + $x) * $bar; } else { return ($bar + very_expensive_operation($m, $n, $o)) / $foo; } } else { return $foo / $bar; } } ?> -
For AJAX you really just need to learn Javascript. You could take a look at http://developer.mozilla.org/en/docs/AJAX though. I would recommend you to use Javascript frameworks such as Prototype or jQuery (my favorite).
-
I'd love to hear some of those exercises.
-
Send these headers: Expires: 0 Cache-Control: must-revalidate, post-check=0, pre-check=0 Pragma: no-cache You can use the header() function for that. Use one header per function call and do it before you output anything.
-
You can make a quiz in any language you would like.
-
Python is an excellent language you might want to learn as well.
-
Eh? Do tell. http://www.phpfreaks.com/forums/index.php/topic,175791.msg779491.html#msg779491
-
Time limit on editing posts on this forum
Daniel0 replied to neylitalo's topic in PHPFreaks.com Website Feedback
Man... I was beginning to like being able to edit my posts again Still though, while the time limit for some reason was off some people did go back editing their topic so the repliers would look like complete morons asking for details which were already provided (after the edit). In a "real" conversation you can't go back and edit what you've previously said so it makes sense not being able to edit what you say here after a certain amount of time as well.