Jump to content

guyfromfl

Members
  • Posts

    286
  • Joined

  • Last visited

    Never

Everything posted by guyfromfl

  1. I am trying to send a file name to another php file, but am having trouble coming up with the best way to deal with the period between filename and extension. I have done a little reading on google and came up with 2 1/2 solutions... #1 - Pass the file name only and assume the extension later. This is good but limits what I can do in the future. #2 - Pass the file name and extension as different vars (ie phpfile.php?filename=foo&ext=bar) #3 - Write a function that changes the periods to an acceptable character and then convert it back in phpfile.php. I don't think this is such a great idea since you can have a file name like joe_vs_the_volcano.1988.txt or whatever. I was just wondering if anybody had any ideas and thoughts I am missing... Thanks
  2. deonno020 is kind of correct. I wrote the service department software for one of my jobs and I will only support it if the user is using FireFox. Not exactly the best standard, but not being hired at that job as a programmer I have no choice. I have too many other projects going on to perfect code... (again not the best standard ) I created a CSS with a page dimension declaration set to print media. I will post the css if you want... Unfortunately Chrome prints headers and footers..I like it because you can create an application icon so the users, otherwise, wouldn't know its basically a website.
  3. it was showing "1". It was how I was handling the array data. Thanks
  4. Sorry.... Its Monday.. I was appending the data wrong.. I was using array_push() instead of $dup[]= array $newArray
  5. Need another set of eyes... I am getting: $dup = array(); // Create an array to store the duplicate entries. foreach($fileList as $filename) { if (($handle = fopen(UPLOAD_PATH.$filename, "r")) != FALSE) { // Create the input array while(($data = fgetcsv($handle, 0, ",")) != FALSE) { $sql = "SELECT id FROM leads.prospect WHERE (email='{$data[3]}' OR phone='" . $format->stripPhoneChars($data[2]) . "') LIMIT 1"; $result = $db->query($sql); if (mysql_num_rows($result) == 0) { $sql = "INSERT IGNORE INTO leads.prospect (email, phone, ip, firstName, lastName, resort) VALUES ('" . trim($data[3]) . "', '" . $format->mysqlSafe($data[2]) . "', '" . $format->mysqlSafe($data[5]) . "', '" . $format->mysqlSafe($data[0]) . "', '" . $format->mysqlSafe($data[1]) . "', '" . $format->mysqlSafe($data[4]) . "')"; $result = $db->query($sql); $added++; } else { $dup = array_push($dup, array($data[0], $data[1])); } } fclose($handle); // Close the file } else { echo "<p>Could not load file $filename</p>"; } } echo "$added records added."; // Show me the duplicate data! echo "<h2>This is the data that would be dumped into the duplicate CSV file:</h2> <h3>" . count($dup)." Duplicates:</h3><ol>"; print_r($dup); echo $dup; foreach($dup as $d) { // <-------------------------------------- LINE 83 echo "<li>$d[0] $d[1] $d[2] $d[3]</li>"; } echo "</ol>";
  6. Basically I want something like: $sql = "INSERT IGNORE INTO leads.prospect (email, phone, ip, firstName, lastName) VALUES ('" . trim($data[3]) . "', '" . $format->mysqlSafe($data[2]) . "', '" . $format->mysqlSafe($data[5]) . "', '" . $format->mysqlSafe($data[0]) . "', '" . $format->mysqlSafe($data[1]) . "')"; $result = $db->query($sql); // I want something like this: if ($result) { $added++; } else { // Add to the duplicate array, to be added to the new CSV file later $dup = array_push($data); }
  7. You can readd it: $nfilename = $p_id . "." . $ext;
  8. Try using this function: pathinfo($fileName, PATHINFO_EXTENSION) It will return the extention of the file.
  9. You are trying to access the data wrong. try echo $query2[0]; The mysql_fetch_array returns the data into an array. The first element of the array is 0. Also, query2 should probably be called something like result, to keep it less confusing.
  10. I am trying to write a script that runs through a CSV file and inserts unique values in a mysql database and spits the duplicate out into a new CSV. I can find the duplicates when I load it into an array, but when I insert them into a MySQL database, I cannot determine if they are duplicates. If I use INSERT IGNORE, it will run the whole file, and reject the duplicates. This is fine, except I need to create a file of the duplicate entries. What is the best way to determine if the insert attempt was rejected? I could do a select to see if the row is there, spit it out...insert if not, but I was thinking there should be a way for MySQL to talk back to me to cut the queries in half... Any ideas? Thanks
  11. I changed the directives and everything seems to be working correctly. Im sorry it took so long to mark this solved. Its been a rough few weeks. Thanks for the help!
  12. I am trying to write a dirty script that removes duplicate rows from a multidimensional array. I want to be able to edit the function and spit the duplicates out to a CSV file. Here is my test file: $fullArray = array(array('Jim', 'Jones'), array('Pete', 'Pumpkin'), array('Barak', 'Obama'), array('Jason', 'Newstead'), array('Toby', 'Keith'), array('Jim', 'Jones'), array('Jim', 'Nelson')); echo "<h1>Original</h2>"; for($i=0; $i<count($fullArray); $i++) { echo $fullArray[$i][0] . " " . $fullArray[$i][1] . "<br />"; } echo "<h2>Checked</h2>"; $cleanArray = array(); $cay = array(); $nn=0; $dup=0; // Loop the entire input array foreach ($fullArray as $index => $item) { echo "foreach index:$index<br>"; // Start an internal pointer for ($f=0; $f<count($fullArray); $f++) { echo "for $f "; // if the index is lower or the same as the pointer, skip it to cut down on time if ($f > $index) { // if the rows are the same... if($fullArray[$f][0] == $item[0] && $fullArray[$f][1] == $item[1]) { echo "$item[0] DUP<br>"; // remove it from the array $cay = array_push($cleanArray, array($item[0], $item[1])); array_pop($fullArray[5]); $dup++; } else { // not a duplicate echo " not a dup<br>"; } } else { echo "ON THIS ONE<br>"; } } echo "<br><br>"; } echo"<br>$dup duplicates found<br><br>"; print_r($fullArray); echo "<br /><br>"; // print_r($item); print_r($cleanArray); ?> When I spit out the new fullArray variable, it still has an element from the duplicate record. This is what I get for the output of the full array after the duplicate was removed:
  13. My girlfriends brother was in a serious crash last friday. I made a website to help get donations to fund his recovery. In the next few days the lawyers are going to release a press release and we want this website to be on the news. I registered http://www.helpcody.com Some times it will load, others will bounce you to a fake page you see when you type a url wrong. Anybody have any ideas? I contacted my DNS (no-ip) and he fixed it but it is now unreliable. I am assuming this is a problem on my server. I added a VirtualHost to httpd.conf: <VirtualHost *.helpcody.com> ServerAlias *.helpcody.com ServerName *.helpcody.com DocumentRoot "/var/www/html/cody/" DirectoryIndex index.php </VirtualHost> Please help!
  14. I am trying to return an associative array from a mysql query in JSON to JS with AJAX. so lets say we have this php: // Simplified SQL $result = mysql_query("SELECT id, description FROM table"); // Encode the Associative array from MySQL and return it to ajax echo json_encode(mysql_fetch_assoc($result)); I now want to deal with it in JS: var response = ajax.responseText; // Create the response from the query // Parse the response from JSON var searchResult = eval('(' + response + ')'); // Create a mock dialog var msg = "<div id='multipleResultsDialog'><div style='background-color: #0099FF; padding-left: 10px; font-weight: bold'>Multiple Matches</div>"; msg += "<div style='background-color: #fff; padding: 10px;'>Please select the correct product:<br /><ul>"; msg += "<li><a href='#'>Add</a></li>"; // Go through each of the elements and add them to the list for (i=0; i<searchResult.id.length; i++) { msg += "<li>"+ searchResult.id[i] + " - " + searchResult.description[i]+"</li>"; } msg += "</ul>"; // fill the div document.getElementById('description').innerHTML = msg; All I can get is this: The id from the only returned record is 441 and the description is "Zephyr" The response from the server is: Do I need to append the array from each mysql row in php before returning it to js? I am sure I am searching for something that will return 2+ rows Please help! Thanks
  15. what about it is not working? Do you have Firebug? Does it return errors?
  16. Wow. That looks very good. I knew there had to be a better way to handle the data than just appending a string to a string then splitting it back. I will have to try it. Thanks!!!
  17. I am trying to learn AJax, and like probably most of you doing it alone, through trial & error and google. What I have done is write a script that takes a stock number and references a MySQL database to get the description and returns the db's unique id, description and msrp. My company, in its genius, used the same stock number for multiple items, so say stock number 510 might have 2+ rows returned from the database. I currently create a string in php with the elements of the result appended to each other seperated by #### echo it back, then .split() in js back into an array. I then count the elements and divide by 3 (how many fields in the row)... Is there a better way to return the data or is making a string then splitting it back into an array the best way to do this? I will get to the ajax function in jQuery but I want to know whats going on first... Any suggestions would be most helpful! Thanks
  18. I am inserting last names into the database using mysql_real_escape_string(), and outputting the data into a textbox using addslashes(). When I try to display O'Brian "O\" is displayed in the text box. The name is saved corretly as O'Brian in the database. I am printing the string like this: echo "<input type='text' value='" . addslashes($customer['lName']) . "' blah blah..."; anybody have any ideas?
  19. When I group by DAYOFWEEK() it only returns !NULL results. If There were no results for tuesday, the chart would say MON TUE WED THUR FRI SAT SUN 1 4 2 3 6 3 I guess Im going to have to code a little bit huh...
  20. switch $order and $where in the query. WHERE comes before the order. $get_mail = mysql_query("SELECT * FROM domains $where $order LIMIT 1")
  21. Here are the tables: repairs.ra (Return Authorization for repair) id, customer, etc.. repairs.raitem (each returned item on the ra) id, raID(FK to ra), repairDate, etc. bli.engines (company's product list) id, description (etc)
  22. I am at work and keep getting interupted by less important things, like the real world so please for give me if this isn't the clearest post. I am trying to generate report that looks like this: EngineMonTueWedThuFriTotal Product 1102036 Product 2001124 Repaired1031510 I have the select of each product that was repaired that week right, I just can't figure out how to get the count for each engine per day and in the cell. Here are the two SQL queries: To get the row data: Select engines.Brand, engines.Scale, engines.Description, repairs.raitem.repairDate, COUNT(*) As repairedEngines From repairs.raitem Inner Join engines On repairs.raitem.description = engines.engineId Where Week(repairs.raitem.repairDate) = Week(Current_Date()) Group By bli.engines.Brand, bli.engines.Description and To tally the days (I know I can do this with variables in php, but I am using this until I get the cell data. Select repairs.raitem.repairDate, COUNT(*) as repaired From repairs.raitem Where YEARweek(repairs.raitem.repairDate) = YEARweek(Now()) Group By repairs.raitem.repairDate Order By repairs.raitem.repairDate
  23. I am working on printing reports for an html/php-based app I am working on. There are sets of data contained in li tags that I do not want to be split from page to page. I have tried to add page-break-after with its different options, but it does not work. On the reports that would print on two pages, the test of the report is about half the width of the page. If there is no need for a page break, it prints fine. I am sick of wasting paper on this so ANY guidance would be much appreciated.
  24. Many of you guys have been a huge help to me while making the Service Department software I am making for work, and I just want to say thanks! The next part of the program is not quite as simple as many of the posts that pop on here. ** I'm sorry this post is so long..** A little background: I am writing a program to track warranty repairs for my company. The program tracks what products are coming in, whats been done, and when they were sent back to the customer. (and alot more things that aren't important for this post) Now I am trying to figure out how to determine how long it takes for the product to be returned to the customer after it arrives. I can't take an average of the entire database since we slow down in the summer and dramatically pick up during the winter. Also, there is one permanent repair person, where two or three others come on board at random. Another reason is some Return Authorizations will never be sent to us. (These RA's will be cancelled after 6 months...) Our current system is an Access database that only has customer info, date received and returned. We tally the daily repairs on paper, and if a customer calls for a status we hand count the products in line before him and divide by 25, to get a rough estimate of how long it will take. 3 weeks ago it was 40 products. Does anybody have any suggestions on how to figure a realistic number of weeks to expect from receivedDate to shipDate? The algorithm/logic would need to take into account the trend of the past few weeks, as well as how many RA's are open and how many are already in queue before it. I'm not asking for the code to figure it out (...it would help), but more importantly suggestions of the logic to how it would work. This question might be more appropriate in another forum, maybe php since that is the language I am writing the whole thing in... Again, thanks for all the help in the past, and if you made it this far...thanks for the time.
×
×
  • 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.