Jump to content

yzerman

Members
  • Posts

    182
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

yzerman's Achievements

Member

Member (2/5)

0

Reputation

  1. I forgot to mention, This is on an Apache 2.0.52 server being run on Red Hat. I am not quite sure how much Apache versions and OS types matter, but I know they do matter at times.
  2. After looking over various sites, trying to quickly grasp the concepts behind mod rewrite - and finish my project by the 7pm deadline, I finally found out exactly how to do what I was trying to do and I figured I would share with the rest of the class. Ok the goal behind this mod rewrite was to enable the website to use a url like http://www.foo.com/bar to pull the file bar.php. After numerous failed attempts at getting this to work correctly, I finally went to the apache site, and tried a few of their examples. The one I found that worked was: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-s RewriteRule ^(.*)$ $1.php This however led to another problem. When I went to http://www.foo.com/ without a directory, Apache didn't see anything to rewrite and threw an Internal Server Error fit, so I had to go back and try and figure out this new problem. Now I suck at mod rewrites, and I know little to nothing about Apache configuration - but I dived deep into the Apache mod_rewrite documentation, and I'll be damned if the first thing I tried actually worked: RewriteEngine On RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.*)$ index.php RewriteCond %{REQUEST_FILENAME} !-s RewriteRule ^(.*)$ $1.php Now you have a simple .htaccess mod rewrite guide, and I have something to come back to when I have to do this again. I know this is probably second nature to most of you guru's out there, but for someone who has no idea what to do, this should help out tremendously. Now let me explain this line by line so that the ones who have no idea what the hell this is - can figure it out: First line: RewriteEngine On This one is pretty self explanatory, this turns the Rewrite engine on if it is not already. Second Line: RewriteCond %{REQUEST_FILENAME} -d This is a rewrite conditional (RewriteCond) statement that checks to see if the filename (%{REQUEST_FILENAME}) is a directory (-d). If this conditional turns out to be true, it uses the Rewrite Rule on the third line, if not, it skips to the next rewrite conditional. Third line: RewriteRule ^(.*)$ index.php This line only comes into effect if the conditional in the second line is TRUE and the file name is actually a directory. What this does, is it tells apache to pull index.php. You can probably change this to whatever file you want apache to pull as the default index file. Ok, on to line 4. This line only comes into play if line 2 turns out to be FALSE. RewriteCond %{REQUEST_FILENAME} !-s This line, like the first conditional in line 2, checks to see if the file name (%{REQUEST_FILENAME}) is a file with a size (-s). If this conditional turns out to be true, it uses the Rewrite Rule on the fifth line, if not, then it will throw up an internal server error. Which means I should probably add another conditional, but for my purposes, this works. 5th Line: RewriteRule ^(.*)$ $1.php This line matches the file name (in this example lets use bar) and tells the Apache server that what we really want is bar.php. Hopefully this helps out getting you started with mod rewrite.
  3. make sure that the $to variable is defined and being sent to the mail() function.
  4. yzerman

    STR_TO_DATE

    The date (timestamp %Y-%m-%d) and time (%h:%m%p). I thought that was obvious by the query. Basically the problem I am running into is when I sort by the date, the time field does not get sorted. So I tried to sort by the date (as shown in the query) and the time (meta_title or time, I screwed up the query) so that events on the same date would be arranged by time (12AM to 12PM to 11:59PM)
  5. additionally, using `fieldname` in your queries will save a lot of heartache down the line as some people use reserved names as field names.
  6. That depends on exactly how you are going to be pulling or storing your data overall. If you are not going to call a set of fields all of the time, then it is better if those fields were in a separate table.
  7. yzerman

    STR_TO_DATE

    I have a query that keeps failing. I am using Mysql version 5.0.24a Here is the table setup: +---------------------+-------------------+ | date (timestamp) | time (varchar 255) | +---------------------+-------------------+ | 2008-04-25 00:00:00 | 10:00AM | +---------------------+-------------------+ Now the query: SELECT *,STR_TO_DATE(meta_title, '%h:%m%p') as time, DATE_FORMAT(date, "%Y-%m-%d') from content ORDER BY DATE_FORMAT(date, '%Y-%m-%d'), STR_TO_DATE(time, '%h:%m%p') ASC Ok, now I have rows with: 07:45AM 10:00AM 12:00PM 12:15PM 10:00PM 10:45PM The rows that are on the hour, return as a properly formatted timestamp (10:00AM) The rows that are inbetween hours, return as null strings. Modifying the table structure is not possible, neither is storing the time in the date timestamp. Is this a bug in MySQL or am I doing something wrong?
  8. try this - its untested, and incomplete, but it should get you on the right track: <?php //check that there were no errors, and that something was submitted if(!empty($_FILES) && $_FILES['attachment']['error'] == 0) { //['attachment'] is the name you gave your file input box //no errors, and a file is present - assign and check the values: $file_name = $_FILES['attachment']['name']; $file_type = $_FILES['attachment']['type']; $file_size = $_FILES['attachment']['size']; $file_tmpname = $_FILES['attachment']['tmp_name']; $error = array(); //set allowed file types and check against the uploaded file $allowed_types = array('image/jpeg','image/pjpg','image/png','image/gif'); if(!in_array($allowed_types, $file_type)) { //not an allowed file type $error .= 'type'; } //next set the max filesize and check it against your file. 1048576 bytes = 1 mb $max_size = 1048576; if($max_size < $file_size) { //if the file is larger then the max size allowed: $error .= 'size'; } //and so on.... //File checking done, lets see if there were any errors: if(!empty($error)) { //there was an error //some code here explaining what the errors were and output to the user } else { //no errors //upload the file } } //fin ?>
  9. got it working, thanks for the help.
  10. oh - and sorry about the double post ken.
  11. um, what did you change? BTW, I tried your code, and it doesn't work. Same issue.
  12. ok, I am at a loss here. First the code (majority of which is courtesy of labs.mininova.org: <script type="text/javascript"> <!-- var pop = document.getElementById('popup'); var xoffset = 15; var yoffset = 10; document.onmousemove = function(e) { var x, y, right, bottom; try { x = e.pageX; y = e.pageY; } // FF catch(e) { x = event.x; y = event.y; } // IE right = (document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth); bottom = (window.scrollY || document.documentElement.scrollTop || document.body.scrollTop) + (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight); x += xoffset; y += yoffset; if(x > right-pop.offsetWidth) x = right-pop.offsetWidth; if(y > bottom-pop.offsetHeight) y = bottom-pop.offsetHeight; pop.style.top = y+'px'; pop.style.left = x+'px'; } function popup(title, text, img) { pop.innerHTML = "<p><h1>" + title + "</h1><p><img width='100' height='75' src='http://www.mysite.com/uploads/" + img + "'/>" + text + "</p>"; pop.style.display = 'block'; } function popout() { pop.style.display = 'none'; } //--> </script> here is the code for the popup: <style type="text/css"> #popup { background-color:#EEEEEE; border:1px solid #00CC66; display:none; font-size:xx-small; opacity:0.95; position:absolute; width:400px; z-index:30; } </style> <div class="popup" id="popup" style="display:none;"></div> <a class="10" onmouseover="popup('The Title','The body Text','theimage.jpg')" onmouseout="popout()">More Info</a> When I implement this code into the website, and hover over the More Info link, the page jumps around but the div doesnt show unless I hit a certian sweet spot. IE is the problem, Firefox it works just fine. Any ideas?
  13. ok, I am at a loss here. First the code (majority of which is courtesy of labs.mininova.org: <script type="text/javascript"> <!-- var pop = document.getElementById('popup'); var xoffset = 15; var yoffset = 10; document.onmousemove = function(e) { var x, y, right, bottom; try { x = e.pageX; y = e.pageY; } // FF catch(e) { x = event.x; y = event.y; } // IE right = (document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth); bottom = (window.scrollY || document.documentElement.scrollTop || document.body.scrollTop) + (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight); x += xoffset; y += yoffset; if(x > right-pop.offsetWidth) x = right-pop.offsetWidth; if(y > bottom-pop.offsetHeight) y = bottom-pop.offsetHeight; pop.style.top = y+'px'; pop.style.left = x+'px'; } function popup(title, text, img) { pop.innerHTML = "<p><h1>" + title + "</h1><p><img width='100' height='75' src='http://www.mysite.com/uploads/" + img + "'/>" + text + "</p>"; pop.style.display = 'block'; } function popout() { pop.style.display = 'none'; } //--> </script> here is the code for the popup: <style type="text/css"> #popup { background-color:#EEEEEE; border:1px solid #00CC66; display:none; font-size:xx-small; opacity:0.95; position:absolute; width:400px; z-index:30; } </style> <div class="popup" id="popup" style="display:none;"></div> <a class="10" onmouseover="popup('The Title','The body Text','theimage.jpg')" onmouseout="popout()">More Info</a> When I implement this code into the website, and hover over the More Info link, the page jumps around but the div doesnt show unless I hit a certian sweet spot. IE is the problem, Firefox it works just fine. Any ideas?
  14. Depending on the version of your PHP (only avaliable in PHP5) you can set the default timezone of all of the date and time functions using the date_default_timezone_set() function.
×
×
  • 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.