Jump to content

michaelham

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

michaelham's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. When I use your script I get the same results. My script needs to display in a table, about 10 pictures along with text information that corresponds to each one. If I comment out the header() line in your script I get jumbled junk. If I don't comment it out I get the Internall Server Error 500 because I am trying to modify the header information after things have already been written to the browser. If I move the header() function all the way to the top of my script I get the same jumbled junk but no formatting, table, etc. Just plain jumbled text on a white screen.
  2. I know this is a newb question but I have been trying to figure it out for days and can't figure out whats wrong. I am using this function to resize images . All is get is scrambled crap. I realize it's the raw code for the image but I can't get it to display. I have tried header('Content-Type: image/jpeg'); at the top of my script but it doesn't help. If i just output the image without resizing using standard html it shows up so I know the location is correct. Any ideas? $photo = imagecreatefromjpeg($photoLoc); $resizedImage = resizeImage($photo,200,150); imagejpeg($resizedImage); function resizeImage($image,$new_width,$new_height=0) { $old_width = imagesx($image); $old_height= imagesy($image); if($new_height==0) // if the height is not specified //....calculate the relative height $new_height= $new_width * $old_height / $old_width ; $new_image= imagecreatetruecolor($new_width, $new_height); imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height); return $new_image; }
  3. Thank you, The querys I'm putting together are in the order that they come in the tab file, just not in the same order as the database, which is why I think I have problems with using bulk insert. I will give the prepare and execute a try. Thanks for the tip on die() and trigger_error(). I will let you know how it works out. Thanks again, MH
  4. if(file_exists($file)){ echo "File Exists...Opening $file\n"; $f = fopen("$file","r"); } else { die("There was an error opening file $file"); } $insert = "INSERT INTO $tableName ("; $columns = ""; $values = ""; $count = 1; $params = array(2, 709); $rows_affected = 0; while($array = fgetcsv($f,0,"\t")){ $values = ""; foreach ($array as $value) { if($count == 1) { $columns .= "$value, "; /*if($value == "ListingNumber") { $listingNumberIndex = key($array) - 1; echo $listingNumberIndex; }*/ } else { $value = str_replace(''', '\'\'', $value); $value = str_replace('&', '&', $value); $values .= "'$value', "; } } if($count == 1) { $columns = substr_replace($columns,"",-2); $count = 2; } else { $sql = $insert . $columns . ") VALUES (" . substr_replace($values,"",-2) . ")"; echo "CURRENT MEMRY USAGE = " . memory_get_usage()/1048567 . "\n"; // PRINT CURRENT MEMRY LIMIT: sqlsrv_query( $conn, $sql,$params); } //END ELSE COUNT ==2 } //END WHILE GET NEXT LINE I know I can change the order the fields are in the insert but I would then have to hardcode it to a particular order, which I don't necessarily want to do, because columns can be added and the order can change in the future. The only thing I know about the files contents is that it will always have all of the columns that are fed from the RETS server which should match all of the columns in my database but not necessarily the order. I also don't want to hardcode them because there are about 10 tables that all have 200+ columns. MH
  5. I have built a script that parses a tab delimited file and inserts records into the sql server database one at a time. For each record it calls sqlsrv_query to run the insert statement which consists of an insert of about 200 columns. I am having a problem with memory issues. It appears that the memory that is used on each call of the query function is not freed therefore I run out of memory around record 15000. I am currently set up using the default 128M. I know it is this function because when I comment out the function and just let it produce the insert statements the memory stays fluxuating between .1 and .3 megs. currently my sqlsrv_query function does not return into a variable. I have tried returning it to a variable then unsetting the variable with each iteration but that doesn't work either. If I am not approaching this the best way please let me know. I have tried a bulk insert but cannot seem to get it to work. I think this is because my db columns are ordered 1,2,3,4,5 and the tab delimited file is ordered 3,5,2,4,1. Getting my tab delimited file reordered isn't an option that I have as it is a return pulled from querying a RETS server.
  6. PERFECT Thank you. Works great now.
  7. I am having a problem when trying to execute a php script using the command line interface in windows. The script executes successfully in Internet Explorere but when I run it in CLI I get the following message. "Trying to get property of non object on line 28". Here is the code snippet. The count() function is on line 28. Any ideas? if(file_exists("METADATA-TABLE.xml")) { $xml = simplexml_load_file("C:\greta05\bin\METADATA-TABLE.xml"); echo "<br />File Exists and loaded<br />"; //print_r($xml); //$title = 'Hello'; $p_cnt = count($xml->METADATA->{'METADATA-TABLE'}); echo "<br />There are $p_cnt tables in this metadata.<br />";
  8. I have figure out a way to get ahold of the index I am looking for during the first iteration. Then I can always access the value I need. The script will actually be doing both inserting new record and updating old (by deleting the old record and reinserting with the new/updated record). I have this working but I now have a different issue, but it isn't related to this so I will open a new thread. Please look for it, called PHP CLI Problem. Thanks Thanks everybody for your help
  9. I am getting the file read in with that but it is still indexing each record with 0,1,2,3,4,5 instead of the column names.
  10. I have a tab delimited file that I will be using to update a database. The file has the column names in the first row and the records following. Is there a way I can retrieve the records into an array and access it similar to the way mysql_fetch_array does it. For example My file looks like this LastName<tab>FirstName<tab>PhoneNumber<tab>ZipCode Smith<tab>Bob<tab>5555555<tab>11212 Thomas<tab>James<tab>6562432<tab>11929 I would like to be able to loop through one record at a time and reference the array like this while($row = NEXT RECORD SOME HOW) { echo "<br />Last Name = " . $row['LastName'] . " FirstName = " . $row['FirstName']; } and have it display Last Name = Smith First Name = Bob Last Name = Thomas First Name = James Any ideas? I would like to be able to do this because my actual files each have about 216 columns and that one is for a small table and the primary key is somewhere in the middle but is always called ListingNumber and the location changes depending on which table it refers to.
×
×
  • 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.