Jump to content

RyanMinor

Members
  • Posts

    117
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

RyanMinor's Achievements

Member

Member (2/5)

0

Reputation

  1. This is my database query SELECT event.*, GROUP_CONCAT(photo_thumbnail) as thumbnails FROM event LEFT JOIN photo ON event_id = photo_event WHERE event_user = ? GROUP BY event.event_id; So I am left with an array in which one of the keys is a comma separated list of thumbnails. I am doing it like this because I am using the live jQuery thumbnail script.
  2. I have a comma separated list of thumbnails coming from my database for each album. I need to add the path to the beginning of each element like so $event['thumbnails'] = thumb.jpg, thumb2.jpg, thumb3.jpg, thumb4.jpg I need to make it so the list above looks like http://site.com/medi...humbs/thumb.jpg, http://site.com/medi...umbs/thumb2.jpg, http://site.com/medi...umbs/thumb3.jpg, http://site.com/medi...umbs/thumb4.jpg How would I go about doing that and ensure that it stays as a comma separated list instead of turning it into an array? Thanks!
  3. Hello, I am trying to output a grid of 3 columns (even if there is only 2 rows returned from the database) similar to a data table, but with divs instead. The data is coming from the database. Below is my current code (which is not working): <?php $end_row = 0; $columns = 3; $loop = 0; foreach ($events as $event) { if ($end_row == 0 && $loop++ != 0) { ?> <div class="left13 section_home"> <?php } ?> <h2><?php echo $event['event_title']; ?></h2> <a href="#"><img src="<?php echo ($event['photo_thumbnail'] != '') ? base_url() . 'media/photos/thumbnail/' . $event['photo_thumbnail'] : base_url() . 'images/no_photo_thumbnail.png'; ?>" alt="" title="" /></a> <p><?php echo ($event['event_description'] != '') ? substr($event['event_description'], 0, strpos($event['event_description'], ' ', 200)) : 'No description yet...'; ?></p> <a href="#" class="section_more"><span class="swirl_left"><span class="swirl_right">View This Event</span></span></a> <?php $end_row++; if($end_row >= $columns) { ?> </div> <?php $end_row = 0; } } if ($end_row != 0) { while ($end_row < $columns) { ?> <div class="left13 section_home"> </div> <?php $end_row++; } ?> <?php } ?> Here is how it should look. How can I adjust my current code to get this? <div class="left13 section_home"> <h2>Wedding <span>Location</span></h2> <a href="#"><img src="images/image_13.jpg" alt="" title="" /></a> <p>Ut enim ad minima veniam, quis nostru <strong>exercitationem</strong> ullam corporis laboriosam, nisi ut aliquid ex ea commodi <strong><a href="#">consequatur</a></strong> </p> <a href="#" class="section_more"><span class="swirl_left"><span class="swirl_right">read more</span></span></a> </div> <div class="left13 section_home"> <h2>Honeymoon <span>Destination</span></h2> <a href="#"><img src="images/image_13_2.jpg" alt="" title="" /></a> <p>Ut enim ad minima veniam, quis nostru <strong>exercitationem</strong> ullam corporis laboriosam, nisi ut aliquid ex ea commodi <strong><a href="#">consequatur</a></strong> </p> <a href="#" class="section_more"><span class="swirl_left"><span class="swirl_right">read more</span></span></a> </div> <div class="left13 section_home"> <h2>Girft <span>Registry</span></h2> <a href="#"><img src="images/image_13_3.jpg" alt="" title="" /></a> <p>Ut enim ad minima veniam, quis nostru <strong>exercitationem</strong> ullam corporis laboriosam, nisi ut aliquid ex ea commodi <strong><a href="#">consequatur</a></strong> </p> <a href="#" class="section_more"><span class="swirl_left"><span class="swirl_right">read more</span></span></a> </div>
  4. I added another line above the first one in the CSV and it worked fine. I hate to have to add a blank line thought everytime I do an upload or if someone else does an upload. Is there any way around this?
  5. I am having a strange issue with running a LOAD DATA INFILE query from a PHP script. Here is my PHP code: $query = $db->prepare("LOAD DATA INFILE ? INTO TABLE csv_data FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' (game_week, home_team, home_score, visitor_team, visitor_score)"); if (!$query->execute(array($location))) { $errors[] = 'CSV upload query failed.'; } else { The first five lines of the csv file are as follows: 1,Abington,24,Fels,8 1,Abington Heights,28,Pittston Area,0 1,Academy Park,29,Marple Newton,20 1,Aliquippa,36,Ambridge,0 1,Allegany MD,56,Southern Garrett MD,6 When I run this query everything gets uploaded perfect except that the first value in the database table for game_week is 0 instead of 1. So the first row looks like this: game_week | home_team | home_score | visitor_team | visitor_score 0 | Abington | 24 | Fels | 8 Why is that first value 0 instead of 1. I really don't understand why this is happening. Any help is greatly appreciated. Also, here is my table structure and I am using XAMPP on Windows 7 if that matters at all: CREATE TABLE csv_data ( game_id int(4) NOT NULL AUTO_INCREMENT, game_date date NOT NULL, game_week tinyint(2) NOT NULL, home_team varchar(250) NOT NULL, home_score tinyint(3) NOT NULL, visitor_team varchar(250) NOT NULL, visitor_score tinyint(3) NOT NULL, PRIMARY KEY (game_id) ) ENGINE=MyISAM AUTO_INCREMENT=675 DEFAULT CHARSET=latin1
  6. I have built a PHP/MySQL CSV uploader/updater to update scores for high school football teams. When I ran this script on XAMPP with Windows 7 I got a permissions error for the "LOAD DATA INFILE" query. I checked my permissions within PHPMyAdmin and the user had all permissions so that isn't it. I need to fix that issue first. I ended up getting everything uploaded by running the query directly on PHPMyAdmin. However, when I try to run the two upload queries my script timed out. The process I am going for here is to upload the file and import the records into a new table (csv_data). Then I want to run the two update queries to update the game table with the new data in the csv_data table. The reason for the two queries is because sometimes the wrong team is in the wrong column as far as home/visitor goes. I find that using CONCAT() is really slowing things down. So I need to first fix my permissions issue with the "LOAD DATA INFILE" query and then figure out a way to speed up my update queries. Any ideas? <?php require_once('global.php'); if (array_key_exists('submit', $_POST)) { if ($_FILES['csv']['error'] > 0){ echo "Error: " . $_FILES['csv']['error'] . "</br>" . "You have not selected a file or there is another error."; } else { $tmp = $_FILES['csv']['tmp_name']; } if (!$_FILES['csv']['type'] == 'text/csv'){ echo "Please select a CSV File"; } else { $location = dirname(__FILE__) . '/csv/' . basename($_FILES['csv']['name']); move_uploaded_file($tmp, $location); } $errors = array(); // Need to get this query to work properly regarding permissions $query = $db->prepare("LOAD DATA INFILE ? INTO TABLE csv_data FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (game_week, home_team, home_score, visitor_team, visitor_score)"); if ($query->execute(array($location))) { try { // Need to figure out how to use LIKE instead of = and do it quickly $query_two = $db->prepare("UPDATE game g, csv_data c, team home_team, team visit_team SET g.game_home_score = c.home_score, g.game_visitor_score = c.visitor_score, g.game_complete = 'Y' WHERE g.game_week = c.game_week AND home_team.team_name LIKE CONCAT('%', c.home_team, '%') AND home_team.team_id LIKE CONCAT('%', g.game_home_team, '%') AND visit_team.team_name LIKE CONCAT('%', c.visitor_team, '%') AND visit_team.team_id LIKE CONCAT('%', g.game_visitor_team, '%')"); if (!$query_two->execute()) { $errors[] = 'The first update query failed.'; } $query_three = $db->prepare("UPDATE game g, csv_data c, team home_team, team visit_team SET g.game_home_score = c.visitor_score, g.game_visitor_score = c.home_score, g.game_complete = 'Y' WHERE g.game_week = c.game_week AND home_team.team_name LIKE CONCAT('%', c.visitor_team, '%') AND home_team.team_id LIKE CONCAT('%', g.game_home_team, '%') AND visit_team.team_name LIKE CONCAT('%', c.home_team, '%') AND visit_team.team_id LIKE CONCAT('%', g.game_visitor_team, '%')"); if (!$query_three->execute()) { $errors[] = 'The second update query failed.'; } } catch(PDOException $e) { echo $e->getMessage(); } } else { $errors[] = 'CSV Upload Query Failed.'; } } ?>
  7. Thanks for the reply. I will mess around with this and see what I can come up with.
  8. I am trying to create an automatic score updater for a football database. My client will be emailing me CSV spreadsheets with the game date, home team, home score, visiting team, and visiting score in them. The problem is that I have a separate team table (team_id, team_name, etc.) and game table as outlined below: team (team_id, team_name, etc.) game(game_id, game_home_team, game_home_score, game_visitor_team, game_visitor_score, game_date, game_complete) sample game data(1, 123, 0, 156, 0, 8-31-2012, No) -> I store the team's id instead of their name in the game table. I need to write a script that will update the scores automatically. There will be about 327 scores per week. The CSV will look like the following (with column headings): game_date, home_team, home_score, visitor_team, visitor_score (2012-8-31, Forest Hills, 44, Westmont Hilltop, 0) -> sample data How would I first get the team id's, then match them home and visitor id's with their team names, then get the game id that corresponds to the matching team_id's, then update the scores for that game? That's a lot and I am kind of lost on the issue. Any help or even a better way to do this would be greatly appreciated. Below is what i have so far: UPDATE game SET game_home_score = ?, game_visitor_score = ?, game_complete = 'Yes' WHERE game_id = SELECT game_id FROM game WHERE game_home_team IN ( SELECT team_id FROM team WHERE team_name = ? ) AND game_visitor_team IN ( SELECT team_id FROM team WHERE team_name = ? ); I know that query is wrong, but it's what I was thinking as far as the direction I need to go. My MySQL knowledge isn't quite vast enough (I don't think) to get this working.
  9. How would I go about converting time (could be in hours:minutes:seconds, minutes:seconds, or just seconds format) into the number of seconds? I have a function that will take in hours:minutes:seconds values but when I supply only minutes:seconds or just seconds, it fails. function convertTimeToSeconds($time) { // Check the duration input of time if (!preg_match("/^\d+(:\d{1,2})?(:\d{1,2})?$/", $time)) { throw new exception('Invalid input format for duration.'); } // Retrieve hours, minutes, and seconds $hours = substr($time, 0, -6); $minutes = substr($time, -5, 2); $seconds = substr($time, -2); $total_seconds = ($hours * 3600) + ($minutes * 60) + $seconds; // Ensure that the result is an integer if (!is_int($total_seconds)) { throw new Exception('Output format is not integer.'); } else { return $total_seconds; } }
  10. I am trying to retrieve schedules for each team based on my table below, but I am having some trouble getting the team names to display. Here are my tables my table: TEAM team_id team_name team_mascot etc. GAME game_id game_date game_home_team game_visitor_team game_home_score game_visitor_score game_complete Here is my current query. I am able to get the team's id values with this but I need the team names as id values won't do me much good. SELECT game_home_team, game_visitor_team, game_date FROM game INNER JOIN team home ON home.team_id = game_home_team INNER JOIN team visitor ON visitor.team_id = game_visitor_team WHERE game_home_team = ? OR game_visitor_team = 6 ORDER BY game_date ASC; How can I retrieve the team names with this query and also display a result such as W or L depending on the score for the game? Thanks so much in advance.
  11. Problem solved. It turns out my path was incorrect. I created a file in the root of my site with the following code in it. <?php echo __FILE__; ?> It gave me the full path and once I changed it, everything worked.
  12. Also, here is my Apache Error Log: [Tue May 01 16:48:35 2012] [error] [client 123.125.71.20] File does not exist: /var/chroot/home/content/p/i/n/pinkydinks/html/robots.txt [Tue May 01 19:59:04 2012] [error] [client 95.108.150.235] File does not exist: /var/chroot/home/content/p/i/n/pinkydinks/html/robots.txt [Tue May 01 19:59:04 2012] [error] [client 95.108.150.235] File does not exist: /var/chroot/home/content/p/i/n/pinkydinks/html/robots.txt [Wed May 02 09:44:06 2012] [error] [client 66.249.71.239] File does not exist: /var/chroot/home/content/p/i/n/pinkydinks/html/robots.txt [Wed May 02 11:54:09 2012] [error] [client 173.8.17.253] (2)No such file or directory: Could not open password file: /home/content/p/i/n/html/digrepro/.htpasswd [Wed May 02 11:54:09 2012] [error] [client 173.8.17.253] (2)No such file or directory: Could not open password file: /home/content/p/i/n/html/digrepro/.htpasswd [Wed May 02 11:57:11 2012] [error] [client 173.8.17.253] (2)No such file or directory: Could not open password file: /home/content/p/i/n/html/.htpasswd
  13. I still get the following after trying to log in after putting "AuthBasicProvider file" in my .htaccess file: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Apache Server at digrepro.com Port 80 Also, I moved the .htpasswd file one level up (out of the site root) and it still gave me the error. Why does .htaccess have to be such a pain?
×
×
  • 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.