Orio
Staff Alumni-
Posts
2,491 -
Joined
-
Last visited
Never
Everything posted by Orio
-
Error in displaying message for inserting new records
Orio replied to helloanddie's topic in PHP Coding Help
I see nothing wrong with the code. (Except the fact you have a block opened after the includes with no if/loop). Let me get this straight again. Your problem is that you are getting a fail/success message on the very first page load? (Even when the form is yet to be submitted) Orio. -
I don't think there's much difference.. It is mainly using curl and preg_match() I think, so that should be the same in php4. Orio.
-
Error in displaying message for inserting new records
Orio replied to helloanddie's topic in PHP Coding Help
Can you show the full code so I could understand better? Orio. -
Error in displaying message for inserting new records
Orio replied to helloanddie's topic in PHP Coding Help
What do you mean by that? The value returned by mysql_query() is returned only after the query was/wasn't executed. So if you get true returned, that means the query executed successfully. Can you explain what's currently wrong? Orio. -
Error in displaying message for inserting new records
Orio replied to helloanddie's topic in PHP Coding Help
Your if is wrong. You are checking if the result is not true, instead of checking if it is true. Should be: <?php //Execute SQL Statement and store results as a recordset $result= mysql_query($sql) or die (mysql_error()); if ( $result === true ) { echo "Contact successfully added."; } else { echo "Please try again."; } ?> Orio. -
That function is way too puffed with unneeded stuff. Try this: <?php function http_exists($url) //$url must be valid, starts with http:// { $headers = get_headers($url) if($headers === FALSE) return FALSE; return (strtolower($headers[0]) == 'http/1.1 404 not found'); } ?> Orio.
-
Try using $path in your header instead of $filename. Also, you are risking yourself here. You are taking user input and placing it right inside a SQL query. This way, people can enter malicious inputs that can damage your database. This is a security hole, and it has to be fixed. There are tons of articles and tutorials about this issue, just google for it. Orio.
-
What do you mean by "File type"? It's extension? It's MIME type? Be a bit more specific please. Orio.
-
After reading some examples, I think this is what you're looking for: <?php $zip = zip_open("test.zip"); $count = 0; if ($zip) { while ($zip_entry = zip_read($zip)) $count++; zip_close($zip); } echo $count; ?> Orio.
-
Although I've never used these, I am sure you'll be able to do that using the zip file functions. Orio.
-
That will match "everything BUT numbers". Also you need only one "+" (or "*", depends on what you're looking for). Anyway, it should look like this: <?php if(preg_match("/^[0-9]+$/", $num_input)) echo "Valid input"; ?> Orio.
-
That's a mistake. Using strlen() is much more efficient than using preg_match(). <?php $len = strlen($pass); if($len < 4 || $len > 12) echo "Bad pass!"; ?> Orio.
-
Yeah, but I guess at some point you'll either get an internal 500 error or as SemiApocalyptic said, you'll get a "maximum execution time" error. You can test it, but either way you have choose the answers wisely so you'll have no doubts about the correct answer. Orio.
-
Cool I really like it. A few suggestions: [*] Capitalization. It looks more professional when all the links (Such as "about", "privacy", "save" etc') start with a capital letter. [*] After loading a saved pad, I think it's better if the user/pass form will close and the links will come back up (Just like the save form disappears after saving). [*] In the beginning, I didn't see the save/load/clear links. Only saw those on the left. Maybe putting boxes around the links would have helped me see them sooner (I saw them only because I looked for them). Although I am not sure boxes will do good with the forms. But I think the links should take more of the visitor's attention. The boxes in the middle are designed neatly and nicely imo, but the links are small and not visible. Some styling changes? I don't know. [*] The most difficult problem to fix... In FF when I press save/load, the form overrides part of the boxes. In IE7 the boxes are moved to the left. I think the behavior in IE is ok (although it's not perfect, but nothing is ), maybe you could tweak it a bit so FF will act the same? But I must say I really like the idea, keep up the good work. Orio.
-
As far as I understand, this question is a part of a quiz / test, and not a question asked in some board or for help. So a good question for this piece of code would be: What would the following code produce? And if it's a multi choice question some possible options could be: [*] 10 Times "Hello" each, in a new line [*] An error, because echo has to come with parentheses around it's parameters. [*] Nothing. [*] An internal sever error. etc' Orio.
-
Memboost is a open source ram optimizer. Check it's web site, maybe you'll find your answer there. Or just go to the source Orio.
-
You should also add the "i" modifier for opening tags like <?PHP. Orio.
-
In the end of your pattern you have the closing < /b>. The function thinks that that slash you have in </b> is closing the pattern, so it thinks b is a modifier. The solution- simply escape that slash: <?php $pattern = "/^<p><b>\d[.]( )?(\d\w\s)+<\/b>$/"; ?> Orio.
-
[SOLVED] replace preg_replace with another function like str_replace
Orio replied to honeyphp's topic in Regex Help
Yep cx323 is right.. It's a place for array_merge() and not the "+" operator since only array_merge() appends the values of arrays that use numeric keys and doesn't overwrite. The line should be: $valid_chars = array_merge(range(65,90) , range(97,122) , range(48,57)); Orio. -
[SOLVED] replace preg_replace with another function like str_replace
Orio replied to honeyphp's topic in Regex Help
It seems like using preg_match() is faster here... Try checking the Filter library, maybe you could find something over there. Orio. -
[SOLVED] replace preg_replace with another function like str_replace
Orio replied to honeyphp's topic in Regex Help
My server is down so I can't test it or find out if it's faster the using preg_replace(). But try it: <?php function only_alpha_num($str) { $valid_chars = range(65,90) + range(97,122) + range(48,57); //A-Z + a-z + 0-9 $len = strlen($str); for($i=0, $new_str = ""; $i< $len; $i++) $new_str .= (in_array(ord($str[$i]), $valid_chars)) ? $str[$i] : ''; return $new_str; } ?> Orio. -
The main function you're looking for is gethostbyaddr(). Orio.