Solved

functions to test MySQL version and if mod_rewrite installed

Posted on 2006-06-12
5
546 Views
Last Modified: 2008-02-01
I need two functions.

1. Function that accepts input version number.  Returns true if the server MySQL version is equal to or greater than the input version.
2. Function that returns true if mod_rewrite is installed on the server.

0
Comment
Question by:killer455
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Accepted Solution

by:
JakobA earned 25 total points
ID: 16891920
1) check mysql version
see: http://dk2.php.net/manual/en/function.mysqli-get-server-version.php

fx:

function checkMySQL( $main, $minor, $sub ) {
    $temp = $main*10000 + $minor*100 + $sub;
    if( $temp <= mysqli-get-server-version( $mysql_conn ) ) {
        return true;
    } else {
        return false;
    }
}
// so if you require 4.1.4 or later:
if ( checkMySQL( 4, 1, 4 ) ) {
    // Yes the SQL is new enough
}

2) to see if mod_rewrite is installed.

<?php
if ( isset( $_ENV['SCRIPT_URL'] ) && isset( $_ENV['SCRIPT_URI'] ) ) {
    // Yes, this is an Apache server with mod_rewrite installed
}
// not entirely safe. environment variables with those names might be created in any
// operating system for other reasons :(
?>

I do not really see the need for this test. It is a once only test (when you place your script on the server), so why not just put a variable in your standard include file?

regards JakobA
0
 

Author Comment

by:killer455
ID: 16895159
I do not really see the need for this test. It is a once only test (when you place your script on the server), so why not just put a variable in your standard include file?

The point was to test the server before installing the script.  Would the extension_loaded php function work?

0
 
LVL 5

Assisted Solution

by:aminerd
aminerd earned 25 total points
ID: 16896600
extension_loaded is for PHP extensions -- not Apache modules.

This should work:

$mod_rewrite = in_array('mod_rewrite', apache_get_modules());
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question