Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,448
  • Joined

  • Days Won

    174

Everything posted by mac_gyver

  1. and what do you suppose that means?
  2. re: your edit in post #18 with the line of code and "I removed the full php tag in line 1 and that fixed that." in post #20. the way to fix an error is to find what's causing it and make it right. by changing the php tag back to a non-working php tag, all you did was to effectively remove the line of php code because php no longer sees it as being php code. what's wrong with line 1 of your file is very likely what is causing the latest error. your include statement isn't working because you have a syntax error in the line of code. you either need to add a missing ) to match the ( you do have or since the include statement isn't actually a function, you can remove the (
  3. that's a very common error message (in the top 3-4 php errors). searching for the keywords in it would tell in general what it means and how to debug what is causing it. for debugging, echo mysql_error(); on the next line after the mysql_query() statement line.
  4. cannot actually help you with that error without seeing line 1 of your file, except to say that there was something that caused an unexpected ';' to be found in it.
  5. BTW - other than your password minimum length check being backwards, your code works as expected for me as well, displaying the expected messages for non-matching usernames and passwords.
  6. here are somethings a little more basic to try to find out why it isn't working - 1) what URL are you entering in your browser's address bar? it should be something like http://localhost/your_file_name.php 2) what is the filename? it must end in .php (unless you have configured your web server to run other extensions as php files.) 3) do you have php installed? does a simple script with <?php echo time(); ?> work? 4) always use full opening php tags <?php 5) your form and your form processing code are apparently all in one file. you may have something that you are not showing us in that file that is preventing the form from being valid or preventing the form processing code from running. post the entire file as is, less any database credentials. out of context snippets of code don't help when the problem is that the whole PAGE doesn't work as expected.
  7. what link? what new tab? $_POST data will be available only on the page that is the target of the form. anything you do to goto a new page or refresh that page will clear the $_POST data. and did you see the post i made above about your process.php code?
  8. your process.php page is probably redirecting back to itself and clearing the $_POST data and/or you don't have an exit; statement after a redirect to prevent the rest of your code from running. you need to post the code that reproduces the problem. not all your code, but the code you do post must have been tested by you and it reproduces the problem.
  9. the best way of doing things randomly without repeats is to remove each choice from the 'pool' of choices as it gets used so that it no longer can be picked.
  10. if $_GET['error'] is optional (may or may not exist), you need to first test if it is set before you test the value in it. if(isset($_GET['error']) && $_GET['error'] == "notnumeric"){ if it's not optional and you expect it to always be present, you should probably troubleshoot why it isn't present. if you are are testing that variable against more than about one value/error message, you should reduce the amount of logic needed to only one set and lookup the value using an array that maps the incoming text string to the actual message - $error_lookup['notnumeric'] = "*** Error! One or more fields was left blank or contained a non-numeric character."; // add other error names/error messages here $error = isset($_GET['error']) ? strtolower(trim($_GET['error'])) : ''; if(!empty($error)){ if(isset($error_lookup[$error])){ echo "<p class='error'>$error_lookup[$error]</p>"; } else { // bad value echo "<p class='error'>An undefined error ($error) was triggered.</p>"; } }
  11. mysql_fetch_array only fetches one row each time it is called. to loop over all the rows in a result set, you might have seen some logic that looks like this - while($row = mysql_fetch_assoc($result)){ // code to run for each row }
  12. the only thing your code needs to do is run 1 (one) query that gets the content of the cart, then loop over the rows that the query retrieved and produce the output that you want. your foreach(){} loop makes no sense, it is looping over the first row in the cart and your query inside of the loop makes no sense because you have already queried for the contents of the cart.
  13. because you are carrying over the end point from the previous row in variables, you can just put the starting Garage point into those variables before the start of the loop and you will no longer need to have any of the $first_pass logic or the if( $lon2a == "" or $lat2a =="") logic. the only things inside of the loop would be the assignment statements for the variables and two $distance += ... statements.
  14. if you can upgrade to php5.4, register_globals have been completely removed and so cannot be turned on, and you won't ever see program variables being overwritten by the language itself.
  15. the syntax you are using for the $manager variable in the WHERE clause is adding dots . before and after the value, so your WHERE clause is false and is not matching anything. you can put a php variable inside of a double quoted string. you also had single quotes around the column name in the SELECT clause, which would have literally returned the string 'manager' - $query = "SELECT manager FROM tablename WHERE manager='$manager'";
  16. @jazzman, READ the thread you are replying in. it concerns a php $_SESSION variable being overwritten.
  17. if you where doing this on paper, how would you find the distance between the last point in one row and the first point in the next row? the point of us helping you, is that you try to do this yourself first, not just to post what you want.
  18. a slightly different method to accomplish the same steps (runs faster when there are many rows) - // get Garage location for the driver ($lat,$lon) // get the route points for the driver (rows must be retrieved in the correct order) $distance = 0; // accumulate the distance // fetch the first row from the result set and get the first point ($lat1,$lon1) // calculate the distance from the Garage to the first point of the first row $distance += calc_distance($lat,$lon,$lat1,$lon1); mysql_data_seek(0); // reset to the first row of the result set // loop over the route points for the driver while($row = mysql_fetch_assoc($result)){ // assign $lat1,$lon1,$lat2,$lon2 // calculate the distance for each row (segment) in the route $distance += calc_distance($lat1,$lon1,$lat2,$lon2); } // calculate the distance from the second point of the last row to the Garage $distance += calc_distance($lat2,$lon2,$lat,$lon);
  19. here are some hints - 1) you need to write a function to calculate the distance between points so that you don't need to copy/paste/change that line of code everywhere you are using it 2) you need to define the steps that solve the problem before you can write any code to do it. see the following outline/pseudo code - // get Garage location for the driver ($lat,$lon) // get and loop over the route points for the driver (rows must be retrieved in the correct order) $first_pass = true; // flag to detect the first row inside the loop $distance = 0; // accumulate the distance while($row = mysql_fetch_assoc($result)){ // assign $lat1,$lon1,$lat2,$lon2 // calculate the distance from the Garage to the first point of the first row if($first_pass){ $distance += calc_distance($lat,$lon,$lat1,$lon1); $first_pass = false; } // calculate the distance for each row (segment) in the route $distance += calc_distance($lat1,$lon1,$lat2,$lon2); } // calculate the distance from the second point of the last row to the Garage $distance += calc_distance($lat2,$lon2,$lat,$lon);
  20. register_globals (thanks php.net) would overwrite $_SESSION['whatever'] any time you do $whatever = some value; and it will also get overwritten by a $_POST['whatever'], $_GET['whatever'], or $_COOKIE['whatever'] value.
  21. the problem is likely due to register globals or you have a session_write_close() prior to that assignment statement so it isn't actually storing to the session data and you are seeing a previous value that was stored or the code isn't successfully starting a session so that you are seeing a previous value stored in the session data. do you have php's error_reporting/display_errors both set to full on so that any session or variable reference errors will be reported? have you tried just echoing the base64_encode of a string to see what it outputs?
  22. echo $_SERVER['DOCUMENT_ROOT']; so that you can see what it is that the code should be testing for.
  23. there's a whole section for this in the mysql documentation - http://dev.mysql.com/doc/refman/5.5/en/example-maximum-column-group-row.html does the box column actually the number name, one, two, ...? if it was the numerical number 1,2,3... it would be easier to order the output. however you cause use ORDER BY FIELD(box, 'one', 'two', ...) to order by the number name.
×
×
  • 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.