Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. NO... that is no what I want to say... he is using the wrong field to establish the relationship.... sub_problem_type must point to the field type_id of the table SubProblemTypes and not to the field type_name , otherwise if in the future he decide to change the value of that field (name) all the relationship could be broken unless an UPDATE CASCADE is in place (that could be highly inefficient depending on the record volume in the table WizardChoices) ... using the type_name field is not the logical way to establish the relationship. Same apply to the field primary_problem_type .
  2. yes... sorry I wasn't clear.... the value for the field must exist before it could be referenced in other table, but as I said... that is only part of your problem
  3. the error means that you are trying to insert a record in the table Wizarchoices and the field "type_name" doesn't exists in the table SubProblemTypes... but looking your tables descriptions clearly you are using the FK's incorrectly... in reality in your table WizardChoices the FK "sub_problem_type" should point to the field "type_id" of your table SubProblemTypes and match the size of the field too ... same mistake for the table PrimaryProblemTypes.. referencing the wrong field... mysql> describe WizardChoices; +-----------------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------------+-------------+------+-----+---------+----------------+ | choice_id | int(3) | NO | PRI | NULL | auto_increment | | assoc_question_number | varchar(3) | NO | MUL | NULL | | | choice_text | text | NO | | NULL | | | primary_problem_type | INT(3) | NO | MUL | NULL | | ///// FK to PrimaryProblemTypes table field "type_id" (guessing field name) .. ON DELETE constraints should be "NO ACTION" | sub_problem_type | INT(3) | YES | MUL | NULL | | ///// FK to SubProblemTypes table field "type_id" +-----------------------+-------------+------+-----+---------+----------------+
  4. and could cause a big mess with your database (if you are not careful) , breaking all the referential integrity of your database model (if any) creating most likely many orphan records. I will say that is no good reason to re-number your auto-increment PK's at all.
  5. All the dependant subqueries can be replaced with an addtional JOIN and using IN for the attribute_id, however why are you joining the table establishment_attribute with the table accomodations when seems that the right relationship is with the table establishment using the establishment_id field, moreover when you are joining the table establishments with accomodations using the field establishments.child_id
  6. I didnt notice that you are using mysql_fetch_row before.... you have 2 options : a) mantain the query as you have originally and replace $ row['PartID'] for $ row [0] Or b) replace mysql_fetch_row for mysql_fech_assoc and mantain the query using the alias of my previous post
  7. That is not enough code to tell, but could be that either your $_POST array is empty or you dont have a database connection open befor to use mysql_real_escape
  8. $sql = "SELECT MAX(PartID) AS PartID FROM `fullstocklist`"; Should take care of your issue
  9. and don't forget to add the '.jpg' extension (or whichever one that you want)
  10. not even.... could be done?... probably but unlikely will be correct/efficient/good practice ... should be done in that way?... NO you already had a good starting point from Jessica... read on "database normalization", here http://en.wikipedia.org/wiki/Database_normalization is a simple way to start... if you don't understand it... just came again and ask... many will be offering help then.... for now probably the majority will just ignore the post or will be telling you the same over and over. Also a clear explanation of your final objectives and details of your tables design will help to understand better what you are trying to achieve, allowing to the members to give you a better advise. Here is another resource provided for a forum member (Christian) that could be interesting for you to watch http://forums.phpfreaks.com/topic/273634-best-way-to-set-up-tables-when-multiple-values/?do=findComment&comment=1408360
  11. in the first snippet your bind_param() sentence is incomplete... read: http://php.net/manual/en/mysqli-stmt.bind-param.php in the second one you have a wrong sql sentence....you have an extra , here VALUES (?,?,)
  12. use aliases to differentiate columns with the same name in each table... like : cs.city AS cscity or whatever alias that you like the most....
  13. if you declared in your table that movie_id is an auto-increment column then your INSERT (below) is wrong $insert = "INSERT INTO movie(movie_id, movie_name, movie_type, " . "movie_year, movie_leadactor, movie_director) " . "VALUES(1, 'Bruce Almighty', 5, 2003, 1, 2), " . "(2, 'Office Space', 5, 1999, 5, 6), " . "(3, 'Grand Canyon', 2, 1991, 4, 3)"; it shouldn't contain references to the movie_id column or values for it. and if you are getting the duplicate row error, means that you are executing the same code more than once.
  14. what is not clear in the error message that you are getting?.... if it is not self evident... read the "Description" here: http://php.net/manual/en/function.mysql-query.php P.S: (not related to the error that you are getting) You should use the mysqli API or PDO instead of mysql API.. it has been soft deprecated already.
  15. Why do you have 5 products tables? post the EXPLAIN plan for your query
  16. Well... seems that you are answering your own question... <?php echo $desc; ?> is not the same as echo $row[$desc]. '<br>'; (at least that you are doing $desc = $row[$desc] in some place in your code)
  17. Stop using the keyboard and read carefully what trq posted for you.. what you did is not even close. As he recomend you forget about the foreign key constraint and focus in the data y relationships that you want to implement firts... in a side note, foreing key in MyIsam engine are not enforced at all.. so...
  18. Take the i. and u. Out of every $ row [] $row ['i.title'] must be $row['title'] same for the rest
  19. Kichen's answer is pointing you in the right direction, with that most likely your $ query_a seems to dont be needed; also will be interesting to see what the 2 last functions get_angler_handle() and get_species () are used for..if those are only getting the angler name and the specie name then they could be not needed with kichen's solution... same as the variable $speciesname what it is used for?
  20. The column "date" is present in both tables by chance?
  21. In reality you dont need $parm_book_id nor $ parm_book_title. .. you can use $ book_id and $ book_title directly in your bind sentence. Also you cannot mix mysqli and mysql sentences..
  22. A common mistake... in you if = is an assigment operator not a comparison operator
  23. If the tables are not related you need to use UNION
  24. Sorry about that... it is your date/datetime/timestamp table field... I see that Psycho & Barand already straight the issue for you.
  25. As Psycho said... more information could help to give you a more precise answer, however reading your post seems to me that you are looking something like this? (modify it according to your needs) select location_id, location_type, COUNT(location_id)AS TotViews, SUM(IF(DATE_FORMAT(fecha,'%Y%m') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH),'%Y%m'),1,0)) As ViewsLastMonth, SUM(IF(DATE_FORMAT(fecha,'%Y%m') = DATE_FORMAT(NOW(),'%Y%m'),1,0)) As TrendThisMonth FROM views GROUP BY location_id,location_type;
×
×
  • 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.