Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Obviously global is the quick answer since you wouldn't have to make changes to every line that makes this call. Of course many out there do not like global, but if it's your solution for the time-being I don't see the problem.
  2. Good luck with this. The code has no comments to help us get the context of what is going on (at least for me!). An awful lot of stuff going here and if your friend wrote it and you accepted it, perhaps you should hold him or yourself responsible for fixing it.
  3. What trq means is "what code are you using now?"
  4. I would use a cookie (cookies must be enabled) and set a cookie named after the ip and the value of it would be my count. Then I would first check the cookie and if value is = 3 I would put out the error message that says they exceeded their allowed attempts. If not, then I would do my query to look for the user into and validate him. If it failed, I would re-set my cookie. If it doesn't fail (user logs in ok), then I would delete the cookie and go on about the business at hand. One problem with your script is your insert query doesn't insert anything.
  5. You ask how to send php vars/values to your JS code which is being output by this same php script, no? If 'main.php' is building that js code and outputting it, then that JS code is eventually going to call sendmessage.php. Since any php value has to be determined before the script finishes and can't be determined on the client, then it seems all you have to do is hard-code them in your js code when you output it. Either that or you are mis-speaking on your intent
  6. What do you mean by "mix all of them"? You mean you want to come up with a color consisting of blending all those colors? Kind of a meaningless task since the outcome is probably going to be #ffffff anyway. Think about it. What if you took 50 buckets of paint and put them all in a vat. What would it look like? What way would you take 50 six digit numbers and mix them up? Take a sum? Or maybe take each in 2-digit pairs and average them to get some kind of approximation of the same color (r,g,b) ?
  7. 1 - please the proper code tags when posting code here 'square bracket code square bracket' and 'squarebracket /code square bracket' 2 You really don't need to put quotes around your var names in your usage. $myfile = fopen("c:\\temp\\test.txt", "w"); $txt = $results; // NO QUOTES NEEDED. WHY THIS LINE? AND WHERE IS $RESULTS SET? fwrite($myfile, $txt); fclose($myfile); echo $results; // NO QUOTES NEEDED I notice you are using back slashes in your path and referencing your C drive. Are you not running on the web? Can you show us the url that you are calling your php script with?
  8. Are you messing with me? That string of chars isn't even IN this code! WHAT was the problem please?
  9. So - what is in $output? Simply echo that back to the caller and then have the caller display it in an alert. Better yet - I like to do this with any ajax-called script - is to just run the script from the browser address bar as if you were calling it from JS and add some debugging echos to do your testing.
  10. How do you KNOW there is a problem with num? Are you getting an error? Try turning on error checking first. Maybe you will see an error.
  11. This code: $results = implode("|", $output); $results = 'BEFORE'.substr($results, 4, 5).'AFTER'; echo "$results"; is confusing to me. You are taking $output and assembling the elements of that array into a pipe-separated string. Then you are grabbing 5 chars from the 5th position and returning it in the $results var. Really? How do you know what is going to be there from the array? Have you looked at $output?
  12. That means that the connect failed. Also you didn't finish your table.
  13. As Maxxd said earlier - you can't use 'header' once you have sent output to the screen. Since you're new - Anything that is outside of the php opening/closing tags is considered output. That means the php parser ignores it and just passes along to be sent to the client. So - your script begins with a set of html to begin a proper html document, ie, web page. Problem is you have some logic in your script that decides it doesn't want to do that. Too late - you already began the page. Solution: Design your scripts so that you examine the incoming data (from a form on the page perhaps?) and process it and decide what you want to do and do it BEFORE you start sending output, whether it is html code, javascript, css or any php variables. Basically php code at the beginning of the script, output at the end. Of course that html output at the end will probably contain php vars that you build in the top to send some dynamic data along with that html.
  14. I didn't say you were stupid - I said you did a stupid thing. Have you not read my signature?
  15. There are some posts out there that say the statement has to be formed like this: header("Location: name.php"); Note the cap and the space. As for the previous post - he's right. As for how you said you thought the header was supposed to be used, how come your only header command is NOT followed by exit? And one more thing: This is the stupidest thing that I see in new coders code: ?> <?php What is that supposed to be? Turn off php mode; turn on php mode? Why?
  16. Your query in the second is way too complex. Why the distinct? Are you saying that employee_id is not unique? I don't think so. Also - since you are not doing join and don't have multiple tables you can shorten this way down. $q = "select Current_GF as foreman from tbl_Employee_Master tbl where Separated=0"; And for the second query: $q = "select Employee_ID from tbl_Employee_Master WHERE Current_GF = '$GF'"; (Note the quotes on $GF) And for the 3rd query: $quer = "select Employee_ID, Last_Name, First_Name from tbl_Employee_Master order by Last_Name";
  17. And the foremen DO have their own record. Your current structure is not that bad. A better design would have been to use the foreman's own employee id in the current_gf field instead of his name. As it is my original solution will still work - you just have to retain the foreman's name instead of his id in order to do that second query for the second dropdown. Think about it. 1 - query the table for distinct current_gf values and output those names to build your primary dropdown. 2 - upon submit grab the incoming post value and do the second query looking for employee info that has that selected name as the current_gf field value.
  18. What is 'current_gf'? Is that the foreman's name? If so - bad choice - should have been id. If not, then how does one id any foreman? And whatever do you mean by "they should all should have a row (to) themselves"?
  19. PS - you should also use proper array syntax by quoting the indices. Yes - it works now but sometimes it doesn't. ($arr['index']) is the normal format and completely safe. And since you have no other references in your query statement I can only guess that 'body' is not a valid tablename in the current db
  20. What is your db table structure? I would imagine that each employee has an id. And that foremen have some indicator that they are in fact foremen. If not, how do you recognize them?
  21. Yes - tell us what "is not working". How smart do you think we are? Smart enough to see something where there is nothing? PS - add the code in my signature to turn on error checking at least. Then run it and tell us what you get.
  22. Do you want to do this via JS and Ajax? Or would a plain php solution work? The latter would be easy. Simply send the form with the primary foreman dropdown where the values in the dropdown are the foreman ids. Then when they submit that you take the foreman value and do a second query of employees in that foreman's unit. Take those query results and build your second dropdown and re-send the page with the selected foreman's element marked as the selected one. An Ajax solution is pretty similar. Same php solution just being triggered via js instead of a form submit.
  23. As said above - show us your attempt. A Real Attempt.
  24. Do you have a question? Other than the probable errors you have because you wrapped your vars in quotes?
  25. So - while doing your debugging (you did do that, right?) which of those scripts seems to be doing the posting work? Isolate the part of your code(s) to where the output is being created and then add some echos to help you see what it is doing and then you may see where it is going wrong. If not, then show us THAT part of the code with some explanation of what is supposed to be doing. Some of us don't open people's attachments. Phobias.
×
×
  • 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.