Jump to content

qwerty234

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

qwerty234's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have pasted my code below. I want to place the user's uploaded image in /tmp/latest.img, but for some reason it is always uploading the same file even though I'm using fopen with the "wb" permission set and fclose. Does anyone have any ideas? move_uploaded_file($_FILES['imagefile']['tmp_name'],"/tmp/latest.img"); $instr = fopen("/tmp/latest.img","wb"); $image = addslashes(fread($instr,filesize("/tmp/latest.img"))); if (strlen($instr) < 20000) { $validImageSize = true; } else { $validImageSize = false; } fclose($instr);
  2. I cannot get the following XSLT to work. I am grabbing the feed properly but the HTML and the XML elements that are supposed to fill it are not being displayed at all. Can some one please help / debug my code? Code follows below. I have the following code that successfully grabs an XML feed: <?php $detailsObtained = false; $syms = ""; $serviceURL = "http://localhost:8880/detailed_quote.html.xml"; $cobj=curl_init($serviceURL); curl_setopt($cobj,CURLOPT_RETURNTRANSFER,1); $response=curl_exec($cobj); curl_close($cobj); if ($response) { $detailsObtained = true; } else echo "Error reading feed"; if ($detailsObtained) { $parser = xslt_create(); $html = xslt_process($parser,$response,"/var/www/html/transform.xsl"); echo($html); } ?> My XSL looks like this: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Stocks</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Ticker</th> <th align="left">high</th> </tr> <xsl:for-each select="MSXML/quote"> <tr> <td><xsl:value-of select="ticker" /></td> <td><xsl:value-of select="high" /></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> And the abbreviated XML feed (which I cannot change the format of) and will have to stay as is looks like the following: <MSXML> <quote source="MSFT"> <ticker>MSFT</ticker> <description>MICROSOFT CORP.</description> <current>28.54</current> <netChange>+0.10</netChange> <percentChange>+0.35%</percentChange> <open>28.67</open> <high>28.75</high> <low>28.41</low> <close>28.44</close> <oneYearHigh>31.84</oneYearHigh> <oneYearLow>25.42</oneYearLow> <dateTime>09/10/2007 14:14 EDT</dateTime> </quote> <quote source="SPX.X"> <ticker>SPX.X</ticker> . . . </MSXML>
  3. How can I determine the values of a listbox, both unselected or selected after submitting the form: <select name="sel1" size="10" multiple="multiple"> <? PHP code populates listbox ?> </select> Do I have to use Javascript to determine the contents, like in the pseudo code Javscript below. But how would you pass the Javascript return value to PHP? function listBoxContents(sel1) { var selLength1 = sel1.length; var valuesPresent1 = new Array(sel1.length-1); var i; for(i=0; i<=selLength1-1; i++) { valuesPresent1[i]=sel1.options[i].valueOf(); } return valuesPresent1; }
  4. The variable $tools has an apostrophe ' in it. This kills the query. I have tried mysql_real_excape_string($tools) and stripslashes($tools) to no avail as you can see. Any ideas? $sql = " INSERT INTO project_tools (id,tool) "; $sql .= " VALUES ('$incident_id','$tools') "; $sql = " INSERT INTO project_tools (id,tool) "; $sql .= " VALUES ('$incident_id','" . stripslashes($tools) . "') "; $sql = " INSERT INTO project_tools (id,tool) "; $sql .= " VALUES ('$incident_id','" . mysql_real_excape_string($tools) . "') ";
  5. I create dynamic text boxes using the following Javascript code: function addMaterial() { var ni = document.getElementById('myDiv'); var numi = document.getElementById('theValue'); var num = (document.getElementById("theValue").value -1)+ 2; numi.value = num; var divIdName = "my"+num+"Div"; var newdiv = document.createElement('div'); newdiv.setAttribute("id",divIdName); newdiv.innerHTML = "<input name='material" + num + "' type='text' id='material" + num + "'> <a href=\"javascript:;\" onclick=\"removeEvent(\'"+divIdName+"\')\">Remove the material</a>"; ni.appendChild(newdiv); } On POST, how can I, in PHP. determine the content of the dynamic text boxes created. Or would I have to use Javascript again?
  6. Hi, In my HTTP header I've collected the following values from a multi-select list after my POST: project_list=community_name&project_list=project_number&project_list=map_letter&project_list=home_type Here's my PHP code to loop thru the project_list after the POST. For some reason my array $a is not being populated, do you see why? $a = array(); foreach ($_POST['project_list'] as $selected) { if ($selected == 'community_name'){ $a[] = "projects.project_name "; } if ($selected == 'project_number'){ $a[] = "projects.project_number "; } if ($selected == 'map_letter'){ $a[] = "projects.map_letter "; } if ($selected == 'home_type'){ $a[] = "home_types.home_type "; } . . .
  7. Ignoring the print_r below (which is telling me that there is data in $result), can someone tell me why my iteration is not outputing the data from $result? $excel_row = 6; $excel_col = 0; print_r($result); $colnames = array_keys ($result[0]); foreach ($result as $row) { foreach ($colnames as $colName) { $sheet->write($excel_row,$excel_col,$row[$colName],$colHeadingFormat); $excel_col++; } $excel_row++; }
  8. Anybody see a problem with the way I'm triying to print these columns out using PEAR/Excel? $result is populated -- I made sure with print_r. $rows = 0; $cols = 0; $rows = mysql_num_rows ($result); $cols = mysql_num_fields ($result); $colNames = array(); for ($col = 0; $col < $cols; $col++) { $colNames[col] = mysql_field_name($result, $col); } // Add all the column headings with a single call // leaving a blank row to look nicer $sheet->writeRow(5,0,$colNames,$colHeadingFormat); $colHeadingFormat2 =& $xls->addFormat(); $colHeadingFormat2->setFontFamily('Helvetica'); $colHeadingFormat2->setSize('10'); $colHeadingFormat2->setAlign('center'); for ($row = 0; $row < $rows; $row++) { $rs = mysql_fetch_row ($result); for ($col = 0; $col < $cols; $col++) { $sheet->write($row+6,$col,$rs[$col],$colHeadingFormat2); } }
×
×
  • 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.