Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. is nothing syntactically wrong with that sentence... is incomplete (no error control) but no wrong, could cause problems depending on your objectives.. yes... but that is a different topic. the first thing you have to do is fix your data inconsistency (or adjust your select to deal with it) and secondly stick with one version of your code.. otherwise is difficult for anybody try to help you. look for the suggestions that has been offered by Pica and other posts and you will be fine ... fenway suggestion to use REGEXP instead of LIKE is good too. this code is the best one that you can continue working on : $query = ("SELECT COUNT(`word`) FROM `hallofryslan_rhymewords` WHERE `word` ='".$rymwurd."'"); if( $telresult = mysql_query($query) ) { $telrow = mysql_fetch_array($telresult); $telwurd = $telrow[COUNT(word)]; // YOU MUST FIX THIS LINE... COUNT(word) <> COUNT(`word`)... you can also use an alias instead echo "<P>Aanwezig: ".$telwurd."</P>"; } else { echo "<br>Query $query<br>Produced error: " . mysql_error() . '<br>'; }
  2. then you are not reading nor thinking in the solutions/suggestions offered to you, that indeed will solve your problem if you take the time to test and adjust them... trim or use LIKE with a variable is 101 coding. We can't see your data, but we already told you what you have wrong in your code (and I offer also a guessing for your wrong data)... the rest is on you.
  3. the simplest way SELECT Institution_name, COUNT(InsNo) FROM <your_table_here> GROUP BY Institution_name HAVING COUNT(InsNo) > 1
  4. if those 2 results are different then obviously your field `word` contains something different to 'Adam'... most likely a leading space or hidden character. You can try to trim blank spaces or use LIKE ... as in WHERE word LIKE '%Adam%' adding to what Picachu already told you... you are no controlling errors .. and yes echo helps to debug your code.... add this lines at the beginning of your php file (after <?php) // Define how to display/report errors ini_set("display_errors", "1"); error_reporting(E_ALL); it should reveal that you have also an error in your code.... specifically in this line $telwurd = $telrow[COUNT(word)];
  5. I believe that you don't need 2 tables (owners & alt_contact)... the user rol should be an attribute of the relationship table (let call it Job_users) job_users job_id user_id user_rol (it can be a ENUM with the defined roles.. O=owner, A=Alternate, etc..etc) in your current solution if you need in the future add more user's roles you will need to modify you table jobs to add other column.. j.m.h.o
  6. the design for your table jobs is calling for a redesign .... you should have a third table with the relationship between jobs and users
  7. here is another thread that answer more or less exactly what you are asking for http://www.phpfreaks.com/forums/index.php/topic,348646.0.html in short... the "magic" idea is just bad design... you should use another table to store the user's interest
  8. you don't need the second SELECT... you just need LAST_INSERT_ID()
  9. you just need to modify the 2 SELECTS that you have in your van_roof_rack.php file to exclude the new category (MB) here $sqlSelect = "SELECT DISTINCT Car_Make FROM products WHERE Car_Make <> 'all' and Car_Make <> 'link' and Default_Code <> 'LE' and Car_Make <> 'n/a'"; and here $sqlSelectModel = "SELECT DISTINCT Car_Model FROM products WHERE Car_Make = '".$strMake."' and Default_Code <> 'LE'"; try replacing Default_Code <> 'LE' with Default_Code NOT IN ( 'LE', 'MB')
  10. other than incorrect number of values in the INSERT, also you are using `backticks` for VALUES which is no correct.
  11. you are trying to order by the string ('weekdate') instead of the column weekdate and no reason to store the `day` in your table... day can be determined from your weekdate column http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_dayname
  12. here is a couple links that could help you: http://www.sitepoint.com/hierarchical-data-database/ and this presentation is a must... http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back slides 48 to 77 show you alternatives... pay attention to the "Closure Table" implementation... the implementation should allow you to solve your query easily (and many more)
  13. post your table(s) description(s)
  14. ... hopefully your table is not named "table" as you posted http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
  15. this presentation posted by fenway in the "The MYSQL sticky" long time ago is a must to be read... around slide 48 and up apply to your case. http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back
  16. use an aggregate function http://dev.mysql.com/doc/refman/5.6/en/group-by-functions.html
  17. this should help you to understand better... http://www.deeptraining.com/litwin/dbdesign/FundamentalsOfRelationalDatabaseDesign.aspx scroll down and read about Normalization... specially about First Normal Form (1NF) and repeating groups
  18. scroll down in this article (better if your read it completely) and look for "Third Normal Form" http://www.deeptraining.com/litwin/dbdesign/FundamentalsOfRelationalDatabaseDesign.aspx what you asked can be done... yes... should be done: no (bad design)... all the calculated values should be obtained in execution time, no stored in the DB
  19. therefore, this is incorrect... you must check both dates individually. WHERE DATE(check_in) AND DATE(last_night) BETWEEN '$first' AND '$last' seems to me that you can do all of that with just one query (no UNION)... use OR to mix group of conditions... try this sql... (no tested): SELECT * FROM Bookings WHERE (DATE(check_in) BETWEEN '$first' AND '$last' AND DATE(last_night) BETWEEN '$first' AND '$last') OR (MONTH(check_in) = '$month' AND YEAR(check_in) = '$year' AND DATE(last_night) > '$last') OR (MONTH(last_night) = '$month' AND YEAR(last_night) = '$year' AND DATE(check_in) < '$first') OR (DATE(check_in) < '$first' AND DATE(last_night) > '$last') AND username = '$username' AND deleted = '0000-00-00 00:00:00'
  20. you can improve your code : - eliminating that foreach completely - replacing in your $query the usage of $sql for: .....AND deleted = '0000-00-00 00:00:00' AND room IN (<here implode your array>) - and here WHERE DATE(check_in) AND DATE(last_night) BETWEEN '$first' AND '$last' what exactly are you trying to do?... I'm guessing that is not what you want... - if you still want to use the foreach and that $sql you will need to enclose that with parentheses ... AND (room = n OR room = m ... etc ) Pika beat me on this... my 3rd point still valid
  21. your SP has syntax errors, hence is not been created... errors marked here in red SET @query = CONCAT('SELECT IF(', field, operator, value, ', 1, 0) INTO @broken FROM newlocations WHERE id = ', lID, ' LIMIT 1'); PREPARE stmt FROM @query; EXECURE stmt; // should be EXECUTE instead of EXECURE DEALLOCATE stmt; // should be DEALLOCATE PREPARE stmt IF ( @broken = 0 ) THEN rules_broken = FALSE; // missing SET Note: I didn't review your code at all.. only syntax check
  22. does it ring a bell? http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat
  23. mysql api doesn't support muti-query sentences.... use mysqli api or execute separates sentences
  24. just looking for open discussion, experience of those evaluating or already doing this... like an open topic...
  25. Just wondering if some of you guys/gals have any experience using XML/XSL to write/publish technical manuals (or books)... looking to share and learn from your experience/tips/constraints ... what do you guys/gals know/think about this?
×
×
  • 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.