-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
Thanks that DID work! I just added the mins > 59 .. function validTime($time) { $bits = explode(':', $time); if (($bits[0] > 24) || ($bits[1] > 59) || ($bits[0] == 24 && $bits[1] > 0) || count($bits) > 2) { echo " $time is invalid!"; return 0; } else { echo " $time is valid!"; return 1; } } THANKS!!! Ale. ahh ok, check out my updated one, checks to make sure there are no string values too, and makes sure that it is the format hour:min
-
"12:12:bvdfuybveyu" would be false, because of the count check I did. You are correct however, I did not test for string values. Here is an editted version. checks for a lot more function validateMilTime($time){ $bits = explode(':', $time); if ($bits[0] > 24 ||$bits[1] > 59|| ($bits[0] == 24 && $bits[1] > 0) || count($bits) != 2 || !is_numeric($bits[0]) || !is_numeric($bits[1])){ return "false"; } return "true"; } echo validatemilTime("25:15") . "25:15<br />"; echo validatemilTime("24:15") . "24:15<br />"; echo validatemilTime("23:15") . "25:15<br />"; echo validatemilTime("22:15:00") . "22:15:00<br />"; echo validatemilTime("ga:ad") . "ad:ad<br />"; echo validatemilTime("12:30AM") . "12:30AM<br />"; echo validatemilTime("aweae:234") . "aweaw:234<br />"; echo validatemilTime("12:60") . "12:60<br />"; output: false25:15 false24:15 true25:15 false22:15:00 falsead:ad false12:30AM falseaweaw:234 false12:60
-
besides the incorrect variable, that function is perfectly fine. I just tested it function check_time($time) { if(strtotime($time)) { return "PASS<br/>"; } else { return "FAIL<br/>"; } } echo check_time("25:10"); echo check_time("12:68"); echo check_time("24:14"); echo check_time("23:14"); echo check_time("00:14"); results: FAIL FAIL FAIL PASS PASS However, if you just want to test military time, that function wont work. for example this: echo check_time("monday"); will output PASS
-
if you want it to be dynamic, then you are trying with the wrong language. However, could you elaborate, im not entirely sure what you mean
-
I don't see how it would be any more optimised
-
function validateMilTime($time){ $bits = explode(':', $time); if ($bits[0] > 24 || ($bits[0] == 24 && $bits[1] > 0) || count($bits) > 2){ return false; } return true; } try that
-
post your code again. How are you supposed to tell what MSIS number to test? do you get it from a form?
-
assuming the 3 arrays will always be the same length $hello = array("hello", "guys", "hows", "it"); $goodbye = array("Its", "going", "find", "thanks"); $aiight = array("Good", "then", "thats", "well"); for ($i = 0; $i < count($hello); $i++){ echo $hello[$i]." ".$goodbye[$i]." ".$aiight[$i]."<br />"; } if they aren't always the same size this won't work as expected
-
oh yeah, sorry about that. what exactly is this msis number? is it constant? will it change? if it will change that you need a variable
-
$result = mysql_query("SELECT * WHERE msis='msis'") that will return all rows where the string string 'msis' is in the column msis. If you want to test a variable, you have to put a variable in there. And are there any errors? check the source for errors also.
-
yes, you can do a query like this $result = mysql_query("SELECT * WHERE field1='$variable1' AND field2='$variable2'")//variables are from your post data or wherevever //if (mysql_num_rows($result) != 0){ //send the email; } that will check for any rows matching the criteria, and if there are any, you can send an email
-
what is your forms action set to? is it set to the correct page? using request is perfectly fine, since forms can only be get or post, not both at the same time.
-
try long php tags. IE <?php instead of <?
-
echo("<script language='javascript'>window.location.href='login.php'</script>"); try that
-
Oracle/PHP. NULL fields shifting my HTML table
mikesta707 replied to mikesta707's topic in PHP Coding Help
Alright, so I kind of figured out a way I might be able to do this. With that PHP class, I get all the column names. What I may have to do is create a function that will take every single entry in the $this->data array (which is basically every row returned) go through it, and where an array key doesn't exist, insert it, and put an empty string into the value (Or the world Null, which ever) However, I am not sure how I would go about this. I am going to make an attempt, and I will get back to this post. -
Ok, this is a very confusing problem. So i built a class in PHP that takes the results of an oracle query, and puts them into an array, and I use another javascript class to create a table with the information. So far, I have not run into a problem with this. However, I have with a recent query, I have come across a problem with null fields. When I preform the following code (simplified for ease of viewing): while(OCIFetchInto($this->execute, $results, OCI_ASSOC)){ if ($this->data == null){ $this->data[] = $results; $this->columns = array_keys($results); } else { array_push($this->data, $results); } if (count($results) > count($this->columns)){ $this->columns = array_keys($results); } } what seems to happen is that where ever there is a null field, the result array doesn't have certain keys that other result sets do. When building my table, everything gets screwy, because some result sets are longer than others, and some rows have less columns than the total amount of columns in the table, and some have more. Because of this, certain cells are not in the correct column. Is there a way to make sure every array is the same length, and wherever there is a null value, instead of ignoring it, just adding a null value to the array under the correct key? I want to try to do this purely with PHP, because I have a lot of different queries that I need to do, and I don't want to have to change a query every time this problem may arise. although I understand why the problem is happening, I honestly have no clue how to fix it, and I don't think I even explained the problem very well. Please, if you need more information, tell me. I can post the javascript stuff that builds the HTML, and the other class functions if needed, but i figured that any fix would go in building the array. thanks in advance Oh, here is an example of what I want to try to do, with simple data. assuming that my query fetches the columns name, date, and awesome level, if my table had the following data name date awesomeness john | today | pretty awesome Mike | yesterday | null instead of the result set being arr[0] => array('name'=>'john', date=>'today', 'awesom'=>'pretty awesome') arr[1] => array('name'='mike', date=>'today') i want it to be arr[0] => array('name'=>'john', date=>'today', 'awesom'=>'pretty awesome') arr[1] => array('name'='mike', date=>'today', 'awesome'=>null)//or 'awesome=>""
-
I don't see how the last if statement wouldn't execute with what you have there? What is the logic that would cause the second if statement to not run? if you want to exit a loop, use break like for ($i = 0; $i < 10; $i++){ //i want to exit this loop at 5 if ($i == 5){ break; } }
-
You are talking about forcing the download dialog box right? check out this page
-
can you put the php in php tags and leave out the HTML. its kind of hard to read?
-
I would suggest consulting the documentation for the API. there are probably many easy to follow tutorials there. Try reading the comments in the API definition too. But if you never learned the "right" way to code in PHP, i suggest you do before you tackle this project. It will be a lot easier down the road when you want to update or edit your websites functionality. You won't have to change a bunch of code on a bunch of changes just to add one simple thing
-
all you really needed to do was put session_start at the beginning of your index page. whatever pages are included with a page that has session_start() on the top doesn't need to have session start
-
[SOLVED] Echo a variable as an HTML link?
mikesta707 replied to markvaughn2006's topic in PHP Coding Help
echo "<a href='$variable'>$variable</a>"; //or if variable isnt the link echo "<a href='whatever links'>$variable</a>"; -
echo "<td> <a href=\"javascript:post_value('$idz');\">SELECT</a></td>"; try that. you have nested single quotes which is probably causing the problem
-
I would suggest doing what you did in the first post. Wherever you put your links in your page, just have a simple if (or possibly a switch statement if you are going to have many languages) statement that chooses which link page to include. That way you can easily just add more links and more languages without having to change a lot of code. if all the links for each language are going to be different anyways, there isn't much else PHP can do that is as simple
-
While I do agree javascript is the best way (No real need to use Jquery for something as simple as this, but you can if you want) Your statements are rather ludicrous. 30 seconds per page load, especially if its a rather simple form, as quite a stretch, especially if the server isn't terrible, and the user has a high speed connection. I would say its more around 5-10 seconds, 15 at most with a high speed connection. Maintaining the old data is not really a problem at all, if you followed what CV said, but bandwidth may become a problem if your websites servers a large audience. And there are also problems with javascript, mainly that a user may have javascript disabled. However, I do agree that the pros of javascript far outweight the cons. Its much faster, cleaner, and easier to maintain