Jump to content

mallen

Members
  • Posts

    316
  • Joined

  • Last visited

Everything posted by mallen

  1. Thanks I was looking at it so long i missed that. The concatenating (sp) was because my original code had more to out put. I just had the echo in the wrong place.
  2. function getSimilarProducts() { global $wpdb; $out =""; $Simprod = "SELECT DISTINCT (pr.prod_id), pr.prod_image FROM products as pr LEFT JOIN category_assoc as assoc ON assoc.prod_id = pr.prod_id WHERE pr.companyB = '1' AND assoc.cat_id = '28' AND pr.prod_active = '1' LIMIT 3"; $SIM = $wpdb->get_results($Simprod, ARRAY_A); echo "These are similar products you may like."; foreach($SIM as $sample) { $out .= "<img src='". $this->imgLink . "/".$sample['prod_image']. "' />"; echo $out; } } I have a simple query I tested in phpmyAdmin. Returns the limit results I need. But when I run my function I get duplicates, it returns 6 results all the same ID.
  3. $THEURL = "SELECT Image_URL From ... ect";//the query $image = $wpdb->get_row($THEURL, ARRAY_A);//the variable is dynamic var_dump(substr(strrchr($image,'/'),1)); fails var_dump(substr(strrchr('http://somewebsite.com/images/image1.jpg','/'),1)); gives 'image1.jpg' var_dump($image); // gives 'http://somewebsite.com/images/image1.jpg' I figured it out: var_dump(substr(strrchr($image['Image_URL'],'/'),1));
  4. Ok I am following you. But in your example you assigned a value to $image. But I already have a value to $image. And if I dump it is gives me the string. So I need to do the reverse. $image = 'http://somewebsite.com/images/image1.jpg';
  5. I'm trying to take the value and pick out everything after the trailing slash. I tested and the variable is correct. On the third line I can't figure out how to format it. var_dump($image);// http://somewebsite.com/images/image1.jpg var_dump(substr(strrchr('http://somewebsite.com/images/image1.jpg', '/'), 1)); //image1.jpg var_dump(strrchr(strrchr('$image','/'),1));//getting false
  6. I found a solution using MySQL full text search in boolean mode that has worked well.
  7. I have been asked to create a more comprehensive search on my website. I have listed products. The table consists of id, name, model, description, watt_range, terms. The problem I have having is if someone searches with multiple words the search won't give results. If I have an item like this. AreaLight2, xyz light, here is the description, 70-100w, area. If someone searches "AreaLight2" it returns the result. If you search "Arealight2 100w" it won't return any results. Can anyone help me point me in the right direction to get this to work? Thanks. Here is the query 'SELECT cat.cat_name, cat.cat_id, prod.prod_id, prod.prod_name, prod.prod_mainImage, prod.prod_description, prod_model, prod.terms FROM `products` as prod LEFT JOIN `category_assoc` AS assoc ON assoc.prod_id = prod.prod_id LEFT JOIN `categories` AS cat ON cat.cat_id = assoc.cat_id WHERE prod.terms LIKE '%Arealight2%' OR LIKE '%100w%' OR prod.prod_name LIKE '%Arealight2%' OR LIKE '%100w%''
  8. I got it solved. I was adding methods below the closing bracket of the class.
  9. Thanks. I just tested that sample code I posted and saw that it worked. Now I need to know why is doesn't on my project. They is just too much to post here. Something must be conflicting. Works without $disp->
  10. If I type it just like this echo $disp->displayTomorrow(); I get Fatal error: Call to undefined method MyDisplay::displayTomorrow()
  11. class MyDisplay { function displayToday() { $today = "Thursday"; { echo $today; } } function displayTomorrow() { $tomorrow = "Friday"; { echo $tomorrow; } } } $disp = new MyDisplay(); echo $disp->displayToday(); echo displayTomorrow();//fails is I have $disp-> I simplified my code for explanation. One class with two methods. When I try to use the method I get this error. Fatal error: Call to undefined method MyDisplay::displayTomorrow()
  12. Seems I got it fixed. $digit .= ($num = $possible_letters[rand(0,strlen($possible_letters)-1)]); I added -1 but I am not sure what the -1 does.
  13. I am working on creating a cusom captcha. It creates a random alphanumeric string. I set the value for the total characters to "5" but sometimes it will only display 4 characters. Is this a result of the rand function? session_start(); error_reporting(E_ALL ^ E_NOTICE); $image = @imagecreatetruecolor(120, 30) or die("Cannot Initialize new GD image stream"); // set background and allocate drawing colours $background = imagecolorallocate($image, 0x66, 0x99, 0x66); imagefill($image, 0, 0, $background); $linecolor = imagecolorallocate($image, 0x99, 0xCC, 0x99); $textcolor1 = imagecolorallocate($image, 0x00, 0x00, 0x00); $textcolor2 = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); $lines = 5; // draw random lines on canvas for($i=0; $i < $lines; $i++) { imagesetthickness($image, rand(1,3)); imageline($image, 0, rand(0,30), 120, rand(0,30) , $linecolor); } $string = ''; $total_characters = 5; $random_dots = 5; $font_size = 16; $possible_letters = '2345678abcdefghjkmnpqrtwyABCDEFGHJKMNPQRTWY'; $fonts = array(); $fonts[] = "fonts/font1.ttf"; $fonts[] = "fonts/font2.ttf"; $fonts[] = "fonts/font3.ttf"; for( $i=0; $i<$random_dots; $i++ ) { imagefilledellipse($image, mt_rand(0,120), mt_rand(0,30), 2, 3, $image_noise_color); } session_start(); $i = 0; $digit = ''; for($x = 15; $x <= 95; $x += 20 ) { while ($i < $total_characters ) { $i++; $x += 15; $textcolor = (rand() % 2) ? $textcolor1 : $textcolor2; $digit .= ($num = $possible_letters[rand(0,strlen($possible_letters))]); imagettftext($image, $font_size, 0, $x, 20, $textcolor, $fonts[array_rand($fonts)], $num);}} $_SESSION['digit'] = $digit; header('Content-type: image/png'); imagepng($image); imagedestroy($image);
  14. I solved it. SELECT DISTINCT main_categories.cat_id AS main_cat_id , main_categories.cat_name AS main_cat_name , child_categories.cat_id AS child_cat_id , child_categories.cat_name AS child_cat_name FROM categories AS main_categories LEFT JOIN categories AS child_categories ON child_categories.cat_parent = main_categories.cat_id LEFT JOIN category_assoc AS assoc ON assoc.cat_id = main_categories.cat_id LEFT JOIN products AS pr ON pr.prod_id = assoc.prod_id WHERE main_categories.cat_parent IS NULL AND `". $this->company . "` = '1' ORDER BY main_categories.cat_name ASC
  15. I have a working query that displays a list of categories, sub categories. I also have a working query that only lists main categories but leaves out "this company =1" and the products table. Incorporating this line is what I am have hard time with. This first one works, and there are no sub categories to display. SELECT cat.cat_name, cat.cat_id FROM categories as cat LEFT JOIN category_assoc as assoc ON assoc.cat_id = cat.cat_id LEFT JOIN products as pr ON pr.prod_id = assoc.prod_id WHERE `". $this->company . "` = '1' ORDER BY cat.cat_name ASC"; This one displays categories and sub categories, but also ones with no products associated with them for that company. I don't want any categories to be listed if there are no products for that company. The condition for the company being "1" is what determines the list of categories. So each of the companies don't have the same list. I think I need a inner join? I have categories, category_assoc and products tables. SELECT main_categories.cat_id AS main_cat_id , main_categories.cat_name AS main_cat_name , child_categories.cat_id AS child_cat_id , child_categories.cat_name AS child_cat_name FROM categories AS main_categories LEFT JOIN categories AS child_categories ON child_categories.cat_parent = main_categories.cat_id WHERE main_categories.cat_parent IS NULL ORDER BY main_categories.cat_name ASC
  16. Fixed it by changing $key to $value function createOptionFromArray($myArray,$selected) { if(!is_array($myArray)) { return false; } $returned = $select = ''; foreach($myArray as $key => $value) { if($selected == $value) { $select = ' selected'; } $returned .= "<option value=\"$value\"$select>$value</option>"; $select = ''; } return $returned; }
  17. function createOptionFromArray($myArray,$selected) { if(!is_array($myArray)) { return false; } $returned = $select = ''; foreach($myArray as $key => $value) { if($selected == $key) { $select = ' selected'; } $returned .= "<option value=\"$key\"$select>$value</option>"; $select = ''; } return $returned; } $option = array(0 => 'Rent', 1 => 'Own'); $selected = (isset($_POST['rent_own']) && intval($_POST['rent_own']) < 2) ? $_POST['rent_own'] : ''; print "<select name=\"rent_own\">\n"; print createOptionFromArray($option,$selected); print "</select>\n"; I am trying to get my form to hold the value of the selext box which it does. But the value I get back is "1" or "0". I need to have the value be "Rent" or "Own". How can I do this? $rent_own = $_POST['rent_own']
  18. I have a variable scope problem. I need to be able to access $xml in the process() method. class AuthorizeNet extends GatewayFramework implements GatewayModule { var $cards = array("visa", "mc"); var $status = array("1" => "CHARGED","4" => "PENDING"); public $xml; public $splitted; public $txnstatus; function AuthorizeNet () { parent::__construct(); $this->setup('login','password','testmode'); } function actions () { add_action('mycart_process_order',array(&$this,'process')); } function process () { global $Mycart; $message = $this->build(); $Response = $this->send($message); $status = $splitted[0]; if ($status == "2" || $status == "4"){ $message = $xml->messages->message->code; $code = $splitted[0]; if (empty($message)) { new MycartError(__("A configuration error occurred while processing this transaction. Please contact the site administrator.","Mycart"),'authnet_error',MYCART_TRXN_ERR); return; } new MycartError($xml->messages->message->code,'authnet_error',MYCART_TRXN_ERR); var_dump($xml->messages->message->code); return; } var_dump($xml->directResponse[6]);echo "\n<br />\n"; $splitted = explode(',', $xml->directResponse[0]); //var_dump($this->$splitted);echo "\n<br />\n"; //echo var_dump($this->$splitted[6]);echo "\n<br />\n"; $txnid = $splitted[6]; var_dump($txnid);echo "\n<br />\n"; $txnstatus = $xml->messages->resultCode; / $Mycart->Order->transaction($txnid,$txnstatus); } function build () { $Order = $this->Order; $xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetXML::USE_DEVELOPMENT_SERVER); $xml->createCustomerProfileTransactionRequest(array( )); echo "Response: " . $xml->messages->message->code . "<br><br>"; echo "Code: " . $xml->messages->resultCode . "<br><br>"; echo "Text: " . $xml->messages->message->text . "<br><br>"; $splitted = explode(',', $xml->directResponse[0]); echo "Direct Code: " . $splitted[0] . "<br><br>"; echo "Dir Response: " . $xml->directResponse. "<br><br>"; echo "TXID: " . $splitted[6] . "<br><br>"; //Successful //echo "Direct Response: " . $xml->directResponse[0] . "<br><br>"; echo "Transaction ID: " . $splitted[6] . "<br><br>"; var_dump($splitted[6]); echo "Raw request: " . $xml . "<br><br>"; //echo "Raw response: " . $response->customerProfileId . "<br><br>"; return $xml;//end function } function send ($message) { // $url = $this->url();//added $url = 'https://apitest.authorize.net/xml/v1/request.api'; $url = apply_filters('mycart_authorize_net_url',$url); } } // END class AuthorizeNet
  19. I get NULL. Since $xml->directResponse is in a different method but the same class would this make a difference?
  20. $split = explode(',', $xml->directResponse[6]); $txnid = $split[6]; echo $txnid; //I don't need to echo it. I tried that also tried this. I need to assign the value to $txnid. If I hard code a value in there like $txnid = "123456" my shopping cart will save it like that. Anything else will fail. So maybe the value needs a function around it. $txnid = "55678759949" ; //shopping cart will use it and save it $txnid = $split[6]; // doesn't work maybe something like $txnid = " .$split[6] . ";
  21. Thanks Actually the string comes from a XML reply <directResponse>1,1,1,some text here,ABCD,Y,55678759949,FGRTUD</directResponse> If I echo $xml->directResponse I will get 1,1,1,some text here,ABCD,Y,55678759949,FGRTUD I need $txnid to hold the value of 55678759949
  22. I am trying to record a part of this string. Should I format this some other way? 1,1,1,some text here,ABCD,Y,55678759949,FGRTUD <<<string $split = explode(',', $xml->directResponse[6]); $txnid = $split[6]; $txnid should equal '55678759949' but it doesn't like that format for some reason. If I put $txnid ="1234"; my page will save it with that value.
  23. This is what I got from a var_export($Response) if anyone can help. E00002 is a Authorize.net CIM response - The content-type specified is not supported. The only supported content-types are text/xml and application/xml. object(XMLdata)#125 (1) { ["data"]=> array(1) { ["ErrorResponse"]=> array(2) { ["ATTRS"]=> array(3) { ["xmlns:xsi"]=> string(41) "http://www.w3.org/2001/XMLSchema-instance" ["xmlns:xsd"]=> string(32) "http://www.w3.org/2001/XMLSchema" ["xmlns"]=> string(39) "AnetApi/xml/v1/schema/AnetApiSchema.xsd" } ["CHILDREN"]=> array(1) { ["messages"]=> array(1) { ["CHILDREN"]=> array(2) { ["resultCode"]=> array(1) { ["CONTENT"]=> string(5) "Error" } ["message"]=> array(1) { ["CHILDREN"]=> array(2) { ["code"]=> array(1) { ["CONTENT"]=> string(6) "E00002" } ["text"]=> array(1) { ["CONTENT"]=> string(44) "The content-type specified is not supported." } } } } } } } } }
×
×
  • 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.