Jump to content

strazdinjsh

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Everything posted by strazdinjsh

  1. such array as matrix A1 A2 A3 B1 B2 B3 C1 C2 C3 must return the array containing all possible combinations of the matrix without repetitions 1. no pairs must return each array element seperately 2. 1 pair (2 elements) must return smth like A1B1-A1B2-A1B3 A2B1-A2B2-A2B3 ... ... ... 3. 3 (or size of array) elements must return A1B1C1-A1B2C1-A1B3C1 A2B1C1-A2B2C1-A2B3C1 ... ... ...
  2. I am looking for help to make a function who returns the all possible variations without repetitions of the 2D array elements. I have done it easily with 1D array like: $array = array('a', 'b', 'c', 'd'); print_r(variations($array)); function variations($array){ $size = count($array); $data = array(); for($i=0; $i<$size; $i++) { foreach($array as $key=>$val) $data[] = array_slice($array, 0, $key+1); array_shift($array); } return $data; }; Have no luck to do so with 2D array what is required for the certain part of the web. The result must look something like: $array = array( array('a1', 'a2', 'a3'), array('b1', 'b2', 'b3'), array('c1', 'c2', 'c3'), ... ... array('x1', 'x2', 'x3') ); ################################# 1 variable a1 a2 a3 b1 b2 b3 c1 c2 c3 ########################################################## 2 variables a1 b1 a1 b2 a1 b3 a2 b1 a2 b2 a2 b3 a3 b1 a3 b2 a3 b3 ----------------- a1 c1 a1 c2 a1 c3 a2 c1 a2 c2 a2 c3 a3 c1 a3 c2 a3 c3 ----------------------------------------- b1 c1 b1 c2 b1 c3 b2 c1 b2 c2 b2 c3 b3 c1 b3 c2 b3 c3 ############################################################ 3 variables a1 b1 c1 a1 b2 c1 a1 b3 c1 a1 b2 c1 a1 b2 c2 a1 b2 c3 a1 b3 c1 a1 b3 c2 a1 b3 c3 ------------------------------------------------------------- a2 b1 c1 a2 b2 c1 a2 b3 c1 a2 b2 c1 a2 b2 c2 a2 b2 c3 a2 b3 c1 a2 b3 c2 a2 b3 c3 ------------------------------------------------------------ a3 b1 c1 a3 b2 c1 a3 b3 c1 a3 b2 c1 a3 b2 c2 a3 b2 c3 a3 b3 c1 a3 b3 c2 a3 b3 c3 -------------------------------------------------------------- ############################################################## n variables ############################################################## n variables Any help and advices would be appreciated. Thank you
  3. could anyone advice how to extend the php class who contains variable? sample below does not work. class test1 extends test2($index){ public function output($index){ echo $index; } } class test2{ public function __construct($index){ echo $index; } } $test = new test1; $test->output('My Test2'); $test->test2('My Test1');
  4. temporary i have publish it on other hosting server (paid one) http://www.pctolife.eu/playground/index.php?m=3 for test reason and can definitely confirm the speed improvements. Looks like it is the server who slows down
  5. Honestly, it is my first experience with blob images and not so successful so far as you can see. I used to save path to images, wanted to try something different... looking forward to hear more of you
  6. I have some issue with the website just created specifically http://ecolandscaping.co/index.php?m=3 and hosted on the 000webhosting.com. It loads the page slowly. Things what i have consideredto trie to improve better performance: * optimized CSS files * optimized MySQL queries with specifying the rows wanted (SELECT ID, IMAGE.....) * avoid to select an image saved as blob if not necessary etc. * made different image retrieving php files P.S. the website is small of size approx 700KB for loading. Problem is that not all the images (saved in MYSQL BLOB) are loaded successfully. Could anyone have a look and advice what else could cause the performance issue. P.S.S. I do take in account that this isthe free hosting and may cause some problems
  7. issue is solved. problem was found in connection function to DB. Could not solve it, re-wrote the function dbConnect() without global variables - works ok.
  8. issue still has a place, any suggestions...
  9. thanks a lot, it works. If it is possible, could you tell me in few words the assigning as array - why? what does _construct do in this case? i apologize i am still newbie.
  10. would anyone know how to assign the value (value returned by some function in the class) of variable $temp in the class: source looks like: class newRecord{ var $temp = listCat('gallery_menu', 'submenu', 'submenu_id'); ////// this line is not working, does not assign? function listCat($table, $submenu, $submenu_id) { $return = '<select name="'.$submenu_id.'" id="'.$submenu_id.'">'; $result = mysql_query("SELECT * FROM $table"); while($row=mysql_fetch_object($result)) { $return = $return.'<option value="'.$row->id.'">'.$row->$submenu.'</option>'; } $return = $return.'</select>'; return $return; } } if function is used out of the class and used in index.php directly, returns expected value of it (there is no doubts - works ok)
  11. if someone thinks that incident is solved - ii IS NOT. Problem still takes a place and any suggestions would be welcome. thank you
  12. 1. i have added function to remove BOM - does not solve the issue function removeBOM($str) { if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) { $str=substr($str, 3); } return $str; } 2. magic_quotes_runtime was and is ON 3. have tried gif, jpg, jpeg, png - none works I would appreciate more comments with suggestions and ideas...Thank you
  13. <?php /*index.php*/ $menu = $_GET["menu"]; $subm = $_GET["subm"]; $text = " vinu aizsakas vel ilgi pirms."; $action = $_GET["action"]; require("sys/functions.php"); dbConnect(); displayheader($menu); /*Home*/ echo '<div class="accordion-toggle"> <a href="aaaaa"><div style="position: absolute; top: 10px; right: 20px; width: 10px; height: 10px; background-color: aqua"></div></a> <a href="aaaaa"><div style="position: absolute; top: 10px; right: 40px; width: 10px; height: 10px; background-color:blue"></div></a> <a href="aaaaa"><div style="position: absolute; top: 10px; right: 60px; width: 10px; height: 10px; background-color:green"></div></a> <a href="aaaaa"><div style="position: absolute; top: 10px; right: 80px; width: 10px; height: 10px; background-color:purple"></div></a> <a href="aaaaa"><div style="position: absolute; top: 10px; right: 100px; width: 10px; height: 10px; background-color:teal"></div></a> H O M E</div> <div class="accordion-content"> <div class="bigcontainer"> <div class="bigcontainertxt">'; bigContainerWithImageTxt($text); echo '</div>'; showLongContainer("img/brown/brownphoto.png", "PHOTOGRAPHY SERVICE", $text); showLongContainer("img/brown/browndesign.png", "WEB DESIGN", $text); showLongContainer("img/brown/brownpc.png", "IT SOLUTIONS", $text); echo '</div>'; echo '</div>'; /*Home*/ /*Photography*/ echo '<div class="accordion-toggle">P H O T O G R A P H Y</div>'; echo '<div class="accordion-content">'; showMenu($subm); if(isset($subm) and $subm!="") { $Browser = new Browser; if ($Browser->Name=="msie") $top = -42; else $top=-30; if(get_rows("gallery")>0) { echo '<div style="position: relative; top: '.$top.'px; z-index: 1;" align="center">'; ?> <img src="sample.php?id=42" /> <?php echo'</div>'; } else echo "Sorry"; } else { echo '<div class="bigcontainer"> <div class="smallcontainerimage"><img src="img/brown/brownphoto.png" /></div> <div class="bigcontainertxt">'; bigContainerWithImageTxt($text); echo '</div>'; showLongContainer("", "PHOTOGRAPHY SERVICES", $text); showLongContainer("", "FOR MODELS", $text); showLongContainer("", "GIFT VOUCHERS", $text); echo '</div>'; } echo '</div>'; /*Photography*/ /*WWW*/ echo '<div class="accordion-toggle">W E B D E S I G N</div> <div class="accordion-content"> <div class="bigcontainer"> <div class="bigcontainertxt">'; bigContainerWithImageTxt($text); echo'</div> <div class="smallcontainerimage"><img src="img/brown/browndesign.png" /></div>'; echo '<div class="webcontainer"> <div class="webcontainertxt"> <div class="title"> <a href="" class="title">www.strods.net</a> </div><br>dfv sdg asf zc dfv sdg asf zc dfv sdg asf zc dfv sdg asf </div> </div>'; echo '<div class="webcontainer"> <div class="webcontainertxt"> <div class="title"> <a href="" class="title">www.strods.net</a> </div><br>dfvsdgasf </div> </div>'; echo '<div class="webcontainer1"> <div class="webcontainertxt"> <div class="title"> <a href="" class="title">www.evergreenlandscapes.ie</a> </div><br>dfvsdgasf </div> </div>'; echo '<div class="webcontainer1"> <div class="webcontainertxt"> <div class="title"> <a href="" class="title">www.nautreni.lv</a> </div><br>dfvsdgasf </div> </div>'; echo '</div>'; echo '</div>'; /*WWW*/ /*PC*/ echo '<div class="accordion-toggle">I T S O L U T I O N S</div> <div class="accordion-content"> <div class="bigcontainer">'; echo'<div class="smallcontainerimage"><img src="img/brown/brownpc.png" /></div>'; echo '<div class="bigcontainertxt">'; bigContainerWithImageTxt($text); echo '</div>'; showLongContainer("", "COMPUTER REPAIR", $text); showLongContainer("", "RECOVERY", $text); showLongContainer("", "MAINTENANCE", $text); echo '</div>'; echo '</div>'; /*PC*/ /*Contact Us*/ echo '<div class="accordion-toggle">C O N T A C T U S</div> <div class="accordion-content">'; if(isset($action)) { $name = CorrectField($_POST["name"]); $email = CorrectField($_POST["email"]); $phone = CorrectField($_POST["phone"]); $message = CorrectField($_POST["message"]); displayForm(); if(CheckField($name, 2)==1 and CheckField($email, 2)==1 and CheckField($phone, 2)==1 and CheckField($message, 2)==1) { if(preg_match('/[^a-z A-Z]/', $name) or CheckField($name, 3)==0) contactError("Please, enter correct name when filling out the form!", "y"); elseif(!preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/', $email) or CheckField($email, 6)==0) contactError("Please, enter correct email address when filling out the form!", "y"); elseif(!is_numeric($phone) or CheckField($phone, ==0) contactError("Please, enter correct phone number when filling out the form!", "y"); elseif(CheckField($message, 10)==0) contactError("Please, enter fully completed text message before sending enquiry!", "y"); else { if(sentEmail($name, $email)==1) mysql_query("INSERT INTO contacts set name = '$name', email = '$email', phone = '$phone', message = '$message'"); } } } else displayForm(); echo '</div>'; /*Contact Us*/ displayFooter(); ?> [color=green]<?php /*sample.php*/ require("sys/functions.php"); dbConnect(); $id = $_GET["id"]; if(!isset($id)) { echo "select an ID"; } else { $res = mysql_query("SELECT * FROM gallery where id=$id"); $row = mysql_fetch_assoc($res); $image = $row["image"]; header("Content-type: image/jpeg"); print $image; exit; } ?> [/color] <?php /*part of functions.php*/ function dbConnect() { global $DBHOST, $DBUSER, $DBPASSWD, $DBNAME; $conn=mysql_connect($DBHOST, $DBUSER, $DBPASSWD); if(!$conn) { echo "Connection with server failed!"; exit(); } if(!mysql_select_db($DBNAME, $conn)) { echo "Connection with database failed!"; mysql_close($conn); exit(); } }; ?> edit: added blocks
  14. Is there anything wrong with my code above or any other suggestions will be appreciated.
  15. I apologize for the insertion code - there is an extra field [extension] in table who was added manually afterwords when dealing with issue. Field info added manually as [jpg] and tried [jpeg] and meant to use for content output. In output source code i removed content output detection and set it manually to [jpeg]
  16. image insertion below (DB table gallery with fields - id(int, auto increment), image(longblob), extension(varchar), date_time(timestamp)) require("sys/functions.php"); dbConnect(); $data = file_get_contents("img/test.jpg"); $data = mysql_real_escape_string($data); mysql_query("INSERT INTO gallery SET image='$data'"); image output below require("sys/functions.php"); dbConnect(); $id = $_GET["id"]; if(!isset($id)) { echo "select an ID"; } else { $res = mysql_query("SELECT * FROM gallery where id=$id"); $row = mysql_fetch_assoc($res); $im = $row["image"]; header("Content-type: image/jpeg"); echo $im; }
  17. i did double check, it worked as described in previous comment by me. shows binary data of file when sample.php?id=42 launched and does not show anything when index.php launched + source code says: <img src="test.php?id=42" /> P.S. Still looking for help. thank you
  18. sorry, i did not reply on your previous comment correctly. I did not get any result with your suggestions when launched index.php (source code showed ..... <img src="sample.php?id=42" />.......). When i launched sample.php?id=42 i got something like binary code of the picture output. Unfortunately i could not get my machine with apache on it at work, so i can not double check it. I will get back as soon as i will be able to. Thank you for your time and efforts. P.S. i will try to use other record with picture, might be problem is hiding in the file or extension or.. or..
  19. I have tried to put some lines of code previously advised (put in comments header() also) without success. errors does not show up any errors. Have anyone tried to put these lines of code on their server, did it work?
  20. Thank you for comments, i will try to do your suggestions, have to leave - i am lucky because working hours are over . Hope it works, otherwise see you tomorrow. have a nice day
  21. unfortunately i have tried the extension jpeg also without success, i have replaced $row[extension] with jpg and jpeg without possibility fail because of mysql or query etc. would my php code work on other servers, might be server settings or smth?
  22. $row[extension] holds the extension of the file and in this case is jpg, it is necessary to define what file output will be expected - picture (png, gif, jpeg, jpg etc.) or pdf or... I am getting image approx 50 x 50 which usually showed when image can not be found or just output. View Source is disabled, i can not look inside the source generated by browser. Opera lets check the file size - approx 259KB. Yes, E_ALL is set and display errors is ON in php.ini
  23. DB field does not contain name and the path to the image because image is located in DB itself. It is not the name of file what is kept in table but image. Is that an answer on your question? if i am wrong, correct me please. P.S. I used to work with mysql and usually kept the path to the image, there were no problems. I am trying to keep images in DB instead of web root folders
×
×
  • 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.