Jump to content

ManiacDan

Staff Alumni
  • Posts

    2,604
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by ManiacDan

  1. When confronted with a problem like this, it's often a good idea to take a step back and ask WHY you only want one hyphen. What purpose does that serve? However, this regex solves your issue without asking why: /(^-[a-z]+$)|(^[a-z]+-[a-z]+$)|(^[a-z]-$)/ Also, in the future, please describe the whole problem. Xyph answered your question in its entirety, and then you came back and said "that's a good start, now here's two more rules."
  2. Thank you for coming back and posting the answer. The boards tend to get low traffic on the weekends. Next time your thread is solved, you can click the "mark solved" button along the top or bottom to mark it as such. I've already marked this one for you. Come back if you need more help!
  3. If there's no match, $result will still be an object. You need to be using mysql_num_rows here. Also, your passwords don't appear to be encrypted.
  4. You shouldn't be storing data like this. You should have: CONTINENT ------------- CONTINENT_ID NAME COUNTRY ------------- COUNTRY_ID CONTINENT_ID NAME That way, you don't have delimited strings in your database (which is [almost] always wrong) and you'll be able to do real queries on this data. Then, your inserts would be easier too, without having to use implode().
  5. Wow, that was quick. So now you have the tables: Listing --------------- name country state town datejoin active country ------------ id name state ------------ id name town -------------- id name And you would like a list of countries, states, and cities in your database with their total number of records for each, right? That will be (something like): SELECT COUNT(country.name) countryCount, country.name countryName, COUNT(state.name) stateCount, state.name stateName, COUNT(town.name) townCount, town.name townName FROM listing JOIN country ON listing.country = country.id JOIN state ON listing.state = state.id JOIN town ON listing.town = town.id GROUP BY country.name, state.name, town.name WITH ROLLUP ORDER BY country.name, state.name, town.name The phrase "with rollup" means that you will get "grand totals" in your table. You will have to loop through this data set, which will include rows in which you will see NULL for the town and a value for state. That is the grand total for that state. Then if you see a row with NULL for town and state, that's the grand total for the country. If the results are confusing, let me know.
  6. If this time ever goes past midnight, it will be wrong on days with daylight savings time. Otherwise it's correct.
  7. TIME, as computers handle it, is not in the format of 09:15. TIME (like the second argument to date() and strtotime()) is the number of seconds since 01/01/1970. You are trying to give "7:10" when 138348402382 is expected. You have to do this math by hand, there is no way to add minutes and hours in PHP without also giving it a date string. Also, you're using "+10" as your argument to strtotime. 10 what? Strtotime assumes seconds, since as I said above time is measured in seconds.
  8. You have a column that's actually called "location" and contains data like "12#42#139"? If so, (a) you did it wrong and (b) you'll never get your counts unless you load the entire table into memory in PHP and chunk through it, counting them by hand. Your table should have had a city, state, and country COLUMN (3 columns, not 1), so you could easily do this in a single query.
  9. You can't do what you're trying to do, you must instantiate the LOWEST classes in order to use their functions. You could make a __call function in the parent class which attempts to call the functionality of the child classes dynamically, but all child functions would have to be static, not dynamic. If you wish classA and classB to share functionality, you can put that functionality on classMain. if you want them to share actual values, you'll need to make classMain a static or singleton class (NOT the parent) and make it a variable on classA and classB.
  10. foreach ($row as $key=>$value) echo "<input type='hidden' name='$key' value='$value'>"; That code produces a HIDDEN input for every piece of data in the table. Perhaps you don't want hidden?
  11. Your first bit of code is using $_POST backward and calls function submitForm, which we cannot see. Your second bit seems ok, but it pulls from a database table which, again, we cannot see (and is named/designed wrong). That table is never inserted into.
  12. The directions API documentation doesn't say anything about payments or subscriptions.
  13. There is no built-in base bbcode library you can compile into your PHP installation. Edit: I meant that you probably don't have it already compiled and we know you run on shared hosting /Edit. There are only custom-written functions like the one you were already handed.
  14. But then he has a configuration utility and it's just a big mess. Either way, he appears to be gone, we've laid out the two scenarios and given him the file-put-contents solution.
  15. I took it the way scoot took it. There are two scenarios: 1) he's writing a software package that will be installed "locally" on the customer's webserver. It needs to accept creds to the user's database, make itself a new user, then discard the user's creds and store its own in plaintext in a file. 2) He's writing an application on HIS server which will remotely connect to someone else's database and perform actions. In this case, remote creds need to be encrypted in the database, and preferably have a database that's not accessible to the outside world except through the webserver.
  16. Right, the credentials don't need to be encrypted if they're right there in the file. If you're storing the credentials to OTHER services in the database, encrypt them there, but db passwords should always be plaintext.
  17. That's what devshed does, the ID is before the title. I added a slash instead of a dash for no real reason above.
  18. Right, that's the issue. Forums would crash instantly if we had to uniquely identify "please help" as a thread title. Also, articles aren't good for this either because of the likelihood of adding things like [update] and [Fixed] to the title. Unique IDs all the way.
  19. The "no it's not" was in response to "Is this the right way to do it?" You can't have JUST the post title in your URL, how would your pages know what to fetch? You usually want your URLs to look like: www.yoursite.com/article/123/How-to-use-mod-rewrite-to-make-seo-friendly-urls Mod-rewrite will turn that link into: www.yoursite.com/article.php?id=123 There is no "removing" of data, mod-rewrite takes a full URL and...rewrites it. You would publish the "pretty" version above, and mod-rewrite would turn it into the "useful" version, stripping off the useless-to-computers bit at the end.
  20. Good eye kicken.
  21. You're not understanding what we're saying: This is not a PHP problem. It has nothing to do with PHP, the session, or anything else. You are trying to insert a row into a MySQL table which has a foreign key constraint on it. That constraint requires that the agentId you insert already be present in another table. it is not, so the insert fails. That is the purpose of foreign keys, and you would get this error if you tried to insert this row by hand directly onto the database server.
  22. Welcome! Congrats!
  23. Accept the root username and password. Create yourself a database and a user unique to your application. Discard the root credentials. Proceed with the standard username for your application (and a random password hopefully).
  24. No, it's not. You're looking for a technique called mod_rewrite, which is a set of regular expressions in your apache config that turn friendly URLs into query strings your pages are actually capable of using.
  25. You're probably missing the code that makes $myPageActive into a real variable. Does your code say $myPageActive = $_POST['myPageActive'] anywhere? If not, you need it. If you're working under this assumption that you won't need to do this, stop right now. The behavior that used to do this was called register_globals, and it was dirty and wrong and has been removed from PHP entirely. You must use $_POST directly.
×
×
  • 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.