Jump to content

unkwntech

Members
  • Posts

    447
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.unkwndesign.com

Profile Information

  • Gender
    Male
  • Location
    San Diego, CA

unkwntech's Achievements

Member

Member (2/5)

0

Reputation

  1. I have the following code: $client = new SoapClient($this->config->host . $this->config->path); $v = $client->__call('getStoreInfo', array('ccpStoreId'=>'f710868', 'requestDate'=>date('d/m/Y'), 'requestId'=>rand(1,9999))); var_dump($v); i know that the variables in the SoapClient are correct, and that the data being bassed to __call() is correct, and that the function getStoreInfo on the API takes 3 arguments with the keys in the array. However all that I get back is either an error or null. The definition for this function looks like this: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="CLIPPED"> <soapenv:Header/> <soapenv:Body> <ser:getStoreInfo> <ser:in0> <!--Optional:--> <ser:ccpStoreId>?</ser:ccpStoreId> <!--Optional:--> <ser:requestDate>?</ser:requestDate> <!--Optional:--> <ser:requestId>?</ser:requestId> </ser:in0> </ser:getStoreInfo> </soapenv:Body> </soapenv:Envelope>
  2. I have the following code. 'hello.php' is a file that does not exist, and as expected require_once is throwing an error: Warning: require_once(template/pages/hello.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/public_html/index.php on line 26 Fatal error: require_once() [function.require]: Failed opening required 'template/pages/hello.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/public_html/index.php on line 26 However the catch statement is never happening, what am I doing wrong? $page = 'hello'; //If the page that was requested does not exist then load an error page showing a 404 try { require_once 'template/pages/' . $page . '.php'; } catch(Exception $e) { //TODO: send a status code 404 require_once 'template/pages/error/404.php'; }
  3. I have a textbox that is posting a list of items (one per line) when I attempt to split that list into an array with this code: $answers = preg_split('/[\r\n]+/', $_POST['answers'], -1, PREG_SPLIT_NO_EMPTY); where $_POST['answers'] = "red\ngreen\nblue"; `$answers` results in an empty array. I have also tried $answers = explode("\n", $_POST['answers']); which resulted in an array with a single empty element.
  4. No there is no problem other then the WTF, I havn't seen/written code like this is several years, and I'm suprised by it. This code comes from a group of 'senior developers', but I warned him no to outsource.
  5. I just found this <sarcasam> wonderful </sarcasam> piece of code in a project I am taking over.... Is it just me or is this really as much of a WTF as I think it is? function db_connect() { global $db_host, $db_user, $db_pass, $db_name, $db_connection; $db_connection = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error()); mysql_select_db($db_name,$db_connection); return $db_connection; } function command($sql){ if(db_connect()) $result = mysql_query($sql) or die(mysql_error()); return $result; } function query($table,$fields,$values,$request) { global $db_connection; if($request=="Add") { $command="insert into " . $table ." (" .$fields .") values(". $values . ")"; } else if($request=="Update") { $update=updateClause($fields,$values); $command="Update ". $table ." set ". $update ."where ". $_SESSION["whereClause"]; } //print $command; $result = mysql_query($command) or die(mysql_error()); //echo $result; //return $result; } function updateClause($fields,$values){ $i=0; $fieldArray=split(",",$fields); $valueArray=split(",",$values); foreach($fieldArray as $key) { $i++; } for($j=0;$j<$i;$j++) { $update1 .=$fieldArray[$j] . "=" . $valueArray[$j] . ", "; } $update1 .=":"; list($update,$a)=explode(", :",$update1); return $update; }//end function function row_count($result) { $numrows = mysql_num_rows($result); return $numrows; } function db_getrow($result) { $getrow = mysql_fetch_row($result); return $getrow; } function db_getarray($result) { $getarray = mysql_fetch_array($result); return $getarray; } function data($result) { $getarray = mysql_fetch_array($result,MYSQL_ASSOC); return $getarray; } function db_getfield($result,$field) { $getfield = mysql_fetch_field($result,$field); return $getfield; } function db_error() { $error = mysql_error(); return $error; } function dbclose($db_connection) { mysql_close($db_connection); } function flipdate($dt, $seperator_in = '-', $seperator_out = '-') { return implode($seperator_out, array_reverse(explode($seperator_in, $dt))); } function get_column($sql) { $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_row($result); return $row[0]; } function get_row($sql) { $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); return $row; }
  6. Nothing too see here, I'm an idiot and resolved the problem.
  7. I have the following .htaccess RewriteEngine on RewriteRule ^audio/(.*?)/ audio.php?id=$1 #works fine RewriteRule ^browse/(.*?)/(.*?)/ browse.php?type=$1&sort=$2 #not working the first RewriteRule works fine however the second one is rewriting to the correct file but the parameters (type&sort) are not being passed. The browse.php currently looks like this: <pre> <?php print_r($_REQUEST); echo $_SERVER['REQUEST_URI'] . "\n" . $_SERVER['SCRIPT_NAME']; ?> </pre> This page is outputting the following:
  8. What is not happening that should be, or what is happening that should not be?
  9. Is it faster for the randomize the sort order of a large set of results on the MySQL server or after I have received the data in PHP? Does anyone have any data to backup either side, or even anecdotal experience? It seems to me that MySQL will probably be faster, however I can't do the benchmark right now, I don't think I have enough data at the moment, but I do see it as a problem in the near future.
  10. When I change the dropdown and the function is called the additional rows are added above the form when the div I am adding them to is at the bottom, this is the page as it stands now: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="javascript"> function changeFormLength() { var rows = document.getElementById('rows').value; var i = 0; while(i < rows) { document.getElementById('rowSpace').innerHTML = document.getElementById('rowSpace').innerHTML +'\ <tr>\ <td><input type="text" name="firstname_'+i+'" id="firstname" /></td>\ <td><input type="text" name="lastname_'+i+'" id="lastname" /></td>\ <td><input name="cc_num_'+i+'" type="text" id="textfield3" size="20" maxlength="16" /></td>\ <td><label>\ <select name="cc_type_'+i+'" id="select">\ <option value="visa" selected="selected">Visa</option>\ <option value="mastercard">MasterCard</option>\ <option value="discover">Discover</option>\ <option value="amex">American Express</option>\ </select>\ </label></td>\ <td><label>\ <select name="cc_exp_m_'+i+'" id="cc_exp_m">\ <option value="01">1 January</option>\ <option value="02">2 Feburary</option>\ <option value="03">3 March</option>\ <option value="04">4 April</option>\ <option value="05">5 May</option>\ <option value="06">6 June</option>\ <option value="07">7 July</option>\ <option value="08">8 August</option>\ <option value="09">9 September</option>\ <option value="10">10 October</option>\ <option value="11">11 November</option>\ <option value="12">12 December</option>\ </select>\ /\ <select name="cc_exp_y_'+i+'" id="cc_exp_y">\ <option value="2009">2009</option>\ <option value="2010">2010</option>\ <option value="2011">2011</option>\ <option value="2012">2012</option>\ <option value="2013">2013</option>\ <option value="2014">2014</option>\ <option value="2015">2015</option>\ <option value="2016">2016</option>\ <option value="2017">2017</option>\ <option value="2018">2018</option>\ <option value="2019">2019</option>\ <option value="2020">2020</option>\ </select>\ </label></td>\ <td><input name="cc_cvv_'+i+'" type="text" id="cc_cvv" size="5" maxlength="4" /></td>\ <td><input name="amt_'+i+'" type="text" id="amt" size="10" maxlength="7" /></td>\ </tr>\ '; i++; } } </script> </head> <body> Add how many rows?<br /> <select name="rows" id="rows" onchange="changeFormLength();"> <option value="1" selected="selected">1</option> <option value="5">5</option> <option value="10">10</option> <option value="15">15</option> <option value="20">20</option> <option value="25">25</option> <option value="30">30</option> <option value="35">35</option> <option value="40">40</option> <option value="45">45</option> <option value="50">50</option> <option value="55">55</option> <option value="60">60</option> </select> <form id="form2" name="form2" method="post" action=""> <label></label> <label></label> <label></label> <table width="78%" border="0" cellpadding="2"> <tr> <td width="17%">First Name</td> <td width="17%">Last Name</td> <td width="14%">Card Number</td> <td width="16%">Card Type</td> <td width="23%">Card Expiration</td> <td width="5%">CVV</td> <td width="8%">Ammount</td> </tr> <tr> <td><input type="text" name="firstname" id="firstname" /></td> <td><input type="text" name="lastname" id="textfield2" /></td> <td><input name="textfield3" type="cc_num" id="textfield3" size="20" maxlength="16" /></td> <td><label> <select name="cc_type" id="select"> <option value="visa" selected="selected">Visa</option> <option value="mastercard">MasterCard</option> <option value="discover">Discover</option> <option value="amex">American Express</option> </select> </label></td> <td><label> <select name="cc_exp_m" id="cc_exp_m"> <option value="01">1 January</option> <option value="02">2 Feburary</option> <option value="03">3 March</option> <option value="04">4 April</option> <option value="05">5 May</option> <option value="06">6 June</option> <option value="07">7 July</option> <option value="08">8 August</option> <option value="09">9 September</option> <option value="10">10 October</option> <option value="11">11 November</option> <option value="12">12 December</option> </select> / <select name="cc_exp_y" id="cc_exp_y"> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> </select> </label></td> <td><input name="cc_cvv" type="text" id="cc_cvv" size="5" maxlength="4" /></td> <td><input name="amt" type="text" id="amt" size="10" maxlength="7" /></td> </tr> <div id="rowSpace"> </div> </table> </form> </body> </html>
  11. Apparently JS doesn't support multi-line string literals, so I had to add a \ to the end of each line
  12. I'm getting the following error on load: Uncaught SyntaxError: Unexpected token ILLEGAL file://path/to/file.ext (line 13) This is the code: function changeFormLength() { var rows = document.getElementById('rows').value; var i = 0; while(i < rows) { //the line under this is line 13, this line (comment) does not exist in the code document.getElementById('rowSpace').innerHTML += '<tr> <td><input type="text" name="firstname_'+i+'" id="firstname" /></td> <td><input type="text" name="lastname_'+i+'" id="lastname" /></td> <td><input name="cc_num_'+i+'" type="text" id="textfield3" size="20" maxlength="16" /></td> <td><label> <select name="cc_type_'+i+'" id="select"> <option value="visa" selected="selected">Visa</option> <option value="mastercard">MasterCard</option> <option value="discover">Discover</option> <option value="amex">American Express</option> </select> </label></td> <td><label> <select name="cc_exp_m_'+i+'" id="cc_exp_m"> <option value="01">1 January</option> <option value="02">2 Feburary</option> <option value="03">3 March</option> <option value="04">4 April</option> <option value="05">5 May</option> <option value="06">6 June</option> <option value="07">7 July</option> <option value="08">8 August</option> <option value="09">9 September</option> <option value="10">10 October</option> <option value="11">11 November</option> <option value="12">12 December</option> </select> / <select name="cc_exp_y_'+i+'" id="cc_exp_y"> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> </select> </label></td> <td><input name="cc_cvv_'+i+'" type="text" id="cc_cvv" size="5" maxlength="4" /></td> <td><input name="amt_'+i+'" type="text" id="amt" size="10" maxlength="7" /></td> </tr> '; i++; } }
  13. No because they are members of the "this" object so $this->varName is a reference to the variable in the class.
×
×
  • 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.