Jump to content

kristinac

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Everything posted by kristinac

  1. thanks. i've had to hard-code it for the time being to keep the project on time but i will try that out once we're live and i have a spare moment.
  2. i have this awesome script i've used on multiple websites and only now is it giving me trouble. it's always aligned/cropped to the middle of the image but for some reason the smaller thumbnails are cropping to the bottom. <?php header ("Content-type: image/jpeg"); $file_name=$_GET['f']; $crop_height=$_GET['h']; $crop_width=$_GET['w']; $file_type= explode('.', $file_name); $file_type = $file_type[count($file_type) -1]; $file_type=strtolower($file_type); $original_image_size = getimagesize($file_name); $original_width = $original_image_size[0]; $original_height = $original_image_size[0]; if($file_type=='jpg') { $original_image_gd = imagecreatefromjpeg($file_name); } if($file_type=='gif') { $original_image_gd = imagecreatefromgif($file_name); } if($file_type=='png') { $original_image_gd = imagecreatefrompng($file_name); } $cropped_image_gd = imagecreatetruecolor($crop_width, $crop_height); $wm = $original_width /$crop_width; $hm = $original_height /$crop_height; $h_height = $crop_height/2; $w_height = $crop_width/2; if($original_width > $original_height ) { $adjusted_width =$original_width / $hm; $half_width = $adjusted_width / 2; $int_width = $half_width - $w_height; imagecopyresampled($cropped_image_gd ,$original_image_gd ,-$int_width,0,0,0, $adjusted_width, $crop_height, $original_width , $original_height ); } elseif(($original_width < $original_height ) || ($original_width == $original_height )) { $adjusted_height = $original_height / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; imagecopyresampled($cropped_image_gd , $original_image_gd ,0,-$int_height,0,0, $crop_width, $adjusted_height, $original_width , $original_height ); } else { imagecopyresampled($cropped_image_gd , $original_image_gd ,0,0,0,0, $crop_width, $crop_height, $original_width , $original_height ); } imagejpeg($cropped_image_gd); ?> if i modify the value of original_image_size, it crops to the middle, but if the height is greater than the width it will add black on either side of the image to fill out the designated value. $original_image_size = getimagesize($file_name); $original_width = $original_image_size[0]; $original_height = $original_image_size[1]; i can't figure out how to get it do both. 0, 0 outputs this: http://www.loudtechinc.com/images/scriptissue/00.png http://www.loudtechinc.com/images/scriptissue/00n2.png 0, 1 outputs this: http://www.loudtechinc.com/images/scriptissue/01.png http://www.loudtechinc.com/images/scriptissue/01n2.png The end goal is to have it fill the desired height and width while cropping to the middle.
  3. the column names are listed: FirstName, LastName, Year, and would be in row one
  4. I am a web designer/PHP hack trying to solve a problem for our HR department. We have a quarterly newsletter in a Wordpress site I developed and they want to have a dynamically updated service anniversary page updated through excel. The solution to this problem is clearly fgetcsv, but I'm having trouble understanding how to implement it within the wordpress page. Here is a really nice function from the php manual page <?php function csv_file_to_mysql_table($source_file, $target_table, $max_line_length=10000) { if (($handle = fopen("$source_file", "r")) !== FALSE) { $columns = fgetcsv($handle, $max_line_length, ","); foreach ($columns as &$column) { $column = str_replace(".","",$column); } $insert_query_prefix = "INSERT INTO $target_table (".join(",",$columns).")\nVALUES"; while (($data = fgetcsv($handle, $max_line_length, ",")) !== FALSE) { while (count($data)<count($columns)) array_push($data, NULL); $query = "$insert_query_prefix (".join(",",quote_all_array($data)).");"; mysql_query($query); } fclose($handle); } } function quote_all_array($values) { foreach ($values as $key=>$value) if (is_array($value)) $values[$key] = quote_all_array($value); else $values[$key] = quote_all($value); return $values; } function quote_all($value) { if (is_null($value)) return "NULL"; $value = "'" . mysql_real_escape_string($value) . "'"; return $value; } ?> But this leaves me with a few questions: 1. is this both function AND query? or do i need extra code to run the function and spit out the results? 2. where do i input my actual values? 3. does this have to mirror a mysql table somewhere else? i feel like i'm missing a crucial piece of info here. the path to the csv file needs to be absolute, due to HR needing to manage the file themselves without the help of yours truly. the intended output will look like this: 5 YEARS FirstName1 LastName1, FirstName2 LastName2, FirstName3 LastName3, etc 6 YEARS FirstName1 LastName1, FirstName2 LastName2, FirstName3 LastName3, etc and so on. so in addition to the FirstName, LastName and Year columns, the loop will need to include a conditional statement. something like: <h1>5 YEAR</h1> <ul> <?php if (quote_all_array(5) ) : ?> echo "<li>(FirstName, LastName), </li>"; <?php endif; ?> </ul> <h1>6 YEAR</h1> <ul> <?php if (quote_all_array(6) ) : ?> echo "<li>(FirstName, LastName), </li>"; <?php endif; ?> </ul> I'm sure my syntax is horribly wrong because I have virtually no idea what I'm doing. Which is why I'm asking you all for help to help my understanding i'll supply a set of variables: CSV Source: http://resource.mysite.com/anny.csv Table Columns: FirstName, LastName, Year External MySql database (should it apply): AnnySql Thanks in advance for any help. I'm over my pay grade on this one.
  5. it's set to varchar 25. the longer entries (modelnumber-##.jpg) are coming through just fine, so i really don't think lenghth is an issue. it will let me go through and /manually/ change the emtpy feilds to NULL, then it will work like it's supposed to. however, each time i update the table by importing (and over-writing) the sheet i have to go through an manually update all the rows again. it's really frustrating. i have the default value set to NULL, so what gives? is there a setting somewhere that i'm just not configuring correctly?
  6. 0 rows affected. i've also thought about the whitespace factor, but checking those individual cell in phpmyadmin confirms that they are indeed empty. i don't get it. isn't there a way to set the table to automatically change empty cells to "NULL"?
  7. okay, my table's name is rollover and the column name is ImageTH_06. when i do this: UPDATE rollover SET ImageTh_06 = NULL WHERE ImageTh_06 = '' it only does one of out of 203 line items.
  8. nothing. it just leaves the cell blank. this is for a rollover widget. some rollovers have 16 images but most only have 15 so the client-side script is set up to display a placeholder image if #16=null. so my table is *supposed* to add NULL into all empty cells on my CSV import. but it isn't putting anything in there, so when i view the html pages, if there is only 15 images, the 16th place shows up as a broken image
  9. i am very new to MySql and this problem is driving me crazy. i'm importing a CSV file into my table (with a setting of "null" default value=null). when i import the table, it doesn't automatically put "NULL" in the empty cells, so each time i import an updated spreadsheet i have to go back and manually check "null" on every line item. a very tedious task indeed. i tried toggling the null/not null settings in the table, but it doesn't seem to make any difference. what am i doing wrong?
  10. i seem to have gotten it to work by exporting as CSV Windows and setting the import fields like this: Fields terminated by , Fields enclosed by " Fields escaped by \ Lines terminated by auto Column names [blank] i think the mac CSV export didn't match up. even though when i open the CSV file in TextEdit it doesn't show the " enclosing cell data. they must be hidden characters that TextEdit won't display. wow, that was frustrating and a colossal waste of time! i hope this helps someone else out there.
  11. i already posted two sample lines in the original post. i'll add a carrige return here on the same two lines and add a third for good measure since it's a little long and convoluted: ItemID,Name,Replaced_by,Replacement_for,Intro,Thumbnail,Photo,Active,style,top,back,sides,tuner,finish,electronics,series,s_hole,binding,f_board,f_inlay,bridge,bracing,shell,resonator,tone_ring,hardware,neck,Headbinding,HeadOverlay,Pickguard,Width,Scale,XLPhoto,StyleID,SeriesID,pegs,Type,leftAvail,binID,revID,p_fullname 115,4280 Minstrel Banjo,,,NULL,4280_small.gif,4280.gif,0,Banjo,NULL,NULL,,Planetary,NULL,None,Alvarez Traditional Series,NULL,NULL,Rosewood,NULL,NULL,NULL,Multi-ply Maple,Mahogany,Plated Brass,Chrome,NULL,NULL,NULL,NULL,NULL,NULL,NULL,5,,,,,901,0, 114,4294 Silver Belle Banjo,,,NULL,4294_small.gif,4294.gif,0,Banjo,NULL,NULL,,Planetary,NULL,None,Alvarez Traditional Series,NULL,NULL,Rosewood,NULL,NULL,NULL,Multi-ply Maple,Mahogany,Plated Brass,Chrome,NULL,NULL,NULL,NULL,NULL,NULL,,5,,,,,901,0,
  12. the system response is the same, yes, but it's not an error. it gives a little green check icon saying the import is complete, but it's only imported one line out of 254.
  13. i tried exporting from excel in CSV Windows, CSV Mac & CSV, each time trying all three of the line deliminators. nothing works. what the hell?
  14. i have a csv file i am trying to import into my 'item' table, which works as long as i import one line at a time. at 250+ lines, this will be a real hassle. here's what i'm doing: 1. save excel doc as csv 2. in phpmyadmin, click the appropriate table 3. select "import" 4. browse for my file "item.csv" 5. click radio button "CSV using LOAD DATA" 6. click "Replace table data with file" 7. change feilds to read as follows: Fields terminated by , Fields enclosed by [blank] Fields escaped by [blank] Lines terminated by auto Column names [blank] 8. leave "us local keyword" checked 9. click "go" then it imports, but it only does the first line of my spreadsheet. it outputs this confirmation message: Import has been successfully finished, 1 queries executed. LOAD DATA LOCAL INFILE '/private/var/tmp/phpU3elSj' REPLACE INTO TABLE `item` FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'# 1 row(s) affected. i have opened my csv file in TextEdit to make sure the deliminators are correct. here is a sample (first two lines) ItemID,Name,Replaced_by,Replacement_for,Intro,Thumbnail,Photo,Active,style,top,back,sides,tuner,finish,electronics,series,s_hole,binding,f_board,f_inlay,bridge,bracing,shell,resonator,tone_ring,hardware,neck,Headbinding,HeadOverlay,Pickguard,Width,Scale,XLPhoto,StyleID,SeriesID,pegs,Type,leftAvail,binID,revID,p_fullname 115,4280 Minstrel Banjo,,,NULL,4280_small.gif,4280.gif,0,Banjo,NULL,NULL,,Planetary,NULL,None,Alvarez Traditional Series,NULL,NULL,Rosewood,NULL,NULL,NULL,Multi-ply Maple,Mahogany,Plated Brass,Chrome,NULL,NULL,NULL,NULL,NULL,NULL,NULL,5,,,,,901,0, these are the things i have tried: 1. removing the header line in my csv file 2. auto_inc the ItemID field (with nothing entered in the csv's ItemID column) 3. disabling auto_inc and manually entering the csv's ItemID field 4. using CSV import instead of CSV LOAD DATA 5. manually entering a glyph as the line break character and specifying it in the "Lines terminated by" field 6. unchecking "local keyword" 7. removing all "NULL" instances from the exported "item" table i don't know what else to do. i'm beating my head against the wall and google hasn't been much help. thanks in advance, k
  15. okay, so apparently just restarting apache (like all the tutorial websites say to do) isn't enough. i just rebooted my machine and it works. man, newbie mistake. my mom: "it doesn't work!" me: "is it plugged in?" mom: "oh, there it goes!" yeah... i can't make fun of her anymore :-\
  16. i'm a web designer who happens to know some code. html? check. css? double check? js? sure... but a developer i never claimed to be. now i'm stuck with a site built in php & mysql and i need to be able to keep it maintained & updated, so i'm trying to get my machine set up with php & mysql, but i'm stuck in php installation/activation. here's where i'm at: i've been following these instructions: http://www.devarticles.com/c/a/Apache/Using-Apache-and-PHP-on-Mac-OS-X/ apache is enabled and i went into terminal as instructed and edited my httpd.conf file to read as follows: LoadModule php4_module libexec/httpd/libphp4.so AddModule mod_php4.c AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps i made a php file named info.php with the following script and placed it in /library/webserver/documents/: <?php phpinfo(); ?> but all browsers interpret the file as text, not a web page, so i see the code typed out plain as day, nor does my machine /anywhere/ read the current php site i am supposed to be managing. it will read the html, but not the php. what am i doing wrong? i have also tried putting these files in the user site folders (http://localhost/~myname/info.php) it is worth mentioning that we are running admitmac network at the office here. i dont expect this to be of any interruption, as apache will run html pages locally just fine from my root library webserver folder.
×
×
  • 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.