Jump to content

thunderousity

Members
  • Posts

    40
  • Joined

  • Last visited

Everything posted by thunderousity

  1. Ah ok - Done a bit more reading. I thought the ob_gzhandler indicated to the server to run gzip for that page. I have removed both the mod_gzip text from the .htaccess file and the ob_gz_handler part from the page. I removed the mod_gzip text from the .htaccess file as it still wasn't compressing according to whatsmyip gzip test I added the following Deflate text to the .htaccess file instead to see if this would work but still no compression. AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript Using Chrome dev tools I checked the response headers and there is no content-encoding being returned despite Accept- encoding being present in the request header section and returning 'gzip, deflate'.
  2. In a bid to make my site faster I thought I would do as the site tests suggest and implement gzip page compression. I have checked to see that gzip is enabled. Check. I have added the following code to my .htaccess file. (I also tried the AddOutputFilterByType DEFLATE text/plain but that didn't seem to work, which may be down to the fact that I hadn't added <? ob_start("ob_gzhandler"); ?> at that time) <ifModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_include mime ^text/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_include handler ^cgi-script$ </ifModule> Added this code in my php: <? ob_start("ob_gzhandler"); ?> However I get the following error: ob_start(): failed to create buffer in /somefolder/anotherfolder on line 2, referer: https://www.google.com/ ...mod_fcgid: stderr: PHP Warning: ob_start(): output handler 'ob_gzhandler' cannot be used twice... Took me ages to find the fact that I needed the <? ob_start("ob_gzhandler"); ?> in my pages. Annoyingly, most sites tell you to just add the mod_gzip code to .htaccess file. Any ideas?
  3. I have 2 tables. A table full of items with an ID number and various values (Table A) and a table which works as the basis for an Item comparison using the ItemID's (Table B ) Table A ItemID, Item_Name, Value_1 1, Potato, 50 2, Carrot, 45 3, Broccoli, 35... Table B ComparisonID, ItemID1, ItemID2 1, 1, 3 2, 2 ,3 3, 5, 145 Requirement: I want to return the ItemID, Item Name and Value for each row in Table B like so Results: ItemID1, Item_Name, Value_1, ItemID2, Item_Name, Value_1 1, Potato, 50, 3, Broccoli, 35 2, Carrot, 45, 3, Broccoli, 35 5, Courgette, 102, 145, Banana, 274 I can create the basic MySQL to return each of the columns using a Union query. However I don't think this is the way to go. It's the part where I need to iterate through each row in Table B whilst also using separate ItemID's for separate columns from the same row that I can't get my head around. Table B will only be up to 1000 rows so it doesn't need to be too efficient. Any ideas where to start? Cheers.
  4. This looks much neater thanks. However, this seems to randomise the name order but the names always start with an A SELECT n.Name, g.Gender FROM tblnames AS n INNER JOIN tblgender AS g ON n.GenderID = g.GenderID WHERE name Like CONCAT( CAST( CHAR( floor( 65 + rand() * (1+90-65) ) ) AS CHAR(3) ) , '%')
  5. I have been working on a query to return a list of names filtered by a random beginning letter A - Z. The following SELECT gives me a random letter using ASCII characters A-Z or 65-90. 1. SELECT floor(65 + (rand() * (1+90-65))) as RandomBetween65and90 The next statement is my main query which at the moment filters rows using Like by a specified ASCII Decimal. In the example below this is 65 or A I had to CAST the CHAR function to return an ASCII Character rather than a decimal for the Like 'A%' 2. SELECT n.Name, g.Gender FROM tblnames AS n INNER JOIN tblgender AS g ON n.GenderID = g.GenderID WHERE name Like CONCAT((SELECT CAST(CHAR(65) AS CHAR(3))), '%') These both work in isolation, however when I try to combine the 2 statements and replace the 65 in the 2nd statement with the 1st statement as a subquery to give me a random letter I don't get the results I expect. I seem to get random rows rather than rows based on a random beginning letter. SELECT n.Name, g.Gender FROM tblnames AS n INNER JOIN tblgender AS g ON n.GenderID = g.GenderID WHERE name Like CONCAT((SELECT CAST(CHAR((SELECT floor(65 + (rand() * (1+90-65))))) AS CHAR(3))), '%') ORDER BY n.Gender
  6. Nope I've changed it according to my environment I've managed to get it working Stopped Apache; I edited the Hosts file and httpd-vhosts.conf Navigate to C:/xampp/apache/conf/extra or wherever your XAMPP files are located. Open the file named httpd-vhosts.conf with a text editor. Around line 19 find # NameVirtualHost *:80 and uncomment or remove the hash. <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs" ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/mysite" ServerName mysite.localhost <Directory "C:/xampp/htdocs/mysite"> Options Indexes FollowSymLinks ExecCGI Includes Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/ZendApp1" ServerName ZendApp1.localhost <Directory "C:/xampp/htdocs/ZendApp1"> Options Indexes FollowSymLinks ExecCGI Includes Order allow,deny Allow from all </Directory> </VirtualHost> 'Hosts' file edited by un-commenting the first 127.0.0.1 line and adding the two lines for my sites like so # localhost name resolution is handled within DNS itself. 127.0.0.1 localhost 127.0.0.1 ZendApp1.localhost 127.0.0.1 mysite.localhost # ::1 localhost Restarted Apache I can now access the sites via http://mysite.localhost and http://ZendApp1.localhost albeit I can only see the file structure for the ZendSkeletonApplication e.g Index of /
  7. Well I'm trying to install the skeleton application as this seems like a good place to start. I'm at home now on Win 8 with my install which I named "ZendApp1" located here C:xampphtdocsZendApp1 I've managed to get to point 13 on here ok so far, however the next steps seem to be confusing. I've tried both options below but none worked, I started and stopped XAMPP at various points but nothing worked - The first site suggests adding this to httpd.conf but the instructions seem biased towards wamp <VirtualHost *:80> ServerName zf2crud.localhostDocumentRoot C:wampwwwzf2crudpublicSetEnv APPLICATION_ENV "development"<Directory C:wampwwwzf2crudpublic>DirectoryIndex index.phpAllowOverride AllOrder allow,denyAllow from all</Directory></VirtualHost> So I tried this site http://austinpassy.com/2012/setting-up-virtual-hosts-wordpress-multisite-with-xampp-on-windows-7/ which suggests editing the hosts file and editing httpd-vhosts.conf file in the following manner - <VirtualHost *>ServerAdmin admin@localhost.comDocumentRoot "C:/xampp/htdocs" # change this line with your htdocs folderServerName localhostServerAlias localhost<Directory "C:/xampp/htdocs">Options Indexes FollowSymLinks Includes ExecCGIOrder allow,denyAllow from all</Directory></VirtualHost> <VirtualHost eateryengine.dev>ServerAdmin admin@localhost.comDocumentRoot "C:/xampp/htdocs/eateryengine" # change this line with your htdocs folderServerName eateryengine.devServerAlias eateryengine.dev<Directory "C:/xampp/htdocs/eateryengine">Order allow,denyAllow from all</Directory></VirtualHost> Any pointers?
  8. hmmm - Maybe this is the way to install Zend Framework 2 on XAMPP http://www.w3programmers.com/install-zend-framework-2-on-your-wamp-and-xampp-server/
  9. I'm a complete noob to all the Framework apart from the very basic concept. However I want to learn more so I can use things like Zend Translate. I'm trying to set up an environment on my Win 7 laptop with my current XAMPP 1.8.2 install. After reading various installation tutorials I'm still confused as they all seem to be slightly different - some make it look easy others a lot of configuration is required. Maybe it depends upon your environment. I'm using this tutorial as this seems simplest and is tailored to xampp. http://mattbearman.com/2010/05/18/how-to-install-zend-framework-with-xampp/ I've downloaded and extracted the Zend Framework 2.2.4 Full Package from here http://framework.zend.com/downloads/latest Bearmans instructions tell me to install to the include_path. However this is configured out of the box to the pear folder shown in my php.ini file as include_path=".;C:xamppphpPEAR" I assume I can install the Zend framework to another folder to seperate it from PEAR to the following include_path=".;C:xamppphpZend" Do I keep the PEAR include_path and add both paths or do I replace it with the zend path. I have no intention of using PEAR now or in the future. tbh I don't know that much about it so maybe I am using it but don't know I am? Once I have the include_path sorted how do I know that it is installed correctly. I've seen tutorials that create projects using command line. I've also seen something about a Skeleton application that can be used to get started a little quicker. do I download this as a project?
  10. Maybe if I'd have read your signature I would have known it was a CSS issue and not a JS issue. I've just been using Bluefish to edit my website and just using the Source in Chrome to debug. Working blind it seems. Saw a mention of Firebug in this thread when looking back through the posts and also the mention of debuggers in your signature and had a look at the built in Chrome debugger. Cheers justsomeguy - this should help loads.
  11. Wow didn't know this existed. I've had a quick read and watched a few videos. Looks like I'll need to get my head around the Zend Framework but I can see some real potential in Globalising my site. Food for thought.
  12. I tried adding the code you suggested in various places but nothing seemed to work. Could I not use jquery to check for an odd number using some sort of if statement. The script would need to check whether the number of divs that are to be shown is odd. If it is odd then subtract 1. I think this would fix it but I'm unsure how to check for odd numbers and at what point. i.e. On Click
  13. I wasn't sure where to put this thread but seeing it is a php based one I've put it here. Feel free to move it somewhere appropriate if need be. I was contemplating translating my site to other languages. I already use Google Translate on my site but that has it's limitations. The main reason for translating the site is so that my pages rank higher in search for the native language. I assume that to get to my website pages currently is by searching in English first and then use the Google translate functionality on my site to change it to a different language. Translating the site has its added overhead that whenever I change a page I have to translate that into other languages. However, my site relies heavily on numbers and statistics and on dynamic PHP/SQL so the wording doesn't alter that much across my pages. Are there any tools, tips or gotchas in achieving this? Is it worth the effort - I'm thinking about translating to Chinese and Spanish for obvious increases in potential traffic.
  14. http://www.autosnout.com/Cars-0-60mph-Listnew.php Try this. Works fine until you select 'More Rows' a few times and an additional subheading (Between 3 and 4 Seconds) appears. This knocks the increments out of synch as the sub heading adds another div. Removing the div for the sub-heading behaves like this; http://www.autosnout.com/Cars-0-60mph-Listnew2.php
  15. I have a JQuery Script (vers 1.10.2) which shows or hides chunks of rows from a php based list. This works by showing or hiding a specific number of css related div elements by clicking the 'Show More' or 'Show Less' text at the bottom of the visible list. It works fine apart from when the Group Heading for a new group in the list appears and puts the incrementing div elements out of sync. Group Heading: echo "<div><h3 class='listrow'>Between ".$min." and ".$max." seconds.</h3></div>" Hmm - Just remove the div element in the group heading I hear you say. When I remove the div element from the sub heading part of the echo, all the sub headings appear at once but the rows work as they should do. i.e. show or hide upon a click. How can I fix this? Code below CSS: <style>.myDiv div{ display:none;}#MoreRows {color:green; cursor:pointer;}#MoreRows:hover {color:black;}#LessRows {color:red; cursor:pointer;}#LessRows:hover {color:black;}</style> JavaScript: $(document).ready(function () { $('.myDiv div:lt(41)').show(); $('#LessRows').hide(); var items = 50000; var minimum = 40; var shown = 40; $('#MoreRows').click(function () { $('#LessRows').show(); shown = $('.myDiv div:visible').size()+40; if(shown< items) {$('.myDiv div:lt('+shown+')').show();} else {$('.myDiv div:lt('+items+')').show(); $('#MoreRows').hide(); } }); $('#LessRows').click(function () { shown = $('.myDiv div:visible').size(); if(shown> 40) { calco = $('.myDiv div:visible').size()-40; $('.myDiv div').not(':lt('+calco+')').hide(); $('#MoreRows').show();} else {$('#LessRows').hide(); $('#MoreRows').show(); } });}); PHP <div class="content"><div class="listrow"><div class="myDiv"><?php$min = 0;$increment = 1;$max = $min - $increment;$rowclass = 0;while ($row_rs3 = mysql_fetch_assoc($rs3)){ if ($row_rs3['Seconds'] > $max) { while ($max < $row_rs3['Seconds']) $max += $increment; $min = $max - $increment; echo "<div><h3 class='listrow'>Between ".$min." and ".$max." seconds.</h3></div>"; } echo "<div class= row" . $rowclass . "><div class='alignleft'><a title=" . $row_rs3['Seconds'] . " specifications href=specifications.php?SpeedID=" . $row_rs3['ItemID'] . ">" .$row_rs3['Item'] . "</a></div><div class='alignright'> Speed - <b>" . $row_rs3['Seconds'] . "</b> seconds</div><div style='clear: both;'></div></div>"; $rowclass = 1 - $rowclass;}?></div><div id="MoreRows">More Rows</div><div id="LessRows">Less Rows</div> </div> </div>
  16. I usually use the following syntax for my php pages mysql_select_db($database_school, $school);$query_Recordset1 = "SELECT * FROM tblSchool";$Recordset1 = mysql_query($query_Recordset1, $school) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1); and use something like this to echo the results echo "<table border='1'>< tr>< th>Firstname</th>< th>Lastname</th>< /tr>";while($row = mysql_fetch_assoc($Recordset1)) { echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "</tr>"; }echo "</table>"; Scenario: I usually do 2 separate PHP/MYSQL statements as above with 2 separate results but that doesn't seem very efficient. In a bid to be more efficient what if I have 1 query which returns 2 rows but I want to echo the first row of results on one side of the web page and the second somewhere completely different on the page. I can't really use a 'while' statement as it's not really a list. I'm guessing I'd have to put it in an array where I can specify which row I want to echo?
  17. This works: SET @tol1 = 10;SET @tol2 = 200;SET @trig = 400;SET @car = 15;(n.b. Value1 is an aggregation - for simplicity it is just Value1 - hence using HAVING in the BETWEEN)SELECT EditionID, Make, Model, EditionDesc, Value1FROM t1HAVING Value1BETWEEN(SELECT CASE WHEN Value1 <= @trigTHEN TRUNCATE(Value1-@tol1,1)ELSE TRUNCATE(Value1-@tol2,1)END as Value1minFROM t1 WHERE EditionID = @car) iTable1)AND(SELECT CASE WHEN Value1 <= @trigTHEN TRUNCATE(Value1+@tol1,1)ELSE TRUNCATE(Value1+@tol2,1)END as Value1maxFROM t1 WHERE EditionID = @car) iTable2)ORDER BY Value1
  18. I have the following SQL statement that selects all the values from a table based upon the row EditionID passed to it via $POST - in this example EditionID is 10 The query gives me 2 values as a tolerance + and - 10 on which to base the list from using BETWEEN However, I want the @tol variable to change to a larger tolerance (lets say 20) if Value1 is >= the integer specified in the variable @trig. I'm not sure how to go about this - as the Value1 values need to be retrieved via the sub queries before making another pass at the sub queries, this time with the correct @tol variable. SET @tol = 10;SET @trig = 300; SELECT EditionID, Make, Model, EditionDesc, Value1FROM t1HAVING Value1BETWEEN(SELECT Value1, TRUNCATE(Value1-@tol) as Value1minFROM t1 WHERE EditionID = 10) iTable1)AND(SELECT Value1, TRUNCATE(Value1+@tol) as Value1maxFROM t1 WHERE EditionID = 10) iTable2)ORDER BY Value1
  19. Hmmm iframe - that got me thinking. I think i'm going to use a google custom search engine as a solution. I've had a look and you can pass a parameter in the url and pre-populate the search. You can also configure it so that it only shows an image search too.
  20. Hi, Is there a way I can dynamically populate a web page on my site with images from google? e.g. Say I have a website about animals and I wanted a hyperlink on this page saying 'More Meerkat images...' or 'More Lion Images'. Once clicking on this link it takes me to a page which automatically loads a specified number of Meerkat or whatever animal the source page is about and the pictures are taken from Google images but embedded on the destination page on my site. The images should be populated based upon a value either passed to the url or from the title of the webpage(which would be passed via php) so that it can be dynamic - There will be hundreds of animal :-) hope that makes sense
  21. Hi MySQL experts, I have a small 250 row excel spreadsheet I want to use to popluate an existing table. I need a: the values to be imported in the correct row based on matching id'sb: I also need to ignore inserting into the first two columns (MakeID and Make) So, the last 3 columns of the csv file are inserted into col3,4 and 5 respectively of the mysql table where MakeID is the same. MySQL Table: MakeID, Col2, Col3, Col4 CSV file MakeID, Make, Col3, Col4, Col51, AUDI, 2000, 20, Sometext2, Alfa, 1987, 25, Somemoretext3, Ford, 1999, 30, Evenmoretext I wanted to do this via phpmyadmin but the Import function doesn't seem to allow for this complexity.
  22. This seems to work - The else section allocates a value of my choice when the page first loads,If I submit the page and the page reloads as part of my input validation error then the first part of the if statement is executed and returns the posted value as selected one this time: <form action="<?php echo $editFormAction; ?>" name="addnewtitle" id="addnewtitle" method="POST"> <table width="100%" border="1" bordercolor="#CCCCCC"> <tr> <td bgcolor="#CCCCCC"><h3 align="left">Title</h3></td> <td><h3 align="left"> <select name="titleid" id="titleid"> <?phpdo { ?> <option value="<?php echo $row_rsttitle['titleid']?>" <?php if (isset($_POST['titleid'])) { if (!(strcmp($row_rsttitle['titleid'], $_POST['titleid']))) {echo "SELECTED";} } else { if (!(strcmp($row_rsttitle['titleid'], 1))) {echo "SELECTED";} } ?>> <?php echo $row_rsttitle['title']?></option> <?php} while ($row_rsttitle = mysql_fetch_assoc($rsttitle)); $rows = mysql_num_rows($rsttitle); if($rows > 0) { mysql_data_seek($rsttitle, 0); $row_rsttitle = mysql_fetch_assoc($rsttitle); }?> </select>
  23. This is for my own content management system. The inputting form is validated by php (no javascript validation), thus when I input something incorrectly or omit a value I get the error messages I expect through my php sanity checking scripts. What I'm interested in is keeping the values I have input after I receive the validation errors on submission so that I don't have to re-input them all again.
  24. I have a drop down list which I want to be able to remember and return the original inputted value even after there is a PHP validation error. Below is the code I have - please feel free to offer some simpler looking code too as it looks a bit ugly. <select name="TestID" id="TestID"> <?phpdo { ?> <option value="<?php echo $row_rstTest['TestID']?>"<?php if (!(strcmp($row_rstTest['TestID'], 1))) {echo "SELECTED";} ?>><?php echo $row_rstTest['Test']?></option> <?php} while ($row_rstTest = mysql_fetch_assoc($rstTest)); $rows = mysql_num_rows($rstTest); if($rows > 0) { mysql_data_seek($rstTest, 0); $row_rstTest = mysql_fetch_assoc($rstTest); }?> </select>
  25. I've added a widget to the footer and this is also suffering a similar fate with the thumbnails :-(
×
×
  • Create New...