Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,508
  • Joined

  • Days Won

    185

Everything posted by mac_gyver

  1. you would add a WHERE term to your query that either excludes the admins or selects everyone but admins, whichever is easier to do. edit, lol, see the above reply by jessica.
  2. your code has no error checking logic to get it to tell you where or why it might be failing. see the code in the following post for some pdo prepare/execute logic with error checking - http://forums.phpfreaks.com/topic/277964-using-mysql-and-php-to-extract-from-a-db/?do=findComment&comment=1429891
  3. for that specific query, you are expecting either zero or one row - if($row = $stmt->fetchobject()){ // query matched the one expected row } else { // query matched no row } i'm also pretty sure there is no pdo fetch_object() method either.
  4. input parameters can be supplied as an array in the execute() method (all values are treated as strings though.) other than the try/catch around the connection, your code has no error checking in it (the $pdo->connect_errno property doesn't exist and isn't doing anything.) i'm also pretty sure that there isn't an $stmt->num_rows property either. you would use the rowCount ( void ) method, when it exists (is usually better to just fetch/fetchall the rows and test if any rows were fetched. do you have php's error_reporting/display_errors turned full on so that php is helping you? you need to use logic like the following to check for errors - $dsn = "mysql:host=localhost;dbname=maindb"; $user = "root"; $password = "mypass"; try { $pdo = new PDO($dsn, $user, $password); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } $query = " your query statement here "; if(!$stmt = $pdo->prepare($query)){ // prepare failed echo "<pre>Prepare failed:\n"; print_r($pdo->errorInfo()); echo "</pre>"; } else { if(!$stmt->execute(array($page))){ // execute failed echo "<pre>Execute failed:\n"; print_r($stmt->errorInfo()); echo "</pre>"; } else { // query ran without any errors, you can test if it returned any rows and use them here } }
  5. a basic while(){} loop can be used to do this as well.
  6. the suggestion to use a bootable linux cd wasn't to install linux, it was to boot to an environment where windows isn't running so that you can delete the file without it being locked by the windows operating system.
  7. did you try searching the source code for the offending alt='image' tag and change it to use the filename variable?
  8. you will also need to enclose customer_# column name in back-ticks as the # isn't normally permitted in an identifier - `customer_#`
  9. afaik, there's no direct equivalent to msyql_result, because it is so inefficient at what it does. you need to fetch the row and access the value. you can do this all at once using - list($count) = mysqli_fetch_row($query_run);
  10. and what do you suppose that means?
  11. 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 (
  12. 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.
  13. 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.
  14. see item #4 in my post above.
  15. 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.
  16. 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.
  17. 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?
  18. 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.
  19. 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.
  20. 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>"; } }
  21. 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 }
  22. 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.
  23. 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.
  24. 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.
  25. 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'";
×
×
  • 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.