Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. Both actually. It does check if its not true, but in programming, the way you check if something is not true, is to add the not operator to the value. You want to pass a true value into the if statement if you want it to run, and the not operator will take a false value (if something is not true) and turn it into a true value
  2. $problem is a boolean value. When there is a problem, it is set to true. If not, then it will be false. Applying the not operator (!) to a boolean value basically reverses it (so true becomes false, false becomes true). What that would be checking is if $problem is false (IE there were no problems) The not operator turns it into true. so yes
  3. no, that doesn't make sense actually. Your two select tags have the same name. So the second one will overwrite the first. You can either make them different names, or make them an array, like so <select name="id[]" > if you choose to make an array, you can access them like $_GET['id'][0];//first one $_GET['id'][0];//second one
  4. .... do you read your own code. The query you are using for the loop. $sql=mysql_query("SELECT * FROM passenger LIMIT 2 OFFSET 0 ");
  5. well this for ( $i=$pos_s+strlen($s1) ; ( ( $i < ($pos_e)) && $i < strlen($text) ) ; $i++ ) { $mid_url .= $text[$i]; } can be accomplished with substr <?php function get_between ($text, $s1, $s2) { $pos_s = strpos($text,$s1); $pos_e = strpos($text,$s2); return substr($text, $pos_s + strlen($s1), $pos_e - ($pos_s + strlen($s1)) ); } $text = "This will be some VEERY long text with somsde words and more words, but yeah..."; echo get_between($text, "be", "words"); ?>
  6. well, i figured that if the page was redirecting, then the error lied somewhere in the validation, so I looked there. You also did validation in an interesting way (with arrays) which I don't see much, so that area already stood out
  7. ... I told you, you need to change your query, because the query is ALWAYS retrieving 2 rows from table (assuming the table has data) If your table has data, then two emails will be sent. If you don't want emails to always be sent, then you need to add a WHERE clause to your query
  8. this doesn't make sense $result = mysql_num_rows($sql); if($result['username'] == $user) { $report = 'Error: This user already exists!<br>'; } $result is an integer, not a result set. But you probably meant $result = mysql_fetch_array($sql); if($result['username'] == $user) { $report = 'Error: This user already exists!<br>'; } That might help, but its essentially the same thing as what OP had because of the WHERE clause, and the fact that the query will only return rows with the username equal to the $user variable. Also, if that does prove false, you will get an undefined index notice. This isn't bad but if you have error reporting turned on (as was suggested earlier) you will see the error whenever the form was submitted successfully.
  9. ok, when you echo action, what value does it have? It would seem that you keep passing the same value for that $_GET variable every time you refresh the page, and gets locked into an infinite refresh loop
  10. do you want to do this without reloading the page? if so you need javascript. It seems like you do want to do this as you mention the onclick attribute. You can call a javascript function that changes the innerHTML attribute of the div with your form. something like <script type="text/javascript" > function change() { div = document.getElementById('button_brief'); div.innerHTML = "your form here"; } </script> and call something like that in your onclick attribute.
  11. If you are getting no header errors, than your header usage is fine. If it's redirecting, its not a header issue, so you don't have to worry about that. Didn't know that the page was redirecting, or I wouldn't have even mentioned it. One thing I noticed $required_fields = array('menu name', 'position', 'visible'); in the variable below, you put "menu_name". should the above line be $required_fields = array('menu_name', 'position', 'visible'); ?
  12. Oh, I didn't even look at your query. You are selecting everything from the table. As long as there is information in the table, there will be some data taken from the table. if you want to add some limitations on what is retrieved, then you need to use a WHERE clause in your query. Right now, your query is taking the first 2 rows from the table. Your Loop is actually perfectly fine. If the query doesn't return any rows, than no emails will be sent
  13. Assuming your time strings will always be of that format (and have a valid time) You could do something like this $string = "RFC3339@2009-12-06T21:00:00"; $time = end(explode('@', $string)); $time = strtotime($time); $now = time(); $timeLeft = $time - $now; $secsInDay = 60*60*24;//60 seconds in a min * 60 mins in an hour * 24 hours in a day //day sleft $daysLeft = (int)($timeLeft / $secsInDay); $timeLeft %= $secsInDay; $secsInHour = 60*60; //hours left $hoursLeft = (int)($timeLeft / $secsInHour); $timeLeft %= $secsInHour; //minutes left; $minutesLeft = (int)($timeLeft / 60);//60 secs in a minute $timeLeft %= 60; //secs left is timeLeft $secsLeft = $timeLeft; echo "$daysLeft days $hoursLeft hours $minutesLeft minutes and $secsLeft seconds"; Just ask if you need an explanation
  14. I took the liberty of formatting your code. <?php $query1="SELECT * FROM ticket"; $sql=mysql_query("SELECT * FROM passenger LIMIT 2 OFFSET 0 "); while($array1=mysql_fetch_assoc($sql)){ $subscountry1=$array1['subs_country']; $subscountry2= explode(",", $subscountry1); for($i = 0; $i < count($subscountry2); $i++){ $subscountry[$i] = $subscountry2[$i]; $query_action1=mysql_query($query1); $num1=mysql_num_rows($query_action1); if(!empty($num1)){ while($array=mysql_fetch_assoc($query_action1)){ $id=$array['id']; $registration=$array['reg_no']; $country=$array['country']; $email=$array1['email']; if($subscountry[$i]==$country){ echo $id.$registration.$country; } } } } mail($email,"xxxxxx","xxxxxx","xxxxxx")."<br>"; } ?> From what I see, it shouldn't mail anything if there were no records found in the database, as the mail function itself is inside the while loop (which won't run if there are no entries returned. but, you should turn error reporting on. there is a syntax error here mail($email,"xxxxxx","xxxxxx","xxxxxx")."<br>"; That doesn't even really make sense
  15. <div id="button_brief" alt="button_brief" onclick="location.href='http://localhost/form/';" style="cursor:pointer;"> <?php echo form; ?> </div> ? I think i'm misunderstanding you, can you explain a little better
  16. I don't quite understand your question, and I'm not even sure if what your asking even makes sense... you can do a var_dump on a variable by... well... doing a var_dump and passing the variable in as the parameter. var_dump($my_variable); If this doesn't answer your question can you explain a little better
  17. try echoing $fetch before the if statement and see if its value is what you expect it to be. It seems OK to me, but without more information, I can't really say. You are sure you are trying to register with a username that doesn't exist on the database already right?
  18. when you compare a variable to a string, you SHOULD surround the string with quotes. IE instead of if ($action == ignore) { it should be if ($action == 'ignore') { when you have a string without quotes, PHP thinks you are using a global variable. IE define("globalVar", "value"); //now I can just use globalVar like so echo globalVar; However, PHP is smart enough to realize when you messed up, and meant a string (as PHP will assume you meant a string, when no global variable of that name is found) As CV said, you should turn error reporting on, so PHP can give you some feedback to why your script isn't working. error_reporting(E_ALL); ini_set("display_errors", 1); you say action is defined above? echo $action and post what its value is. Or better yet, post the code where $action is defined
  19. I don't see a problem at first glance. You say that when you take out that if statement then it works fine? What do you mean by "caught something"? Is there an error on the page? Blank page? what exactly is happening? try adding error_reporting(E_ALL); ini_set("display_errors", 1); to the beginning of your page. That will display any errors that may be happening One thing to consider, you are using headers, and when using header's you can't have any output on the page. THis means any whitespace, html tags, etc. So make sure there is no output up to that error check line
  20. firstly, please put your code in code tags. and for the love of god, format your code! You have 4 ending curly braces on 1 line! Its very hard to read your code, but i did notice that your mail function is inside the while loop. is this how you intended it to be? besides that I don't see much wrong, but again, I can't really read the code
  21. it should be if(strpos($email,'@') === false) { http://php.net/manual/en/function.strpos.php
  22. Give you a copy, No. This is a help board, not a get free scripts board. Here is a tutorial tho: http://www.tizag.com/phpT/fileupload.php
  23. I think your idea of arrays in general is kind of skewed. In PHP multidimensional arrays are nothing more than arrays of arrays. As far as if one is faster than the other, neither is really much faster as far as storing information goes. Traversing through an array is obviously going to be slower than accessing the value of a variable... but speed isn't really the point. Arrays are used to group related information. single variables are for any information that can't or shouldn't be grouped with other information
  24. it should be $user->name; using what you had makes PHP think you are using a variable variables (instead of accessing the name attribute, you are trying to access the attribute whose name is the value of $name. For example if $name is equal to "pass" then saying $user->$name is the same as saying $user->pass)
  25. What I posted above uses the extensionless filename as the link text but the filename with the extension as the href attribute. I tested this on my server and it worked fine.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.