Jump to content

bljepp69

Members
  • Posts

    111
  • Joined

  • Last visited

    Never

Everything posted by bljepp69

  1. you either need to do this: [code]mysql_query("UPDATE software SET naslov = '$naslov', opis = '$opis', kat_id = '$kategorija', cd_id = '$cd', novo = '$novo' WHERE id = '$id'") or die(mysql_error());[/code] or, something like: [code]$popravi = mysql_query("UPDATE software SET naslov = '$naslov', opis = '$opis', kat_id = '$kategorija', cd_id = '$cd', novo = '$novo' WHERE id = '$id'"); if ($popravi)   echo "Product has been successfully updated!"; else   echo "Error: ".mysql_error();[/code] The problem is you are assigning the query to a variable, but not doing anything with that variable that would cause the update query to run.
  2. try: [code]preg_match("/<div>(.*?)<\/div>",$lookhere,$output);[/code]
  3. Try browsing this site - [url=http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3]http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3[/url] as they have a number of regular expressions already built, tested and commented.  On the bottom of the page linked above, there is a regex that should do what you want: (?n:(^\$?(?!0,?\d)\d{1,3}(?=(?<1>,)|(?<1>))(\k<1>\d{3})*(\.\d\d)?)$) or, another one I found: ^(\$)?((\d+)|(\d{1,3})(\,\d{3})*)(\.\d{2,})?$ check the site to read the descriptions of what each does.
  4. Thanks!  That's the help I needed to finish this up.
  5. I've been trying to come up with a single regular expression to break a string apart, but I've not been able to get one that works in all instances.  I have a string of song names.  The way it's given to me is shown in the example text below: 1.20th Century Boy2.Rock On3.Hanging On The Telephone4.Waterloo Sunset5.Hell Raiser6.10538 Overture7.Street Life8.Drive In A Saturday9.Little Bit Of Love10.Golden 21 Of Rock & Roll11.No Matter What12.He's Gonna Step On You Again13.Don't Believe A Word14.Stay With Me It's easy enough to find all the song numbers.  Something like - '/([\d]{1,2}\.)/' - will return just the song numbers.  When I try to expand the expression to find the song names, the closest I can get is - '/([\d]{1,2}\.[^(\d{1,2}\.)]+)/'.   However, that won't return song names that start with numbers, such as number 1 and 6 above, and it truncates number 10 at the number. I'm really hoping to be able to split this into the proper pieces with a single reg ex.  Any help is appreciated.
  6. Your function is returning a value so you need to have something to receive that value.  Change this: modifyPost($message); to $cleanMessage = modifyPost($message); and then use $cleanMessage in your db query. Also, check out nl2br()
  7. Remove the " from around " $sql1. so...mysql_query($sql1).
  8. Looks like you are using cookie based sessions.  You must call session_start() before anything is output to the browser.  When you wrap your site around the search function, you are outputting information to the browser before the call to session_start() happens.  This might be fixed by simply adding the following to the very top of your index.php page for your search: <?php   session_start(); ?> Then go on with your page processing.  Note: remove the call to session_start() from later on in the page.
  9. You may want to check out this excellent tutorial on [a href=\"http://www.phpfreaks.com/tutorials/129/0.php\" target=\"_blank\"]MySQL Full-Text Searching with PHP[/a]. Your query will be set up differently, but you are likely to get back better results.
  10. I think I got it. Any comments on this? SELECT survey_id FROM thistable GROUP BY survey_id,sess_id
  11. Here is a simplified version of a db table I'm using: | index | survey_id | quest_id | sess_id | +-------+------------+----------+---------+ | 1 | 10 | 1 | aaa | | 2 | 10 | 2 | aaa | | 3 | 10 | 3 | aaa | | 4 | 33 | 1 | aaa | | 5 | 33 | 2 | aaa | | 6 | 10 | 1 | bbb | | 7 | 10 | 2 | bbb | | 8 | 10 | 3 | bbb | | 9 | 44 | 1 | ccc | | 10 | 55 | 1 | aaa | | 11 | 55 | 2 | aaa | | 12 | 44 | 1 | ddd | | 13 | 44 | 1 | aaa | +-------+------------+----------+---------+ So what I want to retrieve is the number of times the survey_id occurs, but only count it once per sess_id. So, in the example above, survey_id 10 would be have a count of 2, 33 would be 1, 44 would be 3, 55 would be 1. Note that the quest_id's are tied to the survey_id's and don't really mean anything in this particular query. The sess_id column is there specifically for this query. Basically, I'm tracking user answers to a survey, and I have a function to show the most active surveys for a given time period. So, the interpretation of the above data shows that survey 10 has three questions, and was answered by two unique users. Therefore, I only want to count it twice, not 6 times. Lastly, in any given session a user can answer multiple surveys. That's why you see the sess_id show up multiple times. I'm pretty sure this can be one with one query, but I can't seem to come up with the correct syntax. I know it can be done with two queries, but I'm trying to avoid that. Anyone have any suggestions for the correct query syntax?
×
×
  • 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.