Jump to content

lxndr

Members
  • Posts

    72
  • Joined

  • Last visited

Everything posted by lxndr

  1. I've changed the code and removed the quotes but the problem still remains. Contrary to my original post it does appear that the date field updates but the game_id is still 0, the game_name is blank and the popup value is 1 instead of 0 ?
  2. game_name: varchar(35) game_id: int(4) date: int(11) user: varchar(45) popup: tinyint(1)
  3. I have a situation regarding an SQL update which I really can't make any sense of at all. I'm executing the following call to MySQL: $sql = "UPDATE arcade_lp SET game_name = '$game_name', game_id = '$game_id', date = '$today', user = '$user_name', popup = '$popup' WHERE user = '$user_name' "; if ($user_name == "admin") echo "debug: $sql<br>"; $result = mysql_query($sql, $db) or die(" - Failed More Information:<br><pre>$q</pre><br>Error: " . mysql_error()); The debug from above shows the following debug: UPDATE arcade_lp SET game_name = 'klax3dEasyJS', game_id = '273', date = '1180010641', user = 'MikeL', popup = '0' WHERE user = 'MikeL' Yet following the above MySQL transaction the actual database contains: game_name: blank game_id: 0 date: "contains previous value, i.e. not updated popup: 1 How is this possible ???? ..
  4. I have a table with a column called 'forename' and what I want to be able to do is put all the different values for forenames into a PHP array but only once each, i.e. if there are 20 instances of the forename "John" I only want one of them, in other words I want to capture all the different values. I could do this I guess by using an SQL GROUP query but was wondering if there was a better/more efficient way ? ..
  5. Thanks to both of you for the speedy replies, I shall follow up your suggestions. ..
  6. I have a routine which reads in the names of all the GIF graphic files from a particular directory and displays the actual images but what I want to be able to do is just display a PART of each image. For example, all of the images are 500 pixels wide by 55 pixels high and I want only to display the first hundred pixels width of the image so that I would in effect have just a portion of each image starting from the left and 100 pixels wide. Can it be done ?
  7. I know this should be easy but I just can't get it to work. What I want to do is process a string and extract just those characters between a pair of double quotes: i.e. input string: 'blah blah', "text" output string: text input string: 'some characters', "more text" output string: text The input strings are read in from a text file. Thanks for any help.
  8. [quote author=effigy link=topic=123886.msg512712#msg512712 date=1169675182] There may be a better way, but try this: [s][tt] SELECT name, COUNT(*) AS occurrences FROM (SELECT COUNT(*), name FROM [i][color=red]table[/color][/i] GROUP BY name, year) AS tmp GROUP BY name; [/tt][/s] [tt] SELECT name, COUNT(*) AS occurrences FROM (SELECT DISTINCT name, year FROM [i][color=red]table[/color][/i]) AS tmp GROUP BY name; [/tt] [/quote] Thanks heaps, that seems to be working great.  Appreciate the help. ..
  9. I'm trying to get a count of users in a particular table but I only want to count them once for each occurrence of another field in the database, ie name: john year: 1958 field x: etc field y:  etc name: john year: 1958 field x: etc field y: etc .. would only count once for the name "John" .. the output I'm looking for is: name  occurrences John    235 Mary    167 etc To try and make it clearer if John appears in the name column 10 times, 3 of those have the year column yet to 1958, 4 have 1960 and 3 have 1962 then I would want to return: John:  3 but I need to do it for all the names in the one query. I can see how I could use DISTINCT on the year field but how do I manage to get the user count based on it ?  Or is there a better way of doing this ?
  10. Is it possible to retrieve row data using php dynamic variables? For example, [code]$sql = "SELECT * FROM table WHERE row = '$rows'  "; $result = mysql_query($sql, $db); $row=mysql_fetch_array($result); $col1 = $row["col1"]; $col2 = $row["col2"];[/code] works fine but can I use a dynamic variable to retrieve the column data (the columns are named col1, col2. col3 etc) I tried this: [code]${'col'.$cols} = $row["{'col'.$cols}"];[/code] but that doesn't work, can anyone help? Now fixed.  Please disregard.
  11. [quote author=mjdamato link=topic=117158.msg477760#msg477760 date=1165115312] Too easy. Give me something hard: [code]<?php $maxValue = 5; $randomValues = array(); for ($i=1; $i<=$maxValue; $i++) {   $tmp = rand(1, $maxValue);   while ($tmp == $i || in_array($tmp, $randomValues) ) {     $tmp = rand(1, $maxValue);   }   $randomValues[$i] = $tmp; } echo "<pre>"; print_r($randomValues); echo "<pre>"; ?>[/code] [/quote] That's great.  Thanks muchly !
  12. [quote author=mjdamato link=topic=117158.msg477755#msg477755 date=1165114533] Hmm... Do you want random numbers or do you want non-repeating numbers as in your example? And is the range of numbers always the same as the number of items in the array and do the arrays always start at 1 and not 0? [/quote] Non-repeating random numbers The range of numbers is always the same as the number of array elements, ie. 40 array elements would be numbers 1 to 40. The numbers always start at 1 and go up consequetively, ie. 1,2,3,4 etc ..
  13. Can anyone help me with the following coding problem. I need to write a php function that can generate an array of non duplicate random numbers within a given range BUT also not have any particular array element contain its only position, ie.  element 1 of the array can't contain 1, element 2 cant's contain 2 etc. For example, for a 5 element array with random numbers between 1 and 5, the following would be OK: $array[1]: 3 $array[2]: 1 $array[3]: 5 $array[4]: 2 $array[5]: 4 but the following would NOT be OK: $array[1]: 5 $array[2]: 1 $array[3]: 3 $array[4]: 2 $array[5]: 4 Thanks in advance.
  14. [!--quoteo(post=379383:date=Jun 2 2006, 05:12 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 2 2006, 05:12 PM) [snapback]379383[/snapback][/div][div class=\'quotemain\'][!--quotec--] Oh, OK: [code]<?php $str = 'Blah blah blah (1943 version)'; preg_match('/\(([A-Za-z0-9]*) version\)/', $str, $m); $match = $m[0]; echo $match; ?>[/code] [/quote] Thanks for your help. Much appreciated !
  15. [!--quoteo(post=379364:date=Jun 2 2006, 04:18 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 2 2006, 04:18 PM) [snapback]379364[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]<?php $str = '( confusion)'; preg_match('/\( ([A-Za-z0-9]*)sion\)/', $str, $m); $match = $m[1]; echo $match; ?>[/code] Will echo "confu" [/quote] Hi, Thanks for your message. I didn't quite explain myself correctly... what I want to be able to do is extract everything within the brackets .. e.g: Blah blah blah (1943 version) ->> (1943 version) Some more blah (original version) ->> (original version)
  16. Can anyone tell me how I could pattern match the following from a string and extract the matched text as a new string? begins with '( ' then has a number of alphanumeric characters ends with 'sion)' Thanks in advance.
  17. [!--quoteo(post=379297:date=Jun 2 2006, 12:49 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 2 2006, 12:49 PM) [snapback]379297[/snapback][/div][div class=\'quotemain\'][!--quotec--] wouldint be a lot easer to get rid of all brackets use str_repalce. [/quote] No, I need to do it the way I described.
  18. I have a series of song titles stored in an SQL database and want to be able to split one of the fields as follows: before: title: California, Here I Come (1924 version) comment: after: title: California, Here I Come comment: (1924 version) So, what I need to be able to do is check if the title contains " version)" and if so I want to work out where the bracketed information starts and remove it from the song title (discarding the space before it) and place the bracketed information in another field. The bit I'm struggling with is determing where the bracketed information (containing the word 'version') starts because there could be other bracketed info in the song title too, e.g.: California, Here I Come (1924 version) (worn) or California, Here I Come (worn) (1924 version) Any help would be much appreciated.
  19. [!--quoteo(post=374001:date=May 15 2006, 02:24 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 15 2006, 02:24 PM) [snapback]374001[/snapback][/div][div class=\'quotemain\'][!--quotec--] This should work... [code]<?php function return_date($day,$year=2006) {     $stamp = mktime(0,0,0,1,$day,$year);     $date = date("jS F Y",$stamp);     return $date; } echo return_date(134); ?>[/code] [/quote] Works great! Thanks a bunch, really appreciate the help.
  20. I know that you can output the number of the day of the year using date(z) but is there a simple way of outputting the date in a different format by passing the number of the day of the year instead? e.g. by passing the number 134 to a function you get the output 15th May ?
×
×
  • 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.