Jump to content

radi8

Members
  • Posts

    168
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

radi8's Achievements

Member

Member (2/5)

0

Reputation

  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?
×
×
  • 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.