Jump to content

radi8

Members
  • Posts

    168
  • Joined

  • Last visited

    Never

Everything posted by radi8

  1. radi8

    AJAX tut

    Thanks for the tips. II will keep that in mind the next time I am doing any type of research.
  2. This is a job for Javascript and Ajax! You can setup a timer in JS, then pass the URL of a file that will do this function and have its return value be whatever you want.
  3. Also, inthe $sql2 string, you are passing the $password variable, whic is not the md5 value. Try passing in the $has value instead (just a guess since I would expect all passwords to be in the md5 format).
  4. I put this in the wrong forum and copied it to this one. I apologize ahead of time for the double post. (quote author=radi8 link=topic=333351.msg1569942#msg1569942 date=1305654626) One more question for you all: We just installed a new Linux Ubuntu V 11.04 server with LAMP (Apache2, PHP 5.3.x, MySQL 5.1.4, etc...) all out of the box stuff. I developed (locally) and app where I am exporting some data from MySQL, putting it into a spreadsheet and then sending the Excel file to the client. This all worked fine in my dev setup. BUT... (you know whats coming next) after deploying the app to the new Web Server, when I attempt to export the data, I am successfully creating the Excel file but rather than opening the download dialogue box, the data is being read and sent to the browser window as text! As I mentioned before, this is a new web server, so there may be something missing on the Apache2 setup, or my code may just be crap. Either way, my head hurts and cannot find out what is happening. Here is my header type configuration: <?php function save($filename, $download=false, $download_filename="") { if (!$download) { return $this->domXML->save($filename); } elseif ($this->domXML->save($filename)) { $realFileInfo = $_SERVER['DOCUMENT_ROOT'].'/truck/admin/export/'.$download_filename; $FileInfo = pathinfo($filename); ob_end_clean(); // fix for IE catching or PHP bug issue header("Pragma: public"); header("Expires: 0"); // set expiration time header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header ("Pragma: no-cache"); //header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // browser must download file from server instead of cache // force download dialog header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera header("Content-type: application/x-msexcel"); header("Content-Type: application/download"); // use the Content-Disposition header to supply a recommended filename and // force the browser to display the save dialog. if ($download_filename == "")$download_filename = "download.xls"; //header("Content-Disposition: attachment; filename=".$download_filename.";"); header("Content-Disposition: attachment; filename=".$realFileInfo.";"); header("Content-Transfer-Encoding: binary"); //header("Content-Length: ".filesize($filename)); header("Content-Length: ".filesize($realFileInfo)); //@readfile($filename); @readfile($realFileInfo); return true; } return false; } ?> I added a screen cap for you to see the output. Can you see anything wrong? [attachment deleted by admin]
  5. radi8

    AJAX tut

    Who cares about their certifications. They have good, solid examples of many techniques and it is laid out in a way where you can get answers, especially on those really stupid 'I should know this' stuff. It is ONLY a resource, nothing more. Their AJAX samples are right on the money and the one explaining how to integrate JAVASCRIPT with PHP is really easy to grasp and use.
  6. I put this in the wrong forum. I don't even know why I was in the AJAX forum t begin with. Does anyone know how to move this to the 'General Help' board?
  7. One more question for you all: We just installed a new Linux Ubuntu V 11.04 server with LAMP (Apache2, PHP 5.3.x, MySQL 5.1.4, etc...) all out of the box stuff. I developed (locally) and app where I am exporting some data from MySQL, putting it into a spreadsheet and then sending the Excel file to the client. This all worked fine in my dev setup. BUT... (you know whats coming next) after deploying the app to the new Web Server, when I attempt to export the data, I am successfully creating the Excel file but rather than opening the download dialogue box, the data is being read and sent to the browser window as text! As I mentioned before, this is a new web server, so there may be something missing on the Apache2 setup, or my code may just be crap. Either way, my head hurts and cannot find out what is happening. Here is my header type configuration: <?php function save($filename, $download=false, $download_filename="") { if (!$download) { return $this->domXML->save($filename); } elseif ($this->domXML->save($filename)) { $realFileInfo = $_SERVER['DOCUMENT_ROOT'].'/truck/admin/export/'.$download_filename; $FileInfo = pathinfo($filename); ob_end_clean(); // fix for IE catching or PHP bug issue header("Pragma: public"); header("Expires: 0"); // set expiration time header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header ("Pragma: no-cache"); //header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // browser must download file from server instead of cache // force download dialog header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera header("Content-type: application/x-msexcel"); header("Content-Type: application/download"); // use the Content-Disposition header to supply a recommended filename and // force the browser to display the save dialog. if ($download_filename == "")$download_filename = "download.xls"; //header("Content-Disposition: attachment; filename=".$download_filename.";"); header("Content-Disposition: attachment; filename=".$realFileInfo.";"); header("Content-Transfer-Encoding: binary"); //header("Content-Length: ".filesize($filename)); header("Content-Length: ".filesize($realFileInfo)); //@readfile($filename); @readfile($realFileInfo); return true; } return false; } ?> Can you see anything wrong? [attachment deleted by admin]
  8. radi8

    AJAX tut

    I used this one: http://www.w3schools.com/ajax/default.asp It really worked well and got me rolling on some GREAT dynamic page manipulation
  9. It was a permissions issue on the file. This is a new Linux LAMP server and I guess we are still learning. Thanks to all for your help and assistance. As always, you are the best source of help and support.
  10. That was a formatting issue I injected on this forum post and not a problem in the actual code page. Sorry for the confusion.
  11. I am using a PHP class for a web app that works perfectly well when developing on local machine (PHP 5.2) using the NuSphere IDE. NuSphere sees the class, and when I run the app locally everything seems to work, but when i port the app to the host (Linux Ubuntu with Apache2, PHP 5.3, MySQL 5.1 ), the class is not found (using the remote host debugger). The exact mesage is: Class 'ExcelXML' not found at <line of code>. Here is the code snippet: <?php function setExcelData($sql, $title, $fileName, $idref=0) { $retVal=false; //$fileName=$fileName.'.xml'; $fileName=$fileName.'.xls'; include ('ExcelXML.inc.php'); include_once $_SERVER['DOCUMENT_ROOT'].'/truck/inc/db.inc.php'; $input = ($idref==0?"blank1.xml":"blank.xml"); // create ExcelXML object $xml = new ExcelXML(); // read template file if (!$xml->read($input)) { echo "Failed to open Tempalate Excel XML file<br>"; } ... ?> Here is the class <?php /** * Class ExcelXML * Provide functions to modify the content of file in Excel's XML format. * * REQUIRED: * - An ExcelXML file as template * * FEATURES: * - read, modify, and save Excel's XML file * - create download stream as Excel file format (*.xls) * * CHANGELOG: * 06-08-2008 * - Update setCellValue function * - Fix setCellValue bug * 13-07-2008 * - First created * * * @author Herry Ramli (herry13@gmail.com) * @license GPL * @version 0.1.1 * @copyright August 06, 2008 */ class ExcelXML { var $domXML; var $activeWorksheet; function ExcelXML() { } ... ?> The class is in the same folder location as the calling php file. Any ideas? I don't get it.
  12. Actually, the solution was to use the following: document.getElementById("carrierMsg2").style.display = "table-cell" instead of: document.getElementById("carrierMsg2").style.display = "block"
  13. OK, here is the scenario, In the table in the first code segment below, I have to inner table elements that I will use to tell the user that the update either succeeded or failed (id's carrierMsg1 and carrierMsg2). If I view these elements without hiding them, they span the columns correctly and everything looks great... BUT (and there is always that but), if I hide the elements initially and then use Javascript (second section) to then conditionally show them, the table elements will only display in the first column of the table even though I explicitly tell it to colspan=8. This is definitely an issue with the style.display="bock" command. Can anyone help me get the embedded table to span the entire 8 columns? <table class="reference" width="100%" border="0" align=left> <caption align="top"> Carrier Info for 1st Choice / Barnett Truck </caption> <tr> <th width="7.5%">Number</th> <th width="25%">Name</th> <th width="30%">Email</th> <th width="7.5%">Ship CA</th> <th width="7.5%">Ship FL</th> <th width="7.5%">Ship PA</th> <th width="7.5%">Ship TX</th> <th width="7.5%">Disabled?</th> </tr> <tr> <td align="center">74926</td> <td align="center">1st Choice / Barnett Truck</td> <td align="center"><input type="text" size="40" id="carrierEmail" value="rrice@nurserysupplies.com"></td> <td align="center"><input type="checkbox" name="shipCA" id="shipCA" value=1 checked></td> <td align="center"><input type="checkbox" name="shipFL" id="shipFL" value=1 checked></td> <td align="center"><input type="checkbox" name="shipPA" id="shipPA" value=1 checked></td> <td align="center"><input type="checkbox" name="shipTX" id="shipTX" value=1 ></td> <td align="center"><input type="checkbox" name="carrierDisabled" id="carrierDisabled" value=1 ></td> </tr> <tr> <th colspan=8> <input type="button" name="updateBase" id="updateBase" value="Update Base Carrier Info" onClick="doBase(74926)"> </th> </tr> <tr> <th colspan=8 style="display:none" id="carrierMsg1"> <table class="reference" width = "100%" align="center"> <tr class="success"> <th>SUCCESS</th> </tr> <tr> <th>Carrier Data was successfully updated</th> </tr> </table></th> </tr> <tr> <th colspan=8 style="display:none" id="carrierMsg2"> <table class="reference" width = "100%" align="center"> <tr class="error"> <th>AN ERROR OCCURRED DURING UPDATE</th> </tr> <tr> <th>Carrier Data was NOT updated!!</th> </tr> </table></th> </tr> </table> java script: function doBase(carrierNbr){ if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState>=3 && xmlhttp.status==200) { var txt = xmlhttp.responseText; if(isNaN(txt)){ document.getElementById("carrierMsg2").style.display = "block"; //document.getElementById("carrierMsg2").cells.colspan=8; } else{ var txtVal = parseInt(txt); if(txtVal==0){ document.getElementById("carrierMsg1").style.display = "block"; // document.getElementById("carrierMsg1").cells.colspan=8; } else { document.getElementById("carrierMsg2").style.display = "block"; //document.getElementById("carrierMsg2").cells.colspan=8; } } } } document.getElementById("carrierMsg1").style.display = "none"; document.getElementById("carrierMsg2").style.display = "none"; var email = document.getElementById('carrierEmail').value; var ca = document.getElementById('shipCA').checked?1:0; var fl = document.getElementById('shipFL').checked?1:0; var pa = document.getElementById('shipPA').checked?1:0; var tx = document.getElementById('shipTX').checked?1:0; var dis = document.getElementById('carrierDisabled').checked?1:0; xmlhttp.open("GET","<?php print 'http://'.$_SERVER['HTTP_HOST'].'/webServices/updateCarrier.inc.php';?>?carrierNbr="+carrierNbr+"&carrierEmail="+email+"&shipCA="+ca+"&shipFL="+fl+"&shipPA="+pa+"&shipTX="+tx+"&disabled="+dis,true); xmlhttp.send(); }
  14. Vaguely, I will look into it. I was wondering if that was the route I needed to go. Thanks.
  15. I have a script that will call a php script to return data to a page using the following code (basic AJAX xmlHTTPResponse function): function showRates(from, to, drops, dist){ if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtRates").innerHTML=xmlhttp.responseText; document.getElementById("txtRates").style.display = "block"; } } var InterModal; var surcharge; if(document.getElementById("useSurcharge").checked )surcharge=true; else surcharge = false; if(document.getElementById("useInterModal").checked)InterModal=true; else InterModal = false; diesel = document.getElementById("dieselFuel").value; xmlhttp.open("GET","<?php print 'http://'.$_SERVER['HTTP_HOST'].'/webServices/'?>web.svc.php?start="+from+"&endZip="+to+"&drops="+drops+"&dist="+dist+"&diesel="+diesel+"&Surcharge="+surcharge+"&Intermodal="+InterModal,true); xmlhttp.send(); } The PHP script will return a formatted table to the function displaying the appropriate data. Unfortunately, the document.getElementById("txtRates").innerHTML store the data as a text string. In the table, there are elements that I need to reference in other areas of the form, but cannot. A sample of the table is given here: <table class=\"reference\" width=\"100% border=\"0\" align=\"center\"> <caption align=\"top\">\r\n Truck Rates for given Route\r\n </caption> <tr> <th width=\"5\">Click to Email</th> <th width=\"20%\"> Carrier </th> <th width=\"9%\"> Carrier Nbr </th> <th width=\"9%\"> Base Rate (ttl) </th> <th width=\"9%\"> Drop Fee </th> <th width=\"9%\"> Detention Hrs</th> <th width=\"9%\"> Detention Fee </th> <th width=\"10%\"> Mileage Surcharge </th> <th width=\"10%\"> Total Mileage Surcharge </th> <th width=\"10%\"> Total Rate </th> </tr> <tr> <th><input type=\"button\" id=\"email_83629\" name=\"\" onclick=\"emailSelected(83629)\"> <th>Command Transportation</th> <th>83629</th><td><div align=\"center\">1,303.06</div></td> <td><div align=\"center\">0.00</div></td><td><div align=\"center\">2.0</div></td> <td><div align=\"center\">50.00</div></td><td><div align=\"center\">0.45</div></td> <td><div align=\"center\">488.28</div></td> <td><div align=\"center\"><input type=\"text\" readonly=\"readonly\" disabled=\"disabled\" id=\"rate_83629\" value = 1,791.34></div></td> </tr> <tr> etc... </tr> </table> Notice that the first column and last columns are active elements which, if displayed as a static table would be active DOM objects. But, because this is displayed in the innerHTML these elements are not accessible using standard getElementById() notation. Obviously there is a better way to do this, but I am at a loss as to how. When the button in the first column is pressed, the script should direct the user to an email page where the last column element should be displayed. For now, if I select the first column I want o be able to read the last column. This does not work: function emailSelected(carrierNbr){ var div = document.getElementById("textRates") var rateElement = "rate_" + carrierNbr; var rate = div.InnerHTML.getElementById(rateElement).value; alert('Carrier Nbr: ' + carrierNbr + ', rate: ' + rate); } Can anyone please help direct me to the proper technique?
  16. I d apologize for the tone of my previous reply, but yours was way overboard and totally childish. Typically, when a submission to a question is provided, the response should be as concise and complete as possible. I will try to be more 'friendly' to bad replies in the future.
  17. I have no friggin idea what the heck a reset.css is. I love it when this type of terminology is quoted but NO references or explanation are provided. But yes, the problem is solved.
  18. I should have looked a little more, this resolves the issue: table.reference{ border: 1px solid #c3c3c3; border-collapse: collapse; } table.reference caption{ background-color: #e5eecc; border: 1px solid #c3c3c3; padding: 3px; vertical-align: top; font-size: 100%; font-weight: bold; } table.reference th{ background-color: #e5eecc; border: 1px solid #c3c3c3; padding: 3px; vertical-align: top; } // ADD THIS STANZA table.reference tr.error th{ background-color: #ff0000; color:white; font-weight: bold; border: 1px solid #c3c3c3; padding: 3px; vertical-align: top; } // END NEW STANZA table.reference td{ border: 1px solid #c3c3c3; padding: 3px; vertical-align: top; } usage: <table class="reference" width="400" border="1" align=center> <caption> <?php print $formHeading; ?> </caption> <?php if($_formError['error'])print $_formError['message']; ?> <tr> // where the $_fromError['message'] is formatted like so: $msg='<tr class="error"><th colspan="3">The following errors occurred while processing your login:<br>'; // continue to build output... $_frmError['message']=$msg;
  19. With my site, I have a lot of form validation going on. If a user has an error in a form (table based), I want to highlight the row by set the TH cell background color to RED and change the TH cell text color to BOLD WHITE. CSS can do all this, but I need some help in making it work. Currently, my CSS will format the table for normal operation and display of good (or validated) data. I need to add to this so that I can change the one row to highlight the invalid entry or data. Here is my current CSS which works nicely to format the table for easy viewing: table.reference{ border: 1px solid #c3c3c3; border-collapse: collapse; } table.reference caption{ background-color: #e5eecc; border: 1px solid #c3c3c3; padding: 3px; vertical-align: top; font-size: 100%; font-weight: bold; } table.reference th{ background-color: #e5eecc; border: 1px solid #c3c3c3; padding: 3px; vertical-align: top; } table.reference td{ border: 1px solid #c3c3c3; padding: 3px; vertical-align: top; }
  20. <?php $line1=""; $1stTime=true; $query2 = "SELECT * FROM tracker WHERE username = '" . mysql_real_escape_string($usera) . "'"; $result = mysql_query($query2) or die('Error, query failed : ' . mysql_error()); while($row = mysql_fetch_assoc($result)) { // handle the comma insertion, not initially and not at the end if(!$1stTime) $line1 .= ","; $line1.= "[['{".$row['date']."}',{".$row['reps']."}]"; } ?> This should build the string, or get you close.
  21. The problem resides in the fact that the php script is still running on the server. While a script is running, only 1 set of headers can be sent. The only way to get something like this to work is to have the current script finish completely and then restart another script to reload the page. But, as of now, I do not know how to flush the current script and start another, possibly by starting a cron job (or something) where the script can complete and do the appropriate garbage cleanup and streams closed, and then start an entirely new script set to reload the page. The key is that the original script must NOT have any active processing at all, it must finish and be flushed/closed completely.
  22. This is the goal, but I was going to get the individual regex pattern correct first. Adding the ':' is a trivial matter from that point. Thank you all for the input, I have it working and all is golden!!!
  23. 50jkelly, well that could be a problem since Excel 2003/2005 limits are 64565 rows. I need to do a test to ensure that this limit is not exceeded. Excel 2010 allow for 104876 rows, but this is only on newer versions. Thanks, I will add the $ at the end of the string and give it a shot!
  24. I apologize for the confusion. When all is said and done, the user will enter a range in the form of 'A1:B5'. The user will enter only 1 range of values. In this range, you have a beginning cell and ending cell, which in the script above I explode into the array so that I have: $range: Array ( [0] => A1 [1] => B5 ) I am trying to create the regex pattern to validate each cell reference so that it has 1 or 2 alpha chars at the beginning, and 1 to 5 numeric chars at the end. The alpha chars MUST be at the beginning and the numeric chars MUST be at the end. I have this and it seems to be working better but further testing is required: $regex='/^([A-Za-z]{1,2}+[0-9]{1,5})/';
  25. I have been playting with the following preg_match test for testing user input for excel cell location. The input should be of the form: a1:b20, or a1:zz64564 (or something like that). What the individual cells cannot be is: aaa1 (or 3 alpha chars at the beginning). To test this pattern (a1:b1) I am first exploding the string to get each element into the array, and then testing each reference individually. I will combine it later once I get the regex pattern correct. What is not working is when the cell has more than 2 alpha chars at the beginning. If someone can help clean this up, I would appreciate it. These patterns are hard to get right if you are a novice at them. $regex='/(^([A-Z])|([a-z]){1,2}[0-9]{1,})/'; if(isset($_POST['startingCell'])){ $range=explode(':',$_POST['startingCell'],2); if(strlen($range[0])>0 && count($range)==2){ $validArray=true; foreach($range as $rng){ if(!preg_match($regex,$rng)){ $frmErrorLevel=3; $frmErrorRange=true; } else{ $validArray=true; } } } else{ $frmErrorLevel=3; $frmErrorRange=true; } }
×
×
  • 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.