Jump to content

RLJ

Members
  • Posts

    121
  • Joined

  • Last visited

    Never

Everything posted by RLJ

  1. just to clarify, code as in PHP code. I.e. what's the PHP script I need to give access to a file where direct access has been blocked. Cheers
  2. Hi all, This is probably a very basic question, but it's the first time I've had to deal with it and I can't find a direct answer anywhere online. I have blocked direct access to a file that a user has uploaded in the Apache configuration and in the .htaccess file, so that the file is only accessible through a viewing (PHP) script, which will determine whether the access is allowed or not depending on several factors. What is the actual code I need to give access? Thanks!
  3. Yeah passwords are encrypted, but I would rather not that the webhost can access any information stored in the database. Is there any way of preventing this? The webhost that I am using is iPage (www.ipage.com). Cheers.
  4. Hi all, This is probably a very basic question, but it has recently come to my attention that the support team of the webhost that is hosting my website+database (shared hosting) can create a new user with full privileges and access my database. Is this normal? Seems like a bit of a security gap... Can I prevent this? Thanks!
  5. also if I comment out the banner.load function so that it should just change banner.gif for loading.gif, it doesn't seem to work
  6. A thanks, but I had already tried that as well, it doesn't seem to be working. What I have is the following: <html> <head> <script type="text/javascript" language="javascript"> function bannerload(){ var banner = new Image(); var loading = new Image(); var bannerElement = document.getElementById("BANNER"); banner.src = "IMG/BANNER1-2.gif"; loading.src = "IMG/loading.gif"; banner.onload = function() { bannerElement.removeChild(bannerElement.lastChild); bannerElement.appendChild(banner); }; bannerElement.removeChild(banner); bannerElement.appendChild(loading); } </script> </head> <body onload="bannerload()"> <div id="BANNER"> <img src="IMG/BANNER1-2.gif" alt="Banner" /> </div> </body> </html>
  7. I have tried the following: <html> <head> <script type="text/javascript" language="javascript"> var banner = new Image(); var loading = new Image(); var bannerElement = document.getElementById("BANNER"); banner.src = "IMG/BANNER1-2.gif"; loading.src = "IMG/loading.gif"; banner.onload = function() { bannerElement.removeChild(bannerElement.lastChild); bannerElement.appendChild(banner); }; bannerElement.removeChild(banner); bannerElement.appendChild(loading); </script> </head> <body> <div id="BANNER"> <img src="IMG/BANNER1-2.gif" alt="Banner" /> </div> </body> </html> But it's not working, can someone see where I've gone wrong? Thanks.
  8. Hi all, I have an animated GIF banner on my website that is around 2MB. Currently, I use the following Javascript to preload the banner before the page is displayed: <!-- preload images banner = new Image(); banner.src = \"IMG/banner.gif\"; // End --> However, for people with slower internet connections, I want to write some Javascript that will achieve the following: - page loads up and displays with (small image size) loading.gif instead of banner.gif - banner.gif starts downloading "in the background" - when banner.gif has fully downloaded, loading.gif is replaced with banner.gif and banner.gif starts playing This seems easy, but I'm new to Javascript so I could use some help! Can somebody show me how to do this? Thanks! P.S. if you're thinking why do I need Javascript to do this, it's because if I just include banner.gif as an HTML image (and without the pre-loading Javascript above), it starts playing (and jittering) before it's fully loaded. But perhaps this also depends on the browser.
  9. A yes, thanks. Stupid mistake, I was running the code several times and adding more and more to $emails. Cheers.
  10. Hi all, I have the following code that queries a MySQL database and outputs results on-screen. $result= mysql_query (" SELECT email,firstname,lastname FROM tablename WHERE ID IN('".$IDs."') "); if (!$result) {die('Error: Could not search database. ' );} while($row = mysql_fetch_assoc($result)) { echo $row['firstname']," ",$row['lastname'],"<br />"; $emails[]=$row['email']; } var_dump($emails); var_dump($IDs); However, the two var_dump's output the following (in the case of 2 results for the query): array(6) { [0]=> string(14) "email1@email.com" [1]=> string(23) "email2@email.com" [2]=> string(14) "email1@email.com" [3]=> string(23) "email2@email.com" [4]=> string(14) "email1@email.com" [5]=> string(23) "email2@email.com" } string(67) "9543219aa68ffa1d434dc8530f23fe48','d4384b2b493867706b0bcedda012ed48" ($IDs is an imploded array) Even though the MySQL table only contains one email per ID, both emails are listed 3 times in $emails, instead of just once. Can anyone see why this is? I'm stuck. Thanks!
  11. never mind, just spotted at typo......
  12. Sorry, just noticed there are brackets missing from the if statements, adding extra brackets didnt help though. Just to clarify, script is actually as follows: <script type="text/javascript" language="JavaScript"> function SetPosition() { var HEADHeight = document.getElementById('HEAD').offsetHeight; if (document.getElementById('BANNER')) { document.getElementById('BANNER').style.top = HEADHeight + 10 +'px'; var BANNERHeight = document.getElementById('BANNER').offsetHeight + 5; } else { var BANNERHeight = 0; } document.getElementById('CORE').style.top = HEADHeight + BANNERHEIGHT + 10 +'px'; var COREHeight = document.getElementById('CORE').offsetHeight + 5; if (document.getElementById('ADS')) { document.getElementById('ADS').style.top = HEADHeight + BANNERHEIGHT + COREHeight + 10 +'px'; var ADSHeight = document.getElementById('ADS').offsetHeight + 5; } else { var ADSHeight = 0; } document.getElementById('TAIL').style.top = HEADHeight + BANNERHEIGHT + COREHeight + ADSHeight + 60 +'px'; } </script>
  13. Hi all, I have the following JavaScript function that I want to use to position div's on the page: <script type="text/javascript" language="JavaScript"> function SetPosition() { var HEADHeight = document.getElementById('HEAD').offsetHeight; if (document.getElementById('BANNER') { document.getElementById('BANNER').style.top = HEADHeight + 10 +'px'; var BANNERHeight = document.getElementById('BANNER').offsetHeight + 5; } else { var BANNERHeight = 0; } document.getElementById('CORE').style.top = HEADHeight + BANNERHEIGHT + 10 +'px'; var COREHeight = document.getElementById('CORE').offsetHeight + 5; if (document.getElementById('ADS') { document.getElementById('ADS').style.top = HEADHeight + BANNERHEIGHT + COREHeight + 10 +'px'; var ADSHeight = document.getElementById('ADS').offsetHeight + 5; } else { var ADSHeight = 0; } document.getElementById('TAIL').style.top = HEADHeight + BANNERHEIGHT + COREHeight + ADSHeight + 60 +'px'; } </script> I call this function on the body load as follows: <body onload="SetPosition()"> The above function is not working, it's not changing the position of the divs. Can someone see why? I'm not very knowledgeable on JavaScript, but it seems like it should work. The function was working before, until I changed the following: - body onload="SetPosition()" instead of: body onload="SetPosition('CORE', 'ADS', etc.)" - added the if statements to check whether the div exists. Thanks a lot!
  14. Yeah seems like you might be right, now all session variables are being set correctly, hopefully this will last.
  15. Hi all, I have the following code to check whether the client has javascript enabled in their browser: page.php: <?php session_start(); if(isset($_SESSION['gocheck'])) {$gocheck = $_SESSION['gocheck'];} else {$gocheck = 'no';} //echo $gocheck; if($gocheck=='no'){header ("Location: ./gocheck.php"); exit;} //----Execution only reaches this line if gocheck.php has been run and Javascript is enabled.-------- unset($_SESSION['gocheck']); //rest of page ?> gocheck.php: <?php session_start(); $_SESSION['gocheck'] = 'yes'; echo" <!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\" xml:lang=\"en\" lang=\"en\"> <head> <script type=\"text/javascript\" language=\"JavaScript\"> window.location.replace('page.php'); </script> </head> <body> This website requires Javascript to be enabled in your browser. <br /> Please enable Javascript and try again. </body> </html> "; ?> So what should happen is the user is always redirected from page.php to gocheck.php, which sets the session variable $gocheck to 'yes' and directs back to page.php via Javascript. Because $gocheck is then equal to 'yes', page.php shouldn't direct back again tio gocheck.php. This worked fine on my PC (using WAMP), but when I upload the files to the webhost, it seems to get stuck in an infinite redirect loop between page.php and gocheck.php. Also, if I echo $gocheck in page.php, it returns 'no', so it seems as if for some reason the session variable $gocheck is not being set properly by gocheck.php. Could somebody please shed some light on this? Is there an error in my code? Is there something I need to change in php.ini on the webhost's server? Thanks! P.S. WAMP on my PC uses PHP v.5.3.0, but the webhost uses PHP v.5.2.12 - don't think this can be the problem though.
  16. OK that's pretty clear! Thanks.
  17. Hi all, So I have a table where some rows are set to style="display:none" (then a javascript function unhides them when an "expand" button is clicked), will text inside these rows still be found by search engines such as google? If not, is there a better way to hide this text from the user? Thanks!
  18. Anyone? Sorry if this is a noobish question, but I've never done this before! Thanks
  19. Hi all, So I've nearly finished coding my first website. Currently all the files are in the same directory on my harddrive, but I now want to create a proper folder structure that will be secure. I have been reading up on this a lot on various websites, but it seems like most articles on this topic are targetted at developers with much more complicated websites than mine, and it's all a bit over my head. My website is quite simple, it consists of the following: 1) html files and php files that print something to the screen that I want to be accessible to the user by typing in the url in the browser. 2) html and php files that are called upon by 1, they either print something to the screen inside an iframe or not at all - I want these files to be accessible only to 1) and not directly to the user by typing the url 3) image files and includes, etc. (and also 4) a MySQL database, but maybe this doesn't really have anything to do with the website folder structure.) What should my directory structure be and where should I put 1), 2), 3), etc.? Thanks a lot!
  20. .....never mind. Solved it myself using a while loop on $result and comparing the new and old value of the price each time. Thanks anyway though.
  21. Thanks for your help, but I think it's not quite what I need. I would like to leave $cols untouched so that my query produces an array of several rows or results and then - in addition - I would like to find the lowest values of $price1 and $price2 out of this results array. And btw, values for columns $price1 and $price2 are either numeric or "NO" (the datatype is VARCHAR). So the output that I want would be something like this: ------------------------------------------------------------------------- John Jackson 0.13 25 Bob Johnson 0.14 NO Tom Marley NO 21 Russ Brady 0.19 22 lowest $price1: 0.13 lowest $price2: 21 --------------------------------------------------------------------------- So I don't actually need to know the other data stored in the same row as the lowest price, just the price. So I was hoping I could write some PHP that would take $result and produce the lowest price values, but I don't really know how to do this. Any ideas? Thanks!
  22. Hi all, Just a pretty basic question that I can't find the asnwer to: I have a MySQL query of the following form: $result = mysql_query (" SELECT $cols FROM tablename WHERE......."); Where $cols is as follows: $cols = firstname, lastname, $price1, $price2, etc. ($price1 and $price2 are variable column names that contains prices) How do I find the lowest value for $price1 and/or $price2 out of the results set of this query? Thanks!
  23. Haha, yup, basic and stupid indeed. Changing OR to || worked. Thanks!
×
×
  • 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.