Jump to content

pmg206

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pmg206's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks to you both -- that was it. Figured it was how I was plugging it on (or rather, Dreamweaver suggested it be used, good grief). Thanks again!
  2. The setup is pretty generic, but this one is kicking my butt. Using a PHP page (Yahoo hosting, which is still on MySQL 4.1.14), the goal is to provide users a dropdown list of values that are limited to only what the page user, per their login credentials, should see. (The project is sort of like a soccer league page, but we only want the coach to see members of his/her team in a dropdown list, even though all league players are in the single table.) I figured this would be a no-brainer, based on the login ID and passing the login username/cookie into the query, but I figured wrong. (In this way, the page would then only show them the values that were associated with their team, and pop them into a dropdown list.) But how the cookie needs to be formatted is where I crumble, as it were... The ideal sort of query, which sort of puts the web page into blank-ness, is similar to: $query_team_list = "SELECT * FROM tbl_players WHERE status = 'A' and team_id = <?php echo $HTTP_COOKIE_VARS['cookie4team']; ?> ORDER BY fname ASC"; The team ID is pulled from the cookie created at login, i.e. 101 (always an integer, not the most elegant approach, but that's another issue). If we go with this code, stuff comes back (obviously), but it's retrieving everyone. Not stellar to scroll through dozens of names to find your folks: $query_team_list = "SELECT * FROM tbl_players WHERE status = 'A' and team_id > 1 ORDER BY fname ASC"; Which suggests either I can't do this -- seems unlikely -- or my the means/format of inserting the cookie into the query itself is a no-no. Thoughts? Thanks in advance!
  3. I'm trying to write around a unique qualifier on a PHP 4.0.x web page login screen. Currently, each of a few logins direct folks to a specific page unique to them. Worked fine until the company started to grow, and the intent is to allow roles of folks (users, managers, admins) to all view the same single page, but maintaining their individual logins (so sharing a login to accomplish landing on the same page isn't an option). The thought was to change the != Joe in the existing code (below) to something like a != (Joe,Tom,Jack), but the correct operator for a "not in list" has been elusive in the PHP documentation (can't imagine why searching for "in" operator brings back hundreds of responses, y'know, since "in" is such an uncommon term). We did try setting up groups (1, 2, 3, etc.) in the access table, but it seems the login tool keys off of the username as the access control piece. So the question is if (a) such a thing is practical to do a not-in-list sort of thing, or if not (b) if there's a different login tool out there one can suggest, and I'll push The Power That Be that change is for the better. Thanks! // Determine user page view if(!isset($HTTP_COOKIE_VARS['our_yummy_cookie'])){ header("Location: login_or_leave.php"); } else { if($HTTP_COOKIE_VARS['our_yummy_cookie'] != Tony){ header("Location: dashboard2.php"); } }
  4. Basically, table 1 has a catalog of events (like parades), and table 2 is a list of vehicles. In the events table, there is a varchar(10) field of lettes, a-h, or any combination thereof, indicating which vehicle(s) participated in the event. (Such that a parade may be one vehicle, "a" for example, or may be several, like "abd, etc.) The goal is to produce a list of total events participated, by each vehicle. (A simple join works fine for one truck per event, but the multiple vehicles at one event, given the varchar(10) in 'events' joined to char(1) of 'vehicles'. In data examples, we may have: eventID veh_letters 1 a 2 abc 3 bd 4 d (total of 4 events, 4 unique vehicles, with 7 vehicle-counts. And the goal is to have a query that would kick out the result to look like vehicle total a 2 b 2 c 1 d 2 The simply JOIN results in the two events with a single vehicle (events 1 and 4, so results would look like [vehicle a = 1, d = 1], but 2 and 3 have two or more vehicles, so it skips those rows. The xfer table contains all valid combinations of events.veh_letter and the PK to the vehicle table, so 'xfer' table looks like, extending the example: veh_group veh_id abc a abc b abc c bd b bd d The second query will bring back the count of the multiple vehicle events, so the results come back as [vehicle a = 1, b = 2, c = 1, d = 1]. Thus, if you manually add the two results sets together, we're back at the a = 2, b = 2, c = 1, d = 2. The question, then, is how -- or even if -- the result sets of the two could be merged into a single query result set similar to that done if one manually counted and grouped them on paper.
  5. The missing step is how to (correctly or best) bridge between table 1 (events) and table 2 (apparatus) via the newly created table that should be bringing the two together. If I run each query and add the results, it correctly totals the figures (had Excel check the results via a export file). The question is if there is a means to merge the two queries into one, or if something from one query could simply be added to the other to accomplish the single result set with the total of both query's results.
  6. Thanks -- that got me moving by leaps in the right direction. I created a xfer cross-reference table with only events.veh_group and apparatus.truck_id to join them up, and now have the results that were missing before -- but also am now missing the results I had before (thus in theory, two queries give me the complete picture). Is there a convenient way to marry the two? The original query for single-resource events (just using a basic JOIN between events and apparatus tables): SELECT count( `veh_group` ) AS total, truck_desc FROM EVENTS JOIN apparatus ON events.veh_group = apparatus.truck_id GROUP BY truck_desc And the new query using the xfer and apparatus table: SELECT count( xref.truck_id ) AS total, apparatus.truck_desc FROM xref, apparatus WHERE (apparatus.truck_id = xref.truck_id) GROUP BY truck_desc It feels like I could -- or in theory should -- be able to simply include it in the new query's WHERE clause, but that's not showing me the love. Missing a step along the way, perhaps? Thanks!
  7. I suspect the root cause is poor design (which I'm not opposed to altering if need be), or the end result is inherently a dumb idea. The database tracks party events in an 'events' table, and which resources are assigned to that event (stored in the 'apparatus' table). The lazy guy solution when that association was added was to give each apparatus a letter ID (primary key), and the 'events' table has a text field ('veh_group') of all lettered apparatus used for th event. Works great to pull back which apparatus did what, but the query used there is a contains/like versus an =. So the requirement now is to do reporting of frequency of apparatus, but using the COUNT command, it is successful only on those events with just one apparatus. The SQL used here is: SELECT count(`veh_group`) as total,truck_desc FROM events join apparatus on events.veh_group = apparatus.truck_id GROUP BY truck_desc I figure the limitation on the JOIN is a distinct relationship only exists when a single apparatus works the event (so the a = a, g = g), however, when two or more are present, it breaks, since you can't join on a list of letters back to a single letter (i.e. "aefg" in 'events.veh_group' trying to join to the 'apparatus.truck_id' Figuring the break here is the string trying to be joined back to a single ID, is there a relatively painless way to side-step this land-mine? Thanks! ~ Paul
  8. So, it's happy again, as tables go.  After all the silliness and check and repair commands, I took another backup with the Yahoo! tools, compared the sizes of the MYD and MYI files to confirm they were (a) there, and (b) bigger than the last known good backup, and they were.  Figuring why not, I restored that database backup over the "in use" table (and others, of course), and it's happy again. Thanks for the feedback as I sorted this one out (with your suggestions, of course!).  :)
  9. I certainly hope so (not a team or shared environment, but when the internet connection bounced, who knows how the server side at Yahoo! took the command). The database's other tables are available and accessible.  This table is showing in the myPhpAdmin screen as present, but instead of the count of rows in the table and all the icons available, the row count shows "in use" and roughly half of the icons (browse, search, empty) are grayed out.  Of those visible for use (insert, structure, delete), insert and structure both return a "#1105 - File './films/titles.MYD' not found (Errcode: 13)" error, and I don't plan on hitting the delete... yet. Grrr... but perhaps that Plan B with the oldish backup is going to become the path of lesser resistance in the greater scheme of things...
  10. Presuming I've done this correctly (grabbing the details from theMySQL 3.23, 4.0, 4.1 online reference), this is the query and result: SQL query  SQL query:  CHECK TABLE titles FAST  RESULTS (underscores added to align header and result row data): ----------------------------------------------------------------------------------- Table_______ Op_____  Msg_type____ Msg_text  films.titles___ check___ error________ File './films/titles.MYD' not found (Errcode: 13) ----------------------------------------------------------------------------------- Running a CHECK TABLE titles EXTENDED had a similar result, as did REPAIR TABLE...
  11. So, I'm parked on Yahoo! web hosting and using their MySQL offering (MySQL 4.1.14, PHP 4.3.11, admin tools phpMyAdmin 2.6.3-pl1).  Database is up, running, and groovy, with six tables.  After removing a default value in one field of the main data table, my internet conncetion did something curious, I landed with a 'Page Cannot be Displayed', and the table is now showing "in use" within phpMyAdmin, and a rash of goofyness from the PHP pages. Using myPhpAdmin, if I attempt to access the Structure tab, I end up with the error below (obviously, "films" is the database and "titles" is the table): --------------------------------------------------------------- File './films/titles.MYD' not found (Errcode: 13) Error SQL query: SHOW KEYS FROM `titles` ; MySQL said:  #1105 - File './films/titles.MYD' not found (Errcode: 13) --------------------------------------------------------------- Most of the PHP pages that would otherwise be accessible are now showing this message: --------------------------------------------------------------- File './films/titles.MYD' not found (Errcode: 13) --------------------------------------------------------------- My RTFM on Google mostly posted to a permissions issue, though not too much feedback as to HOW to address it.  I did try to use the Repair Database utility from Yahoo! (myisamchk is what they'll run on my behalf), to no avail. I have a valid backup (10 days old), so reloading and recreating 10 days' work is possible, though my Plan B.  Looking for a whiz bang Plan A, ideally, of course, or any suggestions for a Plan A and a Half.  I do have access to command-line SQL within myPhpAdmin, though no server access, since it's a Yahoo! thing.  Thanks!
  12. (whew)... well, at least I'm not losing my marbles in the process. :) What it does, presently, is... ... yeah, now its working. And I pinky promise I've done nothing between this moment and the last hour when it no workie. Thanks for your validation, Andy, that I wasn't losing it. And like so many public leaders, I won't question success, merely take credit for it (however misplaced it is in this case). Thanks again!
  13. I have this inkling this a no-brainer, but my culling through this forum, Google and two Dummies books hasn't brought me to a solution, so I thought I'd give a shout out. Using Dreamweaver and my Yahoo! MySQL 4.1.14 hosted database, I'm trying to display a record with the page's title taken from database values. The values are inserted into the table fine, located within the body of the page. My strong suspicion is the problem is the <title> tag sits in the head area, thus it's confused. Or, I'm confused. Thinking {Picture => 1000 words}, the code is below. But the notion is the desired result would be <title>Star Wars (1977)</title> with variables inserted, taken from <title><? $title ?> (<? $year ?></title>. [code]<?php require_once('Connections/spoil.php'); ?> <?php $colname_spoiler_page = "-1"; if (isset($_GET['id'])) {   $colname_spoiler_page = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']); } if (isset($_GET['id'])) {   $colname_duckscore = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']); } mysql_select_db($database_spoil, $spoil); $query_spoiler_page = sprintf("SELECT * FROM titles WHERE id = %s ORDER BY id ASC", $colname_spoiler_page); $spoiler_page = mysql_query($query_spoiler_page, $spoil) or die(mysql_error()); $row_spoiler_page = mysql_fetch_assoc($spoiler_page); $totalRows_spoiler_page = mysql_num_rows($spoiler_page); mysql_select_db($database_spoil, $spoil); $query_duckscore = sprintf("SELECT * FROM titles right join ducks on titles.ducksid = ducks.id where titles.id = %s", $colname_duckscore); $duckscore = mysql_query($query_duckscore, $spoil) or die(mysql_error()); $row_duckscore = mysql_fetch_assoc($duckscore); $totalRows_duckscore = mysql_num_rows($duckscore); ?> <head> <title>Frank's Spoiled Movie Endings | <?php echo $row_spoiler_page['title']; ?> (<?php echo $row_spoiler_page['year']; ?>)</title> ... other code ... </head> <body> ... code here...           <td width="500"<strong>Title</strong></td>           <td width="60"><strong>Year</strong></td>           <td width="60"><strong>Length</strong>(Minutes)</td>           <td width="50"><strong><MPAA Rating</strong></td>           <td width="110"><strong>My Rating</strong></td>         </tr>         <tr valign="top">           <td width="500"><strong><?php echo $row_spoiler_page['title']; ?></strong></td>           <td width="60"<?php echo $row_spoiler_page['year']; ?></td>           <td width="60"<?php echo $row_spoiler_page['min']; ?></td>           <td width="50"<?php echo $row_spoiler_page['rating']; ?></td>           <td><img src="<?php echo $row_duckscore['url']; ?>" alt="<?php echo $row_duckscore['alt']; ?>" /></td>         </tr> ... more code there... [/code]
  14. Perfect -- it worked like a charm... thank you both! Good feedback on the validation, too. This is a HUGE learning curve for me between letting Dreamweaver write some of the ASP and just validating it versus trying to do more hand-coding with php.net, this site and a Dummies book as my guides (the latter being a little too focused on their task list to help with the specific stuff). This particular form is just for me to track something personally, so I didn't get hung up on the validation -- yet -- but for the future project meant for the public, validation is a big 10-4. Thanks again!
×
×
  • 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.