Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. Everytime the web browser is closed or the connection to the web server is in any way ended, the session data is disgarded. You probably want to use a cookie rather than a session. Also, $_SESSION['visits']++; will fail unless that value already exists. for first time users it won't exist, and will generate an error. You need some sort of if statement to detect if they are first time users (probably using isset() with $_SESSION['visits'] as the parameter) and if its their first time then set visits to 1 (or 0, whichever value would make more sense to you)
  2. can you post the code that uses sort(). which variable are you sorting? you should be sorting $names
  3. No problem. Thats what i'm here for. marking your topic as solved
  4. going to mark your topic as solved. glad your question got answered
  5. You overwrite the value of $ID in each iteration of the loop, so at the end $ID consists of the last value returned from your query
  6. Oh, json_encode is available in php version 5.2.0 and up
  7. You can't call a PHP function with anything but PHP. You have to remember that PHP is executed by the server when the page is requested. by the time the HTML is output and stuff (whatever the user sees) is all clientside. If you want you could use AJAX, but it would probably be easier to just use javascript. Or you could just make it a 2 step process, and have the form submit to a page that would execute that PHP, and that page redirects based on whatever criteria you have.
  8. The easiest thing to do in my opinion, would be to scrap trying to create a json string by yourself, and instead create a php array and just use json_encode (this function translates a php objects like an array into a valid json notation.) so for example, instead of an empty string you would set $json to an empty array and add things to it like you would a normal associative array, so $json = array() for (...){ .... if(empty($service)) { $json['ErrorService'] = "ERROR: You must select a service level"; } .... ... }//end of for $json_string = json_encode($json);//now this is a valid json string of your php array
  9. well no, that should be outside the loop. I'm not sure what tab your are talking about (I use firefox for development so I don't know about chrome) try using firebug to get more information on the problem
  10. TO be honest though, there is a function that can translate a php object into json notation. its called json_encode. you can use it like so $arr = array();//empty array for($i=0; $i < count($dataArray); $i++) { $p = $dataArray[$i]; $p = explode(":", $p); $addr = $p[4]; $arr[] =$addr;//push each address onto the array } echo json_encode($arr);
  11. Ah its a javascript error. Your json seems malformed. can you post the json string that you get from this script?
  12. Which of the two parameters take priority? closeness or the station priority? like say 1 station has a higher priority but a higher distance also. Which station is assigned to the drill in question? This could be as simple as calculating the distance as JKG mentioned, but a little more information would prove useful in helping you solve this problem.
  13. Also, in the future, you may want to at least post the code that is giving you problems. Sometimes you get lucky and someone who is familiar with the 3rd party script will spot your problem. Judging by how you describe the problem though, it sounds like you should concentrate on the basics of PHP for a little longer before you start using and altering 3rd party programs
  14. can you paste the exact error message and line number?
  15. You can't use the onsubmit event with PHP. This functionality is reserved for javascript. If you want a function to run on the submit event, you will need to convert your php code to javascript and call it that way
  16. Well that depends on what you want your iframe to look like. You will probably want to create a page (perhaps iframe.php) that generates your iframe card for other sites in PHP (the code will basically be the same as results.php, including the part that uses teh $_GET variable) and use that as the src of the iframe. An example URL for the iframe src would be mysite.com/iframe.php?id=112. obviously you would replace mysite.com with your sites url.
  17. sounds like a simple syntax error. can you post the current code?
  18. well the code produced by that script adds an extra comma to the end (in your case, after the first entry in the javascript array) which makes the produced javascript invalid. You need to remove that trailing comma and newline. The following would probably be better <?php $str = "";//start with empty string for($i=0; $i < count($dataArray); $i++) { $p = $dataArray[$i]; $p = explode(":", $p); $addr = $p[4]; $str .= "$addr,\n";//concatenate instead of echoing } //now we can echo, but before we need to take off the ending 2 characters $str = substr($str, 0, strlen($str)-2); echo $str; ?>
  19. yes this is what I meant. Thank you for clarifying.
  20. Well, you marked this topic as solved, but the reason is you that when accessing a base classes methods, once inside those methods you only have access to other base class attributes/methods. So even though you overrided the base classes method, while inside the other method of the base class, it doesn't know of your override more of less. I can discuss this in more detail if you would like.
  21. look into the mysqli_xxx_xxx_fetch method, detailed on this page: http://php.net/manual/en/mysqli-stmt.fetch.php The second code example given on that page seems like it accomplishes what you want.
  22. The easiest solution would be to simply remove the slashes using PHP's stripslashes() function. However, as Pikachu pointed out, the problem most likely stems from a setting in your php.ini. It would be best if you turned this setting off, to avoid this problem in the future. Unfortunately, the text in your database already will be unaffected by this change. Is your server in development or production?
  23. Ok well a couple of questions I want to ask about this thing you want to implement. You could code it a few different ways depending on what you want. Do you want the user to be able to press a button, and then the timer starts, and they can navigate away from the page or close the browser or whatever, and they are still leveled up after 5 minutes? Or do you want it so that they click a button, and have to stay on the page watching the counter (or whatever other activity they can do) until 5 minutes have passed, and then their level or whatever is updated. For the former, The simplest way I can think of would be to have a table that stores that time stamp when they pressed the button, and whenever they navigate to a new page, you check that table to see if enough time has passed (if so, update the table, otherwise don't). The only downside to this is that the table isn't updated at exactly 5 minutes. They could press the button, and go on vacation, and the table wouldn't be updated until they login again. You could also have some sort of Cron job that checks the table every xxx amount of time, and updates accordingly (or a combination of the two), but this could severly slow down your system if you have a lot of users in your table. If the latter, you could use a combination of Javascript and AJAX to show a counter, and have the AJAX send a request to an update script once the count down is finished. The downside to this is you force the user to basically watch a counter for 5 minutes (assuming they can't do anything else on the page)
  24. It sounds like what you are trying to do is have restricted pages (like a members_area type page). Have you created a login script yet? if so, then you probably use sessions or cookies. Either way you simply check if the session or cookie is set to the correct value, and if not show an error message (like "You must log in to view this page") or simply redirect the user. if you haven't created a user login script then, as phpSensei suggested, you should consult google for some tutorials
  25. If you want to save the last page a user was at (whether they were a guest or not) why not just use a cookie?
×
×
  • 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.