Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. most likely you have your DB permits restricted ... (CREATE DATABASE per example). ask to whom host your host DB
  2. Trigger/Function limitation... (I think that I did answer something exactly like this yesterday)... in a trigger/function you can not execute any other SQL sentence that involve the same table used for the trigger/function.... (INSERT,UPDATE, DELETE, TRUNCATE, DROP, etc..etc) but in your triggers (BEFORE UPDATE, BEFORE INSERT) you can assign/calculate your field model_hash value as you want, no need to use another UPDATE clause... per example in a BEFORE UPDATE you can access the OLD and the NEW values of any field look for examples here: http://www.mysqltutorial.org/create-the-first-trigger-in-mysql.aspx
  3. is your DB local or is in a remote server? if is in a remote server: - Are you sure that MYSQl is configured to allow remote connection? (networking enabled) - Or do you know if it is configured to allow access from any IP or specific IP's ? for local: - check if the grants are correct for that user. - and the obvious as ManiacDan pointed out... check the password
  4. just to contribute to the general knowledge of others that could read: PFMaBismAd is right in his answer: mysql_query() ... or more in general, mysql API doesn't support multi-queries, however the mysqli API support them and they can be used without problem, taking obviously the necessary precautions to sanitize and properly chain the sentences. As has been said, multi-queries have some risks and they must be used only in very specific and controlled situations where the risks are non-existent (or highly minimized). @ManiacDan "PHP by default doesn't allow two queries to be processed in the same string" that is incorrect, PHP doesn't play any role in allow or not a multi-query; is mysql API (or mysqli) the responsible for that.
  5. no... is not possible (one of the trigger/functions limitations)... the error is saying you that "Can't update table 'categories' in stored function/trigger because it is already used by statement which invoked this stored function/trigger."
  6. .... (CASE $player_age WHEN 999 THEN uba_players.player_age like '%' AND ELSE uba_players.player_age = $player_age AND END) (CASE '999' WHEN 999 THEN uba_players.player_status like '%' ELSE uba_players.player_age = $player_status END) ORDER BY.... 2 "AND" in the first CASE are wrong... try .... (CASE $player_age WHEN 999 THEN uba_players.player_age like '%' ELSE uba_players.player_age = $player_age END) AND (CASE '999' WHEN 999 THEN uba_players.player_status like '%' ELSE uba_players.player_age = $player_status END) ORDER BY....
  7. maybe you should rephrase that back-ticks are not part of SQL... they are offered in MYSQL to help users to deal with the incorrect usage of MYSQL reserved words, for that case, in MYSQL you can use them if you don't have the option of rename your fields to something different that is not a MYSQL reserved word. The usage of backtick could make your code no portable if in the future you decide to use a different DB Engine and it doesn't support them.
  8. ok... not sure if this is going to solve your issue 100% but you could give it a try... using the table that you currently have it is supposed to count in a giving month only the vacations days relative to that month or the overlaps SELECT user_id,workername datestart, dateend, CASE WHEN dateend > $from THEN SUM(amountofdays) - datediff(dateend,$from) WHEN datestart < $to AND dateend BETWEEN $to AND $from THEN SUM(amountofdays) + datediff($from,dateend) ELSE SUM(amountofdays) END AS monthvacdays FROM test1 WHERE datestart BETWEEN $from AND $to OR dateend BETWEEN $from AND $to GROUP BY user_id; give it a try... and if it doesn't solve what you want... maybe it could give you ideas
  9. how that could be possible if in your select you are filtering using the datestart field?.. meaning if you run your select in November the example record will show because the datestart is in November... if you run the same query in December that record is not going to be shown because datestart is NOT in december... I don't follow... could you explain?
  10. my line : "quickly written ... no tested.... but you can test it" was in reference to my code not yours too much of a hassle... an easy alternative is use an array... per example: $names = array( 'minis' => 'Mini\'s', 'rakwi' => 'Rawki\'s', 'tito' => 'Tito\'s', 'ketis' => 'Keti\'s' ); and then use the array in this line: echo "<font color='$color'><span style='font-size:large;'><br />".$names[$row['groep']]."</span><br /><table>"; Humm... maybe you have some semantic confusion here.. (if I understood correctly your goal)... you mean that you need a new field called "order" in your table leaden... then yes... but don't call that field "order" (order is a reserved mysql word) yes yes... considering that you need to assign the same order number to an specific group.
  11. I really don't want to sound harsh... but for your own good... and for your clients... you have to consider seriously take some formal classes or read some books about database design... trust me... you need it... and after or along with that.. SQL (mysql flavor if is that what you are using) The table's design that you shown in your post is terrible This... doesn't give you an alternate idea about how to improve your design? what about replace all those tables for something simpler like this: Same with you "tables" for the quote.... they are screaming for a re-design Really I can't think on how are you coding all your application... and how it is working... sorry... you asked for opinion/guidance and I know what you are reading is hard... but true. I understand that make changes now in your code could be a huge task and probably re-do a lot of code is not an option at this point... but for your own sake please try to learn a lot more.
  12. quickly written ... no tested.... but you can test it ... the color change is for you to figure out how.... HINT: a possible solution ... use an array echo'<div class="inhoud">'; mysql_select_db($dbname)or die(mysql_error()); $query = "SELECT * FROM leden WHERE type='leiding' ORDER BY groep, voornaam ASC"; $oldgroep = ""; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { // Here we validate if the groep changed if ($row['groep'] != $oldgroep) { if ( $oldgroep != "") { // Close Table... except first time echo'</table></font>'; } // Print the Groep header everytime that it is different echo '<font color="purple"><span style="font-size:large;"><br />'.$row['groep'].'</span><br /><table>'; $oldgroep = $row['groep']; } // Print the table rows echo '<tr valign="middle"><td height="20px" width="30px"> </td><td width="200px">' . $row['voornaam'] . ' ' . $row['achternaam'] . '</td><td>' . $row['telefoonnummer'] . '</td><td>' . $row['email'] . '</td></tr>'; } // Close Table only if it was created if ($oldgroep != "") { echo'</table></font>'; } echo '</div>';
  13. Humm... I just read your post again.... the solution that I gave below doesn't solve your objective completely... I misread your post.... Gizmola VIEW approach solve it.
  14. or calculate the "age" in the SELECT directly and order by seriesId, calculated_age ASC (if I did understand correctly your objective) as in : SELECT a.seriesId AS serienmr b.id AS episode, DATEDIFF(curdate(), b.created) AS age FROM series AS s JOIN episode ON a.seriesId = b.seriesId ORDER by seriesnmr, age ASC
  15. without see the code that is populating the array (and ideally the row's data) is really difficult to give you an answer
  16. just a friendly suggestion... You should read Forum Rule # 17 and Forum DO NOT http://www.phpfreaks.com/page/rules-and-terms-of-service#toc_forum_do_nots
  17. They are called "Named Parameters".... they are used in prepared statements . Depending of which extension are you using... PDO , Mysql, Mysqli, etc. they can be accepted or not... In mysqli the "?" is the equivalent and it is used like this: SELECT SlotID FROM ( SELECT SlotID AS SlotRank, SlotID FROM UserSeats WHERE slot > ? UNION SELECT SlotID + 8 AS SlotRank, SlotID FROM UserSeats WHERE slot <= ? ) ORDER BY SlotRank Search for "Mysql Prepared Statements" to learn more.
  18. maybe you missed this in my previous post other hint..... or almost the code .... SUM(IF(status='Failed',1,0)) AS failed, SUM(IF(status='Success',1,0)) AS success, ...
  19. how the function "knows" about $date_filter ?
  20. for you to play with and have a goal just 1 SELECT and 1 WHILE should do what you have posted ... hint: you can control IN the WHILE IF the group changed, and proceed accordingly
  21. first... - you should put this 2 lines (look bottom in my signature) at the beginning of your code to control/display your errors (if you don't have it) next: - where are you executing your "$query"?... your code seems incomplete - which warning?.... and last... according to what you described as a goal you can obtain your results with just one query... why are you using 3?... hint: look for the usage of IF clause in your SQL query (CASE also will work)
  22. it should work in that case SELECT a.*, GROUP_CONCAT(b.subject) FROM employees AS a LEFT JOIN trainings AS b ON a.id = b.id WHERE a.department = 'Oncology' GROUP BY a.id;
  23. replace LEFT JOIN with JOIN
  24. Alter the table (rename current field, add new field) and then use UPDATE to get the right fields values using substring functions http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substr
  25. try: SELECT a.*, GROUP_CONCAT(b.subject) FROM employees AS a LEFT JOIN trainings AS b ON a.id = b.id AND a.department = 'Oncology' GROUP BY a.id;
×
×
  • 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.