Solved

functions to test MySQL version and if mod_rewrite installed

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 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