Jump to content

johnsmith153

Members
  • Posts

    709
  • Joined

  • Last visited

Everything posted by johnsmith153

  1. Great, thanks, I thought it looked long just to do a simple check, but it worked so I was happy with that! Thanks again. Also, have you any idea how to remove everything from a string except letters, numbers and the @ sign, so: "hello123-123" = "hello123123" "John o'Leary" = "John oLeary" "aaaaaa11111111_1111@" = "aaaaaa111111111111@" Thanks again.
  2. Ok, great, thanks, although I think strpos would be better. Also, what about the number question, so: (1) "hhdhjdjdhjh1" = yes (2) "ddddd" = no (3) "jjjj333" = yes Check if any number appears anywhere in the string. etc. Thanks again for responding.
  3. Hi, I am planning on learning Regular Expressions but just don't have the time right now. I am trying to fix something for a friend and just want a quick fix. Please don't reposed with "have you searched Google?" or anything like that as I have and can't find the answer (within 20 mins anyway). I simply want the Regular Expression for checking for the existence of one single character. (1) Check if an @ sign exists in a string. (2) Check if any number exists in a string. ...both are for separate checks, so one check is to simply check if an @ sign exists in a string, and the other check is the number one. Please help. Thanks.
  4. Thanks for offering this solution. The problem is that the 'colour' field could be anything, so I really need a solution where it automatically picks up all duplicated rather than needing to know a set list of colours. Would it help to have PHP assist in some way rather than doing it all in MySQL?
  5. Ok, I'll do that. Do you have the answer?
  6. I have a simple db with values. I want to find all duplicate values and rename them 1,2,3 - so if I have these values for a 'colour' field: pID / color 1 / brown 2 / blue 3 / red 4 / red 5 / brown ...would result in: 1 / brown1 2 / blue 3 / red1 4 / red2 5 / brown2 ...is this possible?
  7. Actually no, I have spent many hours and I'm still struggling on this. The only thing lazy is thorpe's spelling ('where' in this, and many other examples in most of his other posts).
  8. That's exactly what the problem is (thousands of tutorials). Have you even read my post at all or just trying to bump up your post count figure?
  9. I am learning mod rewrites and finding it difficult where to start. If someone can show me sample code for the following, I think that will help: (1) Simple redirect when they enter www.site.com/view.html to view the page on the server: www.site.com/pages/view.php (2) Simple redirect like 1 but to append a variable. So they enter www.site.com/jim-brown and I want it to use www.site.com/profile.php?nm=jim-brown I know most people will say I need to learn it myself but this will help me start.
  10. Can't create a single login due to limitations of hosting provider. Each db must have a separate user login. In the end the obvious thing is to use kickstart's query (but for the accounts table only) and as not too many records would be returned (I'm only looking to return accounts in the red), I can then run another query (on the 'users' db) to get the user name and any other info using whatever id's are returned from the search of the accounts db. A lot of the time there won't be anything returned at all from the 'accounts' db anyway, so no further query needed. I've done this and it works great. Thanks for all the help.
  11. Thanks for this, except I forgot one important thing (sorry): The two tables are actually in different databases. They are on the same db server, but use a different user id / password to access them. I have all the usernames/passwords. Is this possible? If not, what do I do as moving them isn't possible? Would I need to dump the entire accounts table and do a sort in PHP?
  12. I have a table like this: primary-id / user-id / payment / charge The 'payment' and 'charge' fields are decimal (5,2) datatypes and refer to a payment into the account and charge on the account. So, for user 1, these records may exist: 1 / 1 / 20.00 / 93 / 1 / 10.00 / 159 / 1 / / 5.00 … so their account balance would be $25 Imagine the user's table as simply being Name / id / is_active Dave / 1 / 1 (example above) Jim / 2 / 0 (an inactive user) I need to return any user where their account balance is more than $2 in the red. I imagine it would be something like this: SELECT user-details, actual-a/c-balance WHERE SUM(etc.)<-2 …but could do with a bit of help. Thanks.
  13. I am simply importing a CSV file to MySQL. Somebody has given me a CSV file and imagine fields are Name and Age it is like this: jim-brown,32 dave-smith, 25 bob-roberts,19 ...surely it would be easier to do "Jim Brown", 32 "Dave Smith", 25 "Bob Roberts", 19 ..or am I missing something, would these be capitalised and the dash removed on import?? Thanks.
  14. Imagine a simple form where you submit name and hair color (example). You want them to select from brown, black and blonde hair color only. How would the db be setup? I'm thinking assign a number (1) brown, (2) black and (3) blonde and only store the number in the db. Is this the best way? What are the alternatives. I've seen people store the full colour name in the db. Thanks.
  15. Joining two tables: A simple users and photos table. They are connected by a user_id field. (1) Users table. (2) Photos (a 'profile_pic' field flags which photo is the profile picture) There are lots of records in the photos table. I want to simply return every user and display their profile picture (if they have one). These are the issues I have: (1) A simple join always returns the same number of records as there are photos, not one record per user (so if a user has 50 photos, I see the user record 50 times). (2) If I use GROUP BY then I don;t see multiple records per user, but I don;t have any control over which record is selected from the Photos table. (3) If I simply use: WHERE profile_pic = '1' ...then if someone doesn;t have a profile pic I don;t see their record at all.
  16. DELETE FROM $table WHERE a=1 LIMIT 3 ... or something like this where it deletes a maximum number of records (3 in this case). Thanks.
  17. I have this: /^[a-zA-Z0-9]+$/ ..which allows only letters and numbers. But I also need to allow spaces as well (nothing else though). Thanks in advance.
  18. I have a text string and I need to find the value that appears after a certain value: Value that appears after "XXX:" "Test 123 Hello XXX: 1 Test 555"; So the value would be "1" Any ideas?
  19. I need a regular expression that detects a web address in a string of text. I need it to find any http://www or www. web address. Any domain (.co.uk, .com anything) All these would be picked up: http://domain.com http://www.domain.com www.domain.com http://domain.co.uk http://www.domain.co.uk www.domain.co.uk Also, it must pick up all folders and other url variables (www.site.com/page1?a=123 etc.) ** Also, most importantly:*** It must NOT pick up web addresses that are inside a <a href="">xxx</a> link already, only oes that are plain text and not embedded in this HTML. I have tried but it only does bits of the above. I can do the PHP code, just need to know the regular expression to drop into my preg_match_all code. Thanks in advance.
  20. E.g. 18:00 - 22:30 $a = "18:00"; $b = "22:30"; this would return 4.5 (hours) 22:00 - 01:00 would return 3 hours
  21. Thanks. I think you second url is a duplicate of the first. Do you have one to check for www. and http:// ? Thanks again.
  22. Brilliant. Thanks for taking the time to help. Also, I want to convert plain text links into the HTML hyperlink equivelant. So, "www.test.com" becomes "<a href='www.test.com'>ww.test.com</a> I have managed to do it, I think, but it also replaces the address in hyperlinks already set. So, Go to www.test.com or click <a href='www.test.com'>HERE</a> If I try and change all web links in the above it will also change the <a href='www.test.com'>HERE</a> part, which I don't want it to. Any ideas?
  23. Any idea how to replace all occurences?
×
×
  • 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.