Jump to content

artacus

Members
  • Posts

    737
  • Joined

  • Last visited

    Never

Everything posted by artacus

  1. If you were connecting as a valid user your error message would have read: 'myValidUser'@'localhost'
  2. Sure it is. Just use different variables to store mysql_query() and mysql_fetch_array() values.
  3. It doesn't look like you've defined a username to connect to mysql. Go back and look at your connection string.
  4. I'm assuming that you want to add a new row for each reading. What you want is an auto-increment field for id. http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
  5. My coworker built a non-normalized database and now I'm trying to do reports w/o having to do a ton of queries. The main table I'll be using is category_map. Its a normalized table that gives me the level, category & sub-category. Now I've got about 5 non-normalized tables that are related. So I added a `field_name` field to category_map table. I store the table_name.field_name that each category is mapped to. So a row in my category_map might look like this: cat_id description category level field_name --------- ----------------------------- -------------- -------- ------------------------------------------------------ 40 Secretary Classified JH tbl_class_allocations_jh.secretary 16 Office/Attendance Assistant Classified EL tbl_class_allocations_el.office_attendance_assistant So my question is, "Is there any way to treat that field_name like you would a "variable variable" in PHP. So when the query runs I could get back the value stored in tbl_class_allocations_jh.secretary and not the string "tbl_class_allocations_jh.secretary"???
  6. It doesn't work because you are sorting by a string and not a number. You can do: SELECT CAST(substring_index(VTitle,'',-1) AS UNSIGNED) AS ID FROM videos ORDER BY ID DESC or even: SELECT ROUND(substring_index(VTitle,'',-1)) AS ID FROM videos ORDER BY ID DESC
  7. Always a good idea to echo out your query when its not performing like you think it should. Then paste it into phpmyadmin or something and see what it does. I'm going to go out on a limb here and guess that your database is not normalized. I can't think of a case where you'd have a query like that on a normalized database. I'd recommend reading a tutorial or two on normalization/ db design before you go too much further. Another problem is that you are going to search through 5 fields in every row of your table. So to get any kind of performance, you will have to index all 5 fields. If you still insist on going this route, this query will work: SELECT * FROM locations WHERE '$code' IN (id1, id2, id3, id4, id5)
  8. Well what you'd typically do is have php convert it into an actual time then store it as a data or datetime in mysql. If you really really have to store the strings, use two fields, one for the date and the other for the string.
  9. I don't think you'll be able to do that cleanly in mysql. You should have pretty good luck with php's strtotime()
  10. Well I've worked as a network engineer, sys admin, dba and developer. My personal experience is that I strongly prefer developing. I'm a very creative sort, so I thrive on coming up with solutions to impossible problems... plus I have a deep aversion to boredom. The net and sys admins largely involve fixing or maintaining stuff, so at the end of the day you don't really have that joy of looking back and admiring what you've accomplished... many days your accomplishments are "well its not any more broken that it was yesterday." The MS sys admins know what I'm talking about. LOL. And no one says, "Wow, that was a stroke of genius how you imaged that machine." The DBA is a mix between the two. It can be exciting when you are laying out new databases, writing ETL scripts, writing new queries, or creating a warehouse. But after that, when it gets to the monitoring stage, no thanks. The great thing about being a developer is that if you play your cards right, it can be a source of residual income. So after you develop a name for yourself, you can go to a client and say "look, you really can't afford me. But I'm going to do the project anyhow. I'm going to keep the rights to the code and you get (a percent of my sales, free support, free updates, whatever)" That's something you cant do with the other IT jobs.
  11. Yeah by framework, I mean the infrastructure required to make your own package and a channel to distribute it.
  12. LOL. Awesome thread. 1) The best gifts are totally impractical, useless and otherwise the last thing that would occur to you to give. 2) No matter how much you make, she can spend it faster than you earn it. 3) Chocolate has some mystical power 4) The toilet seat always returns to the down position 5) For some reason, pre-teen and teenage girls will sign their names with some boy's last name over and over again. Not sure what that one is all about.
  13. So you're going to school? I'm not the one asking for help. Trust me mysql has problems when using your syntax. Especially with table aliases. I wasn't sure that was what the problem was in your situation. WITH ROLLUP does work with joined tables, that's not the problem.
  14. I've never done it, but I know you can use the PEAR framework to do this.
  15. No, you are using a bastardization of a join. Mostly mysql lets you get away with it, but quirky things happen. Correct syntax would be: SELECT cp.name, SUM(qty) AS quantity FROM course_selections AS cs JOIN course_options AS co ON cs.course_id = co.course_id JOIN client_partnerships AS cps ON cs.client_id = cps.client_id JOIN client_partners cp ON cps.client_partner_id = cp.id AND cps.`primary` = 1 WHERE co.provider_id = 6 AND cs.client_id > 1 GROUP BY cp.name WITH ROLLUP;
  16. Try doing with JOIN statements instead.
  17. If EventDescription is always the same within an EventName group use: SELECT EventName, EventDescription, MAX(EventDate) AS EventDate FROM EventTable GROUP BY EventName If not use: SELECT FROM EventTable AS et JOIN ( SELECT EventName, MAX(EventDate) AS maxDate FROM EventTable GROUP BY EventName ) AS sub ON et.eventName = sub.EventName AND et.EventDate = sub.maxDate
  18. Don't save it as a varchar, save it as an INT or DECIMAL. Add the $ and comma in php.
  19. Really need to do your print_r for the second line where you're dealing with the data and not the headers. And save your query as a variable first. <?php $sql = "INSERT INTO example_table..."; $result = mysql_query($sql) or die(mysql_error() . "/n<pre>$sql");
  20. DELETE FROM myTab WHERE dtFld < CURDATE()
  21. and change mysql_query($query) or die(mysql_error() . "<pre>\n$query"); So you can see what your sql looks like
  22. Did you do a print_r($data) like I said?
  23. Using 1 table w/ a type field would have been a better design. SELECT 'offer' AS type, memberNo, timestamp, categoryNo, itemTitle, itemDesc FROM offers UNION SELECT 'request' AS type, memberNo, timestamp, categoryNo, itemTitle, itemDesc FROM requests
  24. It means your csv file is not being parsed correctly. I downloaded your source data and your line should look like this: <?php $data = fgetcsv($feed, 3000, ',', '"') Use that and do a print_r($data) to be sure its working correctly.
  25. Not really... as long as its normalized.
×
×
  • 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.