Solved

functions to test MySQL version and if mod_rewrite installed

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now