Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. that is a classical mistake... SP ALWAYS return at least one recordset (Execution STATUS) and if you don't manage it correctly you could find "curious" errors.... the most common is the "Commands out of sync; you can't run this command now" , in some cases also some "Lost connection" error could happen.
  2. you first code doesn't show how you were managing the results of your SP. (most probably there is the cause) when you solved with mysqli_multi_query are you using also mysqli_next_result?
  3. I said: (even when the term is not exactly correct.. it is accepted) but... maybe I didn't understand your question... if so.. clarify your question further this is a other good source for you to learn concepts/terminology if you want to read it http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch01.pdf on it the chapter about SETS, TABLES, RELATIONS and Databases should give you better answers.
  4. the explanation for the error code is very simple.. http://dev.mysql.com/doc/refman/5.0/en/from-clause-subqueries.html however,,, is hard to understand what are you are trying to do using a sub-query when in reality that could be solved with ONE and simple query... just put the 2 WHERE together in one query string and "complexity" is gone
  5. the short answer... very..very simplified... everyone is called just "table" ... but topic is more complex than that, therefore the question hasn't a short answer ... literally we can write a book ... but is a lot out there already (Data Modeling, Database Modeling, Database Design, etc.) here are some articles (from 1000's out there) that could give you guidance if you want to learn http://www.agiledata.org/essays/dataModeling101.html#IdentifyDataEntities http://www.sqlteam.com/article/database-design-and-modeling-fundamentals this is a good paper too that cover a lot of concepts http://www.eecs.umich.edu/~teorey/lec.notes.pdf
  6. maybe I'm going to ask the obvious but.... - did you ask about your problem in the PHP-Fusion Forum? - did you read the PHP-Fusion Manual starting in pages 40 and up? prefix seems to be optional or anything. replace across multiples files should no be a problem (almost a piece of cake if well controlled) using a good editor... and if everything fail.... then.... TRIGGER http://dev.mysql.com/doc/refman/5.0/en/triggers.html
  7. post the structures of your tables A,B y C
  8. possible?... sure it is.... but correct... sure is not. any reason why you want to do that?
  9. In my first reply to you I wrote: - Post Tables structure and Index definitions... complement with number of rows in each table ... no information provided... now.... based on that and your mention of tables (A, B, C) make me suspicious about if your data modeling is correct or not.... for a better answer post your tables structure and explain a little what you are doing....
  10. how much is the difference between do things in the right way (or best way possible) or in the no so right way?... there are some thing that are simply "good practices" because in the long term are going to create good programming habits on you and for sure sooner or later are going to save you some grief. At the end of the day is your choice what to do... but if you came here looking for help and answers I imagine that you are looking also to learn "best practices" right?
  11. ... lets see... second while loop is totally unnecessary and wrong... what you need to do is something like this (one alternative) .. short and incomplete example just to show you the basic: $category_old = ""; while($row = mysql_fetch_array($result)) { if ($row['category] != $category_old) { // print the category in the way that you want here... echo for now echo $row['category']; $category_old = $row['category']; { echo here the rest of your data }
  12. if your table2.domain field hold the relationship with table1 (means table1.id = table2.domain) then your first select is the way to do it.. also you can write that in this way per example: SELECT table1.*, table2.id FROM table1 JOIN table2 ON table1.id = table2.domain AND table2.user = 1 you can also use a LEFT JOIN depending of your data and expected results
  13. In my answer #1... I said by the end of that post: ... so.... start fishing
  14. you can call it "alias" too if you want... ... but technically speaking, table name, alias, and others objects names are known as identifiers http://dev.mysql.com/doc/refman/5.5/en/identifiers.html
  15. Good.... please be sure to mark the post as "Solved" yourself... thanks
  16. is this your actual query?: $query1 = "SELECT datum FROM planning WHERE id = '.$id.' AND YEAR(datum) = '$huidig_jaar' AND MONTH(datum) = '01' ORDER BY id ASC"; because if it is you have an error there that could be causing the behavior... check the difference and try this: $query1 = "SELECT datum FROM planning WHERE id = $id AND YEAR(datum) = '$huidig_jaar' AND MONTH(datum) = '01' ORDER BY id ASC";
  17. and in top of everything else $sql="SELECT * FROM $tbl_name WHERE username=md5('$myusername') and password=md5('$mypassword')and beta= '1'"; the SQL is incorrect... missing a space before the last "and"
  18. "seems" doesn't help much to the people here that is trying to help you. - what exactly are you getting? - which is the complete code that you are using?
  19. some examples here... read and you should be able to answer yourself http://net.tutsplus.com/tutorials/databases/sql-for-beginners-part-3-database-relationships/
  20. this is an example for your tables (adjust the datatye/size as needed): CREATE TABLE `categories` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Category` varchar(45) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB; CREATE TABLE `movies` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Title` varchar(45) NOT NULL, `Category` int(10) unsigned NOT NULL, `URL` varchar(45) NOT NULL, PRIMARY KEY (`ID`), CONSTRAINT `FK_movies_1` FOREIGN KEY (`ID`) REFERENCES `categories` (`ID`) ON DELETE CASCADE ) ENGINE=InnoDB; in your intent you defined the FK in the wrong table.
  21. Use : ORDER BY (CASE....) DESC read here: http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html ask again if you can't figure it out
  22. You must use the data type that provide your model with the necessary room to fulfill the requirements of your business... take a look to the available data types an choose the best one in the previous terms and storage http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html ... I'll probably choose a SMALLINT in your case. Correct. When you have operations over tables that have columns with the same name you must avoid ambiguities , therefore you must qualify the columns either using the table name or using alias as a prefix as I did in the example
  23. mikosiko

    sum

    news should JOIN news_comments using news_id most likely..... otherwise post your tables description
  24. $word should be defined like: $word = ' tim '; to prevent wrong result if the string is something like: $subject = "I want everything in time before tim and nothing after"; right? other option: $subject = "I want everything in time before tim and nothing after"; $word = ' tim '; $arr = explode($word, $string); echo $arr[0]; // if $word need to be ommited too or echo $arr[0] . $word; // to include it
  25. Maybe? $string = "This is- the str - ing for- test-ing and -doing stuff -SECONDPART"; // Test string echo "<br />String 1 :" . substr($string,0,strrpos($string, '-')); echo "<br />String 2 :" . substr($string,strrpos($string, '-')+1); scratch this... I didn't see Pika reply #2
×
×
  • 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.