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
Solved

functions to test MySQL version and if mod_rewrite installed

Posted on 2006-06-12
5
540 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

839 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