Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Which element of the sub-price-array do you want to sort by?
  2. The missing bit can be: [code=php:0]$multi_array[$dealername][] = array(   'address' => $address,   'phone' => $phone, );[/code] Then use var_dump($multi_array) to see what you've created :)  This code assumes there can be many addresses for each dealername.
  3. Try http://www.postgresql.org/docs/8.1/interactive/wal.html and http://www.postgresql.org/docs/8.1/interactive/storage.html
  4. It is possible!  Not with static SQL statements though.  He'll need to use mysql_list_tables() to get a list of all the tables.  Then mysql_list_fields() on each table to get the columns.  The output of that also gives the column types, which can be used to choose which tables are text. Then he needs to generate SQL for each of those columns to update it.. It sounds risky to me though.  I would do it manually myself, unless the number of tables was greater than 30 or so.  Even then, most tables are probably not affected and won't require any updating.
  5. I don't think that's what anarchoi wants to do.  He wants to update all columns of all tables.. so for this table: CREATE TABLE users (   username varchar,   id integer,   address varchar,   comment varchar, ); He wants to update all of the text columns so that 'old_url' is replaced with 'new_url'.  That's not possible using a standard SQL statement unless you list each column specifically.  But I think he wants it to be automated, so the script itself finds which columns of which tables to update. That's my understanding anyway (which could well be wrong!)
  6. That doesn't make sense to me, ataria.  Wouldn't that update rows with a particular value in the 'id' column? You could do it by using mysql_list_tables() and mysql_list_fields() to get all the tables and fields, and then doing an update on each combination.  I think it's worth taking the time to do it manually though, as most columns will not be affected.  And it's possible that some columns should not have the url changed, such as posts by users saying "The forum has moved from http://old_site to http://new_site"
  7. [code=php:0]echo session_save_path()[/code] will give you the path.
  8. Can you post more of your code?  The code which sometimes works but sometimes doesn't would be the best to look at. Cookies can be affected by displaying HTML before the setcookie() call, as they must be sent with the headers.
  9. How is the CSS on your webpage set?  The same method should work for this script.
  10. This code, when used before ANY html output, will redirect the user: [code=php:0]header('Location: http://site.com/page.html'); exit(0);[/code] If you have displayed any HTML before using that, then you will get an error. An alternative is to use a meta refresh tag, which I don't remember the syntax for.
  11. There's no simple command to do that. You can do something like this for each column of each table that might be affected: [code=php:0]UPDATE table SET column = REPLACE(column, 'http://old_url', 'http://new_url');[/code] Make sure you make a backup first!  Something like this can easily have unexpected consequences.
  12. [code=php:0]$user = $_POST['user']; $pass = $_POST['pass']; $something=date("F j, Y"); $user = mysql_real_escape_string(urldecode($user)); $pass = mysql_real_escape_string(urldecode($pass)); $result = mysql_query("SELECT * FROM users WHERE username = '" . $user . "' AND password = '" . $pass . "'") or die(mysql_error()); $co = 0; while($r = mysql_fetch_array($result)) { $co ++; $db_user = $r['username']; $db_pass = $r['password']; } if($co != 0) { print "error you dumbass, wrong password and or username!"; } else { echo "$db_user password correct"; }[/code] Hope that helps :)
  13. Check the capitalization on $distanceList inside the loop :)
  14. Browse through this list: http://sg.php.net/manual/en/funcref.php And take a closer look at the dbx and ODBC functions groups.
  15. Here's an algorithm for doing that (for consecutive integer indexed arrays starting at 0) [code=php:0]function select($array, $num) {   $array_count = count($array);   if ($array_count <= $num) return $array;   $results = array();   for ($i = 0; $i < $num; $i++) {     $choose = rand(0, $array_count-1);     $results[] = $array[$choose];     $array[$choose] = $array[$array_count-1];     unset($array[$array_count-1]);     $array_count--;   }   return $results; }[/code] Basically, this will choose a random item from the array, copy the last element in the array into the spot where that item was, and remove the last item.  Then it'll choose another random item. It will give you a random set of 100 items, and it'll work very quickly even with large arrays.
  16. What does [code=php:0]var_dump($_POST);[/code] show when you submit the form?
  17. Maybe it's because you specify the email as the first argument of mail(), in the To: header and also in the Cc: header.
  18. [code=php:0]while ($row6e = mysql_fetch_array($result6e)) {   print "<tr><td>{$row6e['column']}</td></tr>" } while ($row65 = mysql_fetch_array($result65)) {   print "<tr><td>{$row65['column']}</td></tr>" }[/code] Where "column" is the column name you want to display.
  19. You can't get rows from two results at once like that. What are you trying to do?
  20. That would match a principal with an interest rate of 50% PER MONTH over a period of 30 years. If you wanted an interest rate of 10% PER YEAR over 30 years, you would want (1.1)^30, which is around 17.45, much more reasonable.
  21. You re-wrote it?  What does your code look like now?
  22. I think your calculator may be buggy if you are getting numbers that large (or that small, if that's a "-" in front of it).  PHP's integers cannot hold numbers of that size.
  23. The first things I would try are to print out the value of $_gender to the screen, as well as [code=php:0]var_dump($_POST);[/code] I would also add [code=php:0] or die(mysql_error());[/code] to your mysql_query() line, to check if it fails. I'm also puzzled as to how you submit your form without a submit button.  Are you using javascript?
  24. We have a system where we create a template called "fred.html", and a script called "fred.php" containing the function "fred()".  That function populates an array of variables which are then passed to Smarty for use in fred.html When a request is made for page "fred", the main script looks for these templates and files, and calls the function fred(). Is that the kind of thing you are looking for?
×
×
  • 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.